diff options
author | josephv@chromium.org <josephv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-23 02:36:32 +0000 |
---|---|---|
committer | josephv@chromium.org <josephv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-23 02:36:32 +0000 |
commit | 2a136846bbaa93727667b58b78e4f8831b839e8d (patch) | |
tree | 16b44561ff0cf849d266a75823b70e36f2f79f77 /chrome | |
parent | 1fe1888b41f27c3ea55646a4f64c26e3dc2e2f93 (diff) | |
download | chromium_src-2a136846bbaa93727667b58b78e4f8831b839e8d.zip chromium_src-2a136846bbaa93727667b58b78e4f8831b839e8d.tar.gz chromium_src-2a136846bbaa93727667b58b78e4f8831b839e8d.tar.bz2 |
Adding test suite for flash
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/7481017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
2 files changed, 110 insertions, 0 deletions
diff --git a/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/control b/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/control new file mode 100644 index 0000000..4f0c02a --- /dev/null +++ b/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/control @@ -0,0 +1,19 @@ +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +AUTHOR = "Chrome OS Team" +NAME = "desktopui_PyAutoFlashTests" +PURPOSE = "PyAuto based Chrome flash tests." +CRITERIA = "This test will fail if running Chrome returns a command error." +TIME = "LONG" +TEST_CATEGORY = "Functional" +TEST_CLASS = "desktopui" +TEST_TYPE = "client" + +DOC = """ +This is a wrapper test for Chrome pyauto-based flash tests. +http://dev.chromium.org/developers/testing/pyauto +""" + +job.run_test('desktopui_PyAutoFlashTests') diff --git a/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/desktopui_PyAutoFlashTests.py b/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/desktopui_PyAutoFlashTests.py new file mode 100644 index 0000000..bb886234 --- /dev/null +++ b/chrome/test/chromeos/autotest/files/client/site_tests/desktopui_PyAutoFlashTests/desktopui_PyAutoFlashTests.py @@ -0,0 +1,91 @@ +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import dbus +import os +import pwd +import shutil +import subprocess + +from autotest_lib.client.bin import utils +from autotest_lib.client.cros import constants, chrome_test, cros_ui + + +class desktopui_PyAutoFlashTests(chrome_test.ChromeTestBase): + """Wrapper for running Chrome's PyAuto-based functional tests. + + Performs all setup and fires off the CHROMEOS_FLASH test suite. + """ + version = 1 + + def initialize(self): + chrome_test.ChromeTestBase.initialize(self) + assert os.geteuid() == 0, 'Need superuser privileges' + + deps_dir = os.path.join(self.autodir, 'deps') + subprocess.check_call(['chown', '-R', 'chronos', self.cr_source_dir]) + + # Setup /tmp/disable_chrome_restart + if not os.path.exists(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE): + open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() + + # Setup suid python binary which can enable Chrome testing interface + suid_python = os.path.join(self.test_binary_dir, 'suid-python') + py_path = subprocess.Popen(['which', 'python'], + stdout=subprocess.PIPE).communicate()[0] + py_path = py_path.strip() + assert os.path.exists(py_path), 'Could not find python' + if os.path.islink(py_path): + linkto = os.readlink(py_path) + py_path = os.path.join(os.path.dirname(py_path), linkto) + shutil.copy(py_path, suid_python) + os.chown(suid_python, 0, 0) + os.chmod(suid_python, 04755) + + def _session_manager_ready(self, old_pid): + pgrep_process = subprocess.Popen(['pgrep', 'session_manager'], + stdout=subprocess.PIPE) + new_pid = pgrep_process.communicate()[0].strip() + if not new_pid or old_pid == new_pid: + return False + + try: + bus = dbus.SystemBus() + proxy = bus.get_object('org.chromium.SessionManager', + '/org/chromium/SessionManager') + dbus.Interface(proxy, 'org.chromium.SessionManagerInterface') + except dbus.DBusException: + return False + return True + + def run_once(self): + # Make sure Chrome minidumps are written locally. + minidumps_file = '/mnt/stateful_partition/etc/enable_chromium_minidumps' + if not os.path.exists(minidumps_file): + open(minidumps_file, 'w').close() + pgrep_process = subprocess.Popen(['pgrep', 'session_manager'], + stdout=subprocess.PIPE) + old_pid = pgrep_process.communicate()[0].strip() + subprocess.call(['pkill', constants.SESSION_MANAGER]) + utils.poll_for_condition( + lambda: self._session_manager_ready(old_pid), timeout=20) + assert os.path.exists(minidumps_file) + + # Enable Chrome testing interface and Login + deps_dir = os.path.join(self.autodir, 'deps') + pyautolib_dir = os.path.join(self.cr_source_dir, + 'chrome', 'test', 'pyautolib') + login_cmd = cros_ui.xcommand_as( + 'python %s chromeos_utils.ChromeosUtils.LoginToDefaultAccount ' + '-v --no-http-server' % + os.path.join(pyautolib_dir, 'chromeos', 'chromeos_utils.py')) + utils.system(login_cmd) + + # Run pyauto tests in the "CHROMEOS_FLASH" test suite + chronos_id = pwd.getpwnam('chronos') + os.chown(os.getcwd(), chronos_id.pw_uid, chronos_id.pw_gid) + functional_cmd = cros_ui.xcommand_as( + '%s/chrome_test/test_src/chrome/test/functional/' + 'pyauto_functional.py --suite=CHROMEOS_FLASH -v' % deps_dir) + utils.system(functional_cmd) |