def run_once(self): """Entry point of this test.""" # Mash requires a connected display to start chrome. Chromebox and # Chromebit devices in the lab run without a connected display. # Limit this test to devices with a built-in display until we can fix # mash. http://crbug.com/673561 if site_utils.get_board_type() not in ['CHROMEBOOK', 'CHROMEBASE']: logging.warning('chrome --mash requires a display, skipping test.') return # The test is sometimes flaky on these boards. Mash doesn't target # hardware this old, so skip the test. http://crbug.com/679213 boards_to_skip = [ 'x86-mario', 'x86-alex', 'x86-alex_he', 'x86-zgb', 'x86-zgb_he' ] if utils.get_current_board() in boards_to_skip: logging.warning('Skipping test run on this board.') return # GPU info collection via devtools SystemInfo.getInfo does not work # under mash due to differences in how the GPU process is configured. # http://crbug.com/669965 mash_browser_args = ['--mash', '--gpu-no-complete-info-collection'] logging.info('Testing Chrome --mash startup.') with chrome.Chrome(auto_login=False, extra_browser_args=mash_browser_args): logging.info('Chrome --mash started and loaded OOBE.') logging.info('Testing Chrome --mash login.') with chrome.Chrome(extra_browser_args=mash_browser_args): logging.info('Chrome login with --mash succeeded.')
def run_once(self): """Entry point of this test.""" # Flaky on nyan_* boards. http://crbug.com/717275 boards_to_skip = ['nyan_big', 'nyan_kitty', 'nyan_blaze'] if utils.get_current_board() in boards_to_skip: logging.warning('Skipping test run on this board.') return # GPU info collection via devtools SystemInfo.getInfo does not work # under mash due to differences in how the GPU process is configured # with mus hosting viz. http://crbug.com/669965 mash_browser_args = [ '--enable-features=Mash', '--disable-features=SingleProcessMash', '--gpu-no-complete-info-collection' ] logging.info('Testing Chrome with Mash startup.') with chrome.Chrome(auto_login=False, extra_browser_args=mash_browser_args): logging.info('Chrome with Mash started and loaded OOBE.') self.__screen_visual_sanity_test() logging.info('Testing Chrome with Mash login.') with chrome.Chrome(extra_browser_args=mash_browser_args): logging.info('Chrome login with Mash succeeded.')
def run_once(self): """Entry point of this test.""" # The test is flaky on x86-* boards. Mash doesn't target hardware this # old, so skip the test. http://crbug.com/679213 # The test is also flaky on nyan_* boards. Temporarily skip the test # until this can be fixed. http://crbug.com/717275 boards_to_skip = [ 'x86-mario', 'x86-alex', 'x86-alex_he', 'x86-zgb', 'x86-zgb_he', 'nyan_big', 'nyan_kitty', 'nyan_blaze' ] if utils.get_current_board() in boards_to_skip: logging.warning('Skipping test run on this board.') return # GPU info collection via devtools SystemInfo.getInfo does not work # under mus due to differences in how the GPU process is configured. # http://crbug.com/669965 mus_browser_args = ['--mus', '--gpu-no-complete-info-collection'] logging.info('Testing Chrome --mus startup.') with chrome.Chrome(auto_login=False, extra_browser_args=mus_browser_args): logging.info('Chrome --mus started and loaded OOBE.') logging.info('Testing Chrome --mus login.') with chrome.Chrome(extra_browser_args=mus_browser_args): logging.info('Chrome login with --mus succeeded.')
def run_once(self): username = '' with chrome.Chrome() as cr: username = cr.username if not cryptohome.is_vault_mounted(user=username, allow_fail=False): raise error.TestFail('Expected to find a mounted vault.') if cryptohome.is_vault_mounted(user=username, allow_fail=True): raise error.TestFail('Expected to not find a mounted vault.') # Remove our vault, mount another vault, create a test file # in the other vault, and ensure that the file no longer exists # after we log back in. cryptohome.remove_vault(username) cryptohome.mount_vault(TEST_USER, TEST_PASS, create=True) test_file = os.path.join(cryptohome.user_path(TEST_USER), 'hello') open(test_file, 'w').close() cryptohome.unmount_vault(TEST_USER) with chrome.Chrome(): if not cryptohome.is_vault_mounted(user=username, allow_fail=False): raise error.TestFail('Expected to find user\'s mounted vault.') if os.path.exists(test_file): raise error.TestFail('Expected to not find the test file.')
def run_once(self): listener = session_manager.OwnershipSignalListener(gobject.MainLoop()) listener.listen_for_new_key_and_policy() # Sign in. Sign out happens automatically when cr goes out of scope. with chrome.Chrome(clear_enterprise_policy=False) as cr: listener.wait_for_signals(desc='Owner settings written to disk.') key = open(constants.OWNER_KEY_FILE, 'rb') hash = hashlib.md5(key.read()) key.close() mtime = os.stat(constants.OWNER_KEY_FILE).st_mtime # Sign in/sign out as a second user. with chrome.Chrome(clear_enterprise_policy=False, username=self._TEST_USER, password=self._TEST_PASS, gaia_id=self._TEST_GAIAID) as cr: pass # Checking mtime to see if key file was touched during second sign in. if os.stat(constants.OWNER_KEY_FILE).st_mtime > mtime: raise error.TestFail("Owner key was touched on second login!") # Sanity check. key2 = open(constants.OWNER_KEY_FILE, 'rb') hash2 = hashlib.md5(key2.read()) key2.close() if hash.hexdigest() != hash2.hexdigest(): raise error.TestFail("Owner key was touched on second login!")
def run_once(self, count=None): if count: # Run stress test by logging in and starting ARC several times. # Each iteration is about 15s on Samus. for i in range(count): logging.info('cheets_CTSHelper iteration %d', i) with chrome.Chrome( arc_mode=arc.arc_common.ARC_MODE_ENABLED) as _: time.sleep(2) else: # Utility used by server tests to login. We do not log out, and # ensure the machine will be rebooted after test. try: self.chrome = chrome.Chrome( arc_mode=arc.arc_common.ARC_MODE_ENABLED, init_network_controller=False) except: # We are going to paper over some failures here. Notice these # should still be detected by regularly running # cheets_CTSHelper.stress. logging.error('Could not start Chrome. Retrying soon...') # Give system a chance to calm down. time.sleep(20) self.chrome = chrome.Chrome( arc_mode=arc.arc_common.ARC_MODE_ENABLED, num_tries=3, init_network_controller=False)
def test_webrtc(self, local_path, gather_result): """ Runs the webrtc test with and without hardware acceleration. @param local_path: the path to the video file. @param gather_result: a function to run and return the test result after chrome opens. The input parameter of the funciton is Autotest chrome instance. @return a dictionary that contains test the result. """ keyvals = {} EXTRA_BROWSER_ARGS.append(FAKE_FILE_ARG % local_path) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], arc_mode=self.arc_mode, init_network_controller=True) as cr: # On daisy, Chrome freezes about 30 seconds after login because of # TPM error. See http://crbug.com/588579. if utils.get_board() == 'daisy': logging.warning('Delay 30s for issue 588579 on daisy') time.sleep(30) # Open WebRTC loopback page and start the loopback. self.start_loopback(cr) result = gather_result(cr) # Check if decode is hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.RTC_INIT_HISTOGRAM, constants.RTC_VIDEO_INIT_BUCKET): keyvals[WEBRTC_WITH_HW_ACCELERATION] = result else: logging.info("Can not use hardware decoding.") keyvals[WEBRTC_WITHOUT_HW_ACCELERATION] = result return keyvals # Start chrome with disabled video hardware decode flag. with chrome.Chrome(extra_browser_args= DISABLE_ACCELERATED_VIDEO_DECODE_BROWSER_ARGS + EXTRA_BROWSER_ARGS, arc_mode=self.arc_mode, init_network_controller=True) as cr: if utils.get_board() == 'daisy': logging.warning('Delay 30s for issue 588579 on daisy') time.sleep(30) # Open the webrtc loopback page and start the loopback. self.start_loopback(cr) result = gather_result(cr) # Make sure decode is not hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.RTC_INIT_HISTOGRAM, constants.RTC_VIDEO_INIT_BUCKET): raise error.TestError('HW decode should not be used.') keyvals[WEBRTC_WITHOUT_HW_ACCELERATION] = result return keyvals
def run_once(self, codec, fps, video_file): """ Report cpu usage and frame processing time with HW and SW encode. Use MediaRecorder to record a videos with HW encode and SW encode, and report the frame processing time and CPU usage of both. @param codec: a string indicating the codec used to encode video stream, ex. 'h264'. @param fps: an integer specifying FPS of the fake input video stream. @param video_file: a string specifying the name of the video file to be used as fake input video stream. """ # Download test video. url = DOWNLOAD_BASE + video_file local_path = os.path.join(self.bindir, video_file) file_utils.download_file(url, local_path) fake_file_arg = (FAKE_FILE_ARG % local_path) fake_stream_arg = (FAKE_STREAM_ARG % fps) processing_time_sw = 0 processing_time_hw = 0 cpu_usage_sw = 0 cpu_usage_hw = 0 with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS + [fake_file_arg, fake_stream_arg] + DISABLE_HW_ENCODE_ARGS + [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: (processing_time_sw, cpu_usage_sw) = self.get_record_performance(cr, codec, False) self.output_perf_value(description=(SW_PREFIX + FRAME_PROCESSING_TIME), value=processing_time_sw, units=TIME_UNIT, higher_is_better=False) self.output_perf_value(description=(SW_PREFIX + CPU_USAGE), value=cpu_usage_sw, units=PERCENT, higher_is_better=False) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS + [fake_file_arg, fake_stream_arg] + [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: (processing_time_hw, cpu_usage_hw) = self.get_record_performance(cr, codec, True) self.output_perf_value(description=(HW_PREFIX + FRAME_PROCESSING_TIME), value=processing_time_hw, units=TIME_UNIT, higher_is_better=False) self.output_perf_value(description=(HW_PREFIX + CPU_USAGE), value=cpu_usage_hw, units=PERCENT, higher_is_better=False) log = 'sw processing_time=%f cpu=%d hw processing_time=%f cpu=%d' % ( processing_time_sw, cpu_usage_sw, processing_time_hw, cpu_usage_hw) logging.info(log)
def test_playback(self, local_path, gather_result): """ Runs the video playback test with and without hardware acceleration. @param local_path: the path to the video file. @param gather_result: a function to run and return the test result after chrome opens. The input parameter of the funciton is Autotest chrome instance. @return a dictionary that contains test the result. """ keyvals = {} with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), arc_mode=self.arc_mode, init_network_controller=True) as cr: # crbug/753292 - enforce the idle checks after login if not utils.wait_for_idle_cpu(WAIT_FOR_IDLE_CPU_TIMEOUT, CPU_IDLE_USAGE): logging.warning('Could not get idle CPU post login.') if not utils.wait_for_cool_machine(): logging.warning('Could not get cold machine post login.') # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Check if decode is hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): keyvals[PLAYBACK_WITH_HW_ACCELERATION] = result else: logging.info("Can not use hardware decoding.") keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION] = result return keyvals # Start chrome with disabled video hardware decode flag. with chrome.Chrome(extra_browser_args= DISABLE_ACCELERATED_VIDEO_DECODE_BROWSER_ARGS, arc_mode=self.arc_mode, init_network_controller=True) as cr: # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Make sure decode is not hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): raise error.TestError( 'Video decode acceleration should not be working.') keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION] = result return keyvals
def test_playback(self, local_path, gather_result): """ Runs the video playback test with and without hardware acceleration. @param local_path: the path to the video file. @param gather_result: a function to run and return the test result after chrome opens. The input parameter of the funciton is Autotest chrome instance. @return a dictionary that contains test the result. """ keyvals = {} with chrome.Chrome(arc_mode=self.arc_mode, init_network_controller=True) as cr: # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Check if decode is hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): keyvals[PLAYBACK_WITH_HW_ACCELERATION] = result else: logging.info("Can not use hardware decoding.") keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION] = result return keyvals # Start chrome with disabled video hardware decode flag. with chrome.Chrome(extra_browser_args= DISABLE_ACCELERATED_VIDEO_DECODE_BROWSER_ARGS, arc_mode=self.arc_mode) as cr: # Open the video playback page and start playing. self.start_playback(cr, local_path) result = gather_result(cr) # Make sure decode is not hardware accelerated. if histogram_verifier.is_bucket_present( cr, constants.MEDIA_GVD_INIT_STATUS, constants.MEDIA_GVD_BUCKET): raise error.TestError( 'Video decode acceleration should not be working.') keyvals[PLAYBACK_WITHOUT_HW_ACCELERATION] = result return keyvals
def run_once(self, username, password): """Test body.""" if not username: raise error.TestFail('User not set.') if not password: raise error.TestFail('Password not set.') with chrome.Chrome(gaia_login=True, username=username, password=password) as cr: if not cryptohome.is_vault_mounted( user=chrome.NormalizeEmail(username)): raise error.TestFail('Expected to find a mounted vault for %s' % username) tab = cr.browser.tabs.New() # TODO(achuith): Use a better signal of being logged in, instead of # parsing accounts.google.com. tab.Navigate('http://accounts.google.com') tab.WaitForDocumentReadyStateToBeComplete() res = tab.EvaluateJavaScript(''' var res = '', divs = document.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) { res = divs[i].textContent; if (res.search('%s') > 1) { break; } } res; ''' % username) if not res: raise error.TestFail('No references to %s on accounts page.' % username) tab.Close()
def run_once(self, video): """Tests whether video seek works by random seeks forward and backward. @param video: Sample video file to be seeked in Chrome. """ with chrome.Chrome(init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'video.html'))) tab.WaitForDocumentReadyStateToBeComplete() tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video) def get_seek_test_status(): seek_test_status = tab.EvaluateJavaScript( 'getSeekTestStatus()') logging.info('Seeking: %s', seek_test_status) return seek_test_status utils.poll_for_condition( lambda: get_seek_test_status() == 'pass', exception=error.TestError('Seek test is stuck and timeout'), timeout=WAIT_TIMEOUT_S, sleep_interval=1)
def run_once(self, tab_open_secs=1.5, timeout_secs=180): perf_results = {} time_limit = time.time() + timeout_secs err = False # 1 for initial tab opened n_tabs = 1 # Open tabs until a tab discard notification arrives, or a time limit # is reached. with chrome.Chrome() as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) while time.time() <= time_limit and not err: tab = cr.browser.tabs.New() n_tabs += 1 # The program in js-bloat.html allocates a few large arrays and # forces them in memory by touching some of their elements. tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'js-bloat.html'))) tab.WaitForDocumentReadyStateToBeComplete() time.sleep(tab_open_secs) if n_tabs > len(cr.browser.tabs): err = True if err: logging.info("tab discard after %d tabs", n_tabs) else: msg = "FAIL: no tab discard after opening %d tabs in %ds" % \ (n_tabs, timeout_secs) logging.error(msg) raise error.TestError(msg) perf_results["NumberOfTabsAtFirstDiscard"] = n_tabs self.write_perf_keyval(perf_results)
def run_once(self, video_file): """Tests whether Chrome reloads video after reloading the tab. @param video_file: fullpath to video to play. """ with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: shutil.copy2(constants.VIDEO_HTML_FILEPATH, self.bindir) cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] html_fullpath = os.path.join(self.bindir, 'video.html') url = cr.browser.platform.http_server.UrlOf(html_fullpath) player = native_html5_player.NativeHtml5Player( tab, full_url=url, video_id='video', video_src_path=video_file, event_timeout=30) player.load_video() player.play() player.verify_video_can_play(5) player.reload_page() player.load_video() player.play() player.verify_video_can_play(5)
def run_once(self, video_name, histogram_name, histogram_bucket_val, capability): if self.is_skipping_test(): raise error.TestNAError('Skipping test run on this board.') if not device_capability.DeviceCapability().have_capability( capability): logging.warning("Missing Capability: %s" % capability) return # Download test video. url = DOWNLOAD_BASE + video_name local_path = os.path.join(self.bindir, video_name) file_utils.download_file(url, local_path) # Start chrome with test flags. EXTRA_BROWSER_ARGS.append(FAKE_FILE_ARG % local_path) EXTRA_BROWSER_ARGS.append(helper_logger.chrome_vmodule_flag()) with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS, init_network_controller=True) as cr: histogram_differ = histogram_verifier.HistogramDiffer( cr, histogram_name) # Open WebRTC loopback page. cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.start_loopback(cr) # Make sure decode is hardware accelerated. histogram_verifier.expect_sole_bucket(histogram_differ, histogram_bucket_val, histogram_bucket_val)
def run_once(self): user_id, password = utils.get_signin_credentials( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'credentials.txt')) if not (user_id and password): logging.warn('No credentials found - exiting test.') return with chrome.Chrome(auto_login=False) as cr: cr.browser.oobe.NavigateGaiaLogin( user_id, password, enterprise_enroll=True, for_user_triggered_enrollment=True) time.sleep(STABILIZATION_DURATION) self.verify_enrollment(user_id) start_time = time.time() perf_keyval = {} perf_file = open(_PERF_RESULT_FILE, 'w') writer = csv.writer(perf_file) writer.writerow(['cpu', 'memory', 'timestamp']) while (time.time() - start_time) < TOTAL_TEST_DURATION: perf_keyval['cpu_usage'] = self.test_cpu_usage() perf_keyval['memory_usage'] = self.used_mem() writer.writerow([ perf_keyval['cpu_usage'], perf_keyval['memory_usage'], time.strftime('%Y/%m/%d %H:%M:%S') ]) self.write_perf_keyval(perf_keyval) time.sleep(10) perf_file.close()
def RunCryptohomeTest(self): """Test Cryptohome.""" logging.info('RunCryptohomeTest: Starting chrome and logging in.') is_arc_available = utils.is_arc_available() arc_mode = arc_common.ARC_MODE_ENABLED if is_arc_available else None with chrome.Chrome(arc_mode=arc_mode, num_tries=1) as cr: # Check that the cryptohome is mounted. # is_vault_mounted throws an exception if it fails. logging.info('Checking mounted cryptohome.') cryptohome.is_vault_mounted(user=cr.username, allow_fail=False) # Navigate to about:blank. tab = cr.browser.tabs[0] tab.Navigate('about:blank') # Evaluate some javascript. logging.info('Evaluating JavaScript.') if tab.EvaluateJavaScript('2+2') != 4: raise TestFail('EvaluateJavaScript failed') # ARC test. if is_arc_available: arc.wait_for_adb_ready() logging.info('Android booted successfully.') arc.wait_for_android_process('org.chromium.arc.intent_helper') if not arc.is_package_installed('android'): raise TestFail( '"android" system package was not listed by ' 'Package Manager.') if is_arc_available: utils.poll_for_condition( lambda: not arc.is_android_container_alive(), timeout=15, desc='Android container still running ' 'after Chrome shutdown.')
def launch_recorder_test(self, test_name): """Launch a recorder test. @param test_name: Name of test to run. """ with chrome.Chrome(extra_browser_args=EXTRA_BROWSER_ARGS +\ [helper_logger.chrome_vmodule_flag()], init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) self.tab = cr.browser.tabs[0] self.tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'loopback_mediarecorder.html'))) self.tab.WaitForDocumentReadyStateToBeComplete() self.tab.EvaluateJavaScript(test_name + "();") if not self.is_test_completed(): logging.error('%s did not complete', test_name) raise error.TestFail('Failed %s' % (test_name)) try: result = self.tab.EvaluateJavaScript('result;') except: logging.error('Cannot retrieve results from javascript') raise error.TestFail('Failed %s' % (test_name)) if result != 'PASS': raise error.TestFail('Failed %s, got %s' % (test_name, result))
def initialize(self, extension_path=None, username=None, password=None, arc_mode=arc_common.ARC_MODE_ENABLED, **chrome_kargs): """Log in to a test account.""" extension_paths = [extension_path] if extension_path else [] self._chrome = chrome.Chrome(extension_paths=extension_paths, username=username, password=password, arc_mode=arc_mode, **chrome_kargs) if extension_path: self._extension = self._chrome.get_extension(extension_path) else: self._extension = None # With ARC enabled, Chrome will wait until container to boot up # before returning here, see chrome.py. self.initialized = True try: if is_android_container_alive(): self.arc_setup() else: logging.error('Container is alive?') except Exception as err: raise error.TestFail(err)
def run_once(self, test_duration_secs=30, fullscreen=True): """Finds a brower with telemetry, and run the test. @param test_duration_secs: The test duration in seconds to run the test for. @param fullscreen: Whether to run the test in fullscreen. """ self.test_duration_secs = test_duration_secs ext_paths = [] if fullscreen: ext_paths.append( os.path.join(self.autodir, 'deps', 'graphics', 'graphics_test_extension')) with chrome.Chrome(logged_in=False, extension_paths=ext_paths, init_network_controller=True) as cr: websrc_dir = os.path.join(self.autodir, 'deps', 'webgl_mpd', 'src') if not cr.browser.platform.SetHTTPServerDirectories(websrc_dir): raise error.TestFail('Failed: Unable to start HTTP server') test_url = cr.browser.platform.http_server.UrlOf( os.path.join(websrc_dir, 'ManyPlanetsDeep.html')) self.run_many_planets_deep_test(cr.browser, test_url) self.calculate_perf_values() self.write_perf_keyval(self.perf_keyval)
def display(filepath): """Display chart with filepath on device by using telemetry.""" assert os.path.isfile(filepath), 'filepath %r not found.' % filepath filepath = os.path.abspath(filepath) logging.info('Setup SIGINT listener for stop displaying.') displaying = [True] def handler(signum, frame): """Wait signal to clear running flag.""" if signum == signal.SIGINT: displaying.pop() signal.signal(signal.SIGINT, handler) with chrome.Chrome(init_network_controller=True ) as cr, set_display_brightness(DISPLAY_LEVEL): logging.info('Display chart file of path %r.', filepath) cr.browser.platform.SetHTTPServerDirectories(os.path.dirname(filepath)) tab = cr.browser.tabs[0] tab.Navigate(cr.browser.platform.http_server.UrlOf(filepath)) logging.info('Set chart tab fullscreen.') kb = keyboard.Keyboard() kb.press_key('f4') kb.close() logging.info('Chart is ready.') while displaying: time.sleep(1)
def run_once(self): """Entry point of this test.""" if not self._is_testable(): return # Log in and start test. with chrome.Chrome(autotest_ext=True) as cr: # Setup. self._set_autotest_ext(cr.autotest_ext) self._open_test_page(cr) self._emulate_mouse() self._center_cursor() # Check default setting values. logging.info('Checking for default setting values.') self._check_for_click(True) self._check_for_drag(False) # Toggle settings in all combinations and check. options = [True, False] option_pairs = itertools.product(options, options) for (click_value, drag_value) in option_pairs: self._center_cursor() self._set_tap_to_click(click_value) self._set_tap_dragging(drag_value) self._check_for_click(click_value) self._check_for_drag(click_value and drag_value)
def run_once(self, test_duration_secs=2700, fullscreen=True): """Finds a brower with telemetry, and run the test. @param test_duration_secs: The test duration in seconds. @param fullscreen: Whether to run the test in fullscreen. """ # To avoid 0ms on fast machines like samus the workload was increased. # Unfortunately that makes running on slow machines impractical without # deviating from upstream too much. if utils.get_gpu_family() == 'pinetrail': # TODO(ihf): return a TestPass(message) once available. logging.warning('Test is too slow to run regularly.') return self._test_duration_secs = test_duration_secs ext_paths = [] if fullscreen: ext_paths.append( os.path.join(self.autodir, 'deps', 'graphics', 'graphics_test_extension')) with chrome.Chrome(logged_in=False, extension_paths=ext_paths, init_network_controller=True) as cr: websrc_dir = os.path.join(self.autodir, 'deps', 'webgl_perf', 'src') if not cr.browser.platform.SetHTTPServerDirectories(websrc_dir): raise error.TestFail('Failed: Unable to start HTTP server') test_url = cr.browser.platform.http_server.UrlOf( os.path.join(websrc_dir, 'index.html')) self.run_performance_test(cr.browser, test_url)
def run_once(self): """Entry point of this test.""" extension_path = self._get_extension_path() with chrome.Chrome(extension_paths=[extension_path], init_network_controller=True) as cr: self._extension = cr.get_extension(extension_path) # Open test page. self._tab = cr.browser.tabs[0] cr.browser.platform.SetHTTPServerDirectories( os.path.join(os.path.dirname(__file__))) page_path = os.path.join(self.bindir, 'page.html') self._url = cr.browser.platform.http_server.UrlOf(page_path) self._tab.Navigate(self._url) # Check specific features. self._check_chromevox() # Enable then disable all other accessibility features. for value in [True, False]: for feature in self._FEATURE_LIST: logging.info('Setting %s to %s.', feature, value) self._set_feature(feature, value) time.sleep(1)
def run_once(self, arc_mode=None): # If we are in arc_mode, do not report failures to perf dashboard. if arc_mode: self._test_failure_report_enable = False # We use kiosk mode to make sure Chrome is idle. self.add_failures('Graphics_Idle') with chrome.Chrome(logged_in=False, extra_browser_args=['--kiosk'], arc_mode=arc_mode): # Try to protect against runaway previous tests. if not utils.wait_for_idle_cpu(20.0, 0.1): logging.warning('Could not get idle CPU before running tests.') self._gpu_type = utils.get_gpu_family() self._cpu_type = utils.get_cpu_soc_family() self._board = utils.get_board() errors = '' errors += self.verify_graphics_dvfs() errors += self.verify_graphics_fbc() errors += self.verify_graphics_psr() errors += self.verify_graphics_gem_idle() errors += self.verify_graphics_i915_min_clock() errors += self.verify_graphics_rc6() errors += self.verify_lvds_downclock() errors += self.verify_short_blanking() if errors: raise error.TestFail('Failed: %s' % errors) self.remove_failures('Graphics_Idle')
def run_once(self): """Entry point of this test.""" extension_path = os.path.join(os.path.dirname(__file__), 'a11y_ext') with chrome.Chrome(extension_paths=[extension_path], is_component=False) as cr: # Setup ChromeVox extension self._extension = cr.get_extension(extension_path) # Begin actual test logging.info('Detecting initial ChromeVox welcome sound.') self._enable_ChromeVox() audio_length = self._detect_audio() if audio_length < 1: raise error.TestError('No sound after enabling Chromevox!') logging.info('Detecting initial ChromeVox welcome speech.') audio_length = self._detect_audio() if audio_length < 2: raise error.TestError('Speech after enabling ChromeVox was <= ' '%f seconds long!' % audio_length) logging.info('Detecting page navigation sound.') cr.browser.tabs[0].Navigate('chrome://version') audio_length = self._detect_audio() if audio_length < 2: raise error.TestError('Speech after loading a page was <= ' '%f seconds long!' % audio_length) logging.info('Detecting new tab sound.') tab = cr.browser.tabs.New() audio_length = self._detect_audio() if audio_length < 1: raise error.TestError('No sound after opening new tab!')
def run_once(self, test_url=JELLYFISH_URL, duration=2.5 * HOUR): """run_once method. @param test_url: url of webgl heavy page. @param duration: time in seconds to display url and measure power. """ with chrome.Chrome(init_network_controller=True) as self.cr: tab = self.cr.browser.tabs.New() tab.Activate() # Just measure power in full-screen. fullscreen = tab.EvaluateJavaScript('document.webkitIsFullScreen') if not fullscreen: with keyboard.Keyboard() as keys: keys.press_key('f4') self.backlight.set_percent(100) logging.info('Navigating to url: %s', test_url) tab.Navigate(test_url) tab.WaitForDocumentReadyStateToBeComplete() if test_url == self.JELLYFISH_URL: # Change param to 100 fast moving jellyfish. tab.EvaluateJavaScript('$("#jCount").val(100);') tab.EvaluateJavaScript('$("#jSpeed").val(0.1);') # Jellyfish is added one by one. Wait until we have 100. while tab.EvaluateJavaScript('jellyfish.count') < 100: time.sleep(0.1) self.start_measurements() time.sleep(duration)
def run_once(self, scenario_group='all', autoconnect=False, **kwargs): with chrome.Chrome(): # Replace the test type with the list of tests if (scenario_group not in cellular_SuspendResume.scenarios.keys()): scenario_group = 'all' logging.info('Running scenario group: %s' % scenario_group) scenarios = cellular_SuspendResume.scenarios[scenario_group] self.init_flimflam() device = self.__get_mobile_device() if not device: raise error.TestFail('Cannot find mobile device.') self.enable_device(device, True) service = self.flim.FindCellularService(self.TIMEOUT) if not service: raise error.TestFail('Cannot find mobile service.') service.SetProperty('AutoConnect', dbus.Boolean(autoconnect)) logging.info('Running scenarios with autoconnect %s.' % autoconnect) for t in scenarios: self.run_scenario(t, **kwargs)
def run_once(self, codec, is_switchres, video): """Tests whether video seek works by random seeks forward and backward. @param codec: the codec to be tested, ex. 'vp8', 'vp9', 'h264'. @param is_switchres: bool, True if using switch resolution video. @param video: Sample video file to be seeked in Chrome. """ if self.is_skipping_test(codec, is_switchres): logging.info('Skipping test run on this board.') return # return immediately to pass this test with chrome.Chrome( extra_browser_args=helper_logger.chrome_vmodule_flag(), init_network_controller=True) as cr: cr.browser.platform.SetHTTPServerDirectories(self.bindir) tab = cr.browser.tabs[0] tab.Navigate( cr.browser.platform.http_server.UrlOf( os.path.join(self.bindir, 'video.html'))) tab.WaitForDocumentReadyStateToBeComplete() tab.EvaluateJavaScript('loadSourceAndRunSeekTest("%s")' % video) def get_seek_test_status(): seek_test_status = tab.EvaluateJavaScript( 'getSeekTestStatus()') logging.info('Seeking: %s', seek_test_status) return seek_test_status utils.poll_for_condition( lambda: get_seek_test_status() == 'pass', exception=error.TestError('Seek test is stuck and timeout'), timeout=WAIT_TIMEOUT_S, sleep_interval=1)
def run_once(self, stress_run=False, arc_mode=None): """ Runs the test. @param stress_run: True if we are doing a stress run and want to double the timeout. @param arc_mode: This value is passed to Chrome and determines how the ARC/Android instance should start. Possible values are defined in common_lib/cros/arc_common.py. """ if stress_run: self._SESSION_STOP_TIMEOUT *= 2 self._listener.listen_for_session_state_change('started') with chrome.Chrome(arc_mode=arc_mode): self._listener.wait_for_signals(desc='Session started.', timeout=self._SESSION_START_TIMEOUT) # To enable use as a 'helper test'. self.job.set_state('client_success', True) # Start listening to stop signal before logging out. self._listener.listen_for_session_state_change('stopped') self._listener.wait_for_signals(desc='Session stopped.', timeout=self._SESSION_STOP_TIMEOUT)