Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 from page_sets import android_screen_restoration_shared_state | |
| 5 | |
| 6 from telemetry.page import page as page_module | |
| 7 from telemetry.page import page_set as page_set_module | |
| 8 | |
| 9 | |
| 10 class KeyIdlePowerPage(page_module.Page): | |
| 11 | |
| 12 def __init__(self, url, page_set, turn_screen_off): | |
| 13 super(KeyIdlePowerPage, self).__init__( | |
| 14 url=url, | |
| 15 page_set=page_set, | |
| 16 shared_page_state_class=(android_screen_restoration_shared_state | |
| 17 .AndroidScreenRestorationSharedState)) | |
| 18 self.user_agent_type = 'mobile' | |
| 19 self._turn_screen_off = turn_screen_off | |
| 20 | |
| 21 def RunNavigateSteps(self, action_runner): | |
| 22 super(KeyIdlePowerPage, self).RunNavigateSteps(action_runner) | |
| 23 action_runner.Wait(2) | |
| 24 if self._turn_screen_off: | |
| 25 # TODO(jdduke): Remove this API violation after the shared page state is | |
| 26 # exposed here, crbug.com/470147. | |
|
nednguyen
2015/05/15 16:42:57
Add: # pylint: disable=protected-access
| |
| 27 action_runner._tab.browser.platform.android_action_runner.TurnScreenOff() | |
| 28 # We're not interested in tracking activity that occurs immediately after | |
| 29 # the screen is turned off. Several seconds should be enough time for the | |
| 30 # browser to "settle down" into an idle state. | |
| 31 action_runner.Wait(2) | |
| 32 | |
| 33 def RunPageInteractions(self, action_runner): | |
| 34 # The page interaction is simply waiting in an idle state. | |
| 35 action_runner.Wait(20) | |
| 36 | |
| 37 | |
| 38 class KeyIdlePowerCasesPageSet(page_set_module.PageSet): | |
| 39 | |
| 40 """ Key idle power cases """ | |
| 41 | |
| 42 def __init__(self): | |
| 43 super(KeyIdlePowerCasesPageSet, self).__init__(user_agent_type='mobile') | |
| 44 | |
| 45 foreground_urls_list = [ | |
| 46 # Why: Ensure minimal activity for static, empty pages in the foreground. | |
| 47 'file://key_idle_power_cases/blank.html', | |
| 48 ] | |
| 49 | |
| 50 for url in foreground_urls_list: | |
| 51 self.AddUserStory(KeyIdlePowerPage(url, self, False)) | |
| 52 | |
| 53 background_urls_list = [ | |
| 54 # Why: Ensure animated GIFs aren't processed when Chrome is backgrounded. | |
| 55 'file://key_idle_power_cases/animated-gif.html', | |
| 56 # Why: Ensure CSS animations aren't processed when Chrome is backgrounded. | |
| 57 'file://key_idle_power_cases/css-animation.html', | |
| 58 # Why: Ensure rAF is suppressed when Chrome is backgrounded. | |
| 59 'file://key_idle_power_cases/request-animation-frame.html', | |
| 60 # Why: Ensure setTimeout is throttled when Chrome is backgrounded. | |
| 61 'file://key_idle_power_cases/set-timeout.html', | |
| 62 ] | |
| 63 | |
| 64 for url in background_urls_list: | |
| 65 self.AddUserStory(KeyIdlePowerPage(url, self, True)) | |
| OLD | NEW |