OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 from page_sets import android_screen_restoration_shared_state | 4 from page_sets import android_screen_restoration_shared_state |
5 | 5 |
6 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
7 from telemetry.page import shared_page_state | 7 from telemetry.page import shared_page_state |
8 from telemetry import story | 8 from telemetry import story |
9 | 9 |
10 | 10 |
11 class KeyIdlePowerPage(page_module.Page): | 11 class KeyIdlePowerPage(page_module.Page): |
12 | 12 |
13 def __init__(self, url, page_set, turn_screen_off, duration_seconds=20, | 13 def __init__(self, url, page_set, turn_screen_off, duration_seconds=20, |
14 shared_page_state_class=shared_page_state.SharedMobilePageState): | 14 shared_page_state_class=shared_page_state.SharedMobilePageState): |
15 super(KeyIdlePowerPage, self).__init__( | 15 super(KeyIdlePowerPage, self).__init__( |
16 url=url, | 16 url=url, |
17 page_set=page_set, | 17 page_set=page_set, |
18 shared_page_state_class=(android_screen_restoration_shared_state | 18 shared_page_state_class=(android_screen_restoration_shared_state |
19 .AndroidScreenRestorationSharedState)) | 19 .AndroidScreenRestorationSharedState), |
| 20 name=url.split('/')[-1]) |
20 self._turn_screen_off = turn_screen_off | 21 self._turn_screen_off = turn_screen_off |
21 self._duration_seconds = duration_seconds | 22 self._duration_seconds = duration_seconds |
22 | 23 |
23 def RunNavigateSteps(self, action_runner): | 24 def RunNavigateSteps(self, action_runner): |
24 super(KeyIdlePowerPage, self).RunNavigateSteps(action_runner) | 25 super(KeyIdlePowerPage, self).RunNavigateSteps(action_runner) |
25 action_runner.Wait(2) | 26 action_runner.Wait(2) |
26 if self._turn_screen_off: | 27 if self._turn_screen_off: |
27 action_runner.tab.browser.platform.android_action_runner.TurnScreenOff() | 28 action_runner.tab.browser.platform.android_action_runner.TurnScreenOff() |
28 # We're not interested in tracking activity that occurs immediately after | 29 # 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 # the screen is turned off. Several seconds should be enough time for the |
(...skipping 20 matching lines...) Expand all Loading... |
50 shared_page_state_class=(android_screen_restoration_shared_state | 51 shared_page_state_class=(android_screen_restoration_shared_state |
51 .AndroidScreenRestorationSharedState)) | 52 .AndroidScreenRestorationSharedState)) |
52 self._name = self.display_name + " (Long Idle)" | 53 self._name = self.display_name + " (Long Idle)" |
53 | 54 |
54 | 55 |
55 class KeyIdlePowerCasesPageSet(story.StorySet): | 56 class KeyIdlePowerCasesPageSet(story.StorySet): |
56 | 57 |
57 """ Key idle power cases """ | 58 """ Key idle power cases """ |
58 | 59 |
59 def __init__(self): | 60 def __init__(self): |
60 super(KeyIdlePowerCasesPageSet, self).__init__() | 61 super(KeyIdlePowerCasesPageSet, self).__init__(verify_names=True) |
61 | 62 |
62 foreground_urls_list = [ | 63 foreground_urls_list = [ |
63 # Why: Ensure minimal activity for static, empty pages in the foreground. | 64 # Why: Ensure minimal activity for static, empty pages in the foreground. |
64 'file://key_idle_power_cases/blank.html', | 65 'file://key_idle_power_cases/blank.html', |
65 ] | 66 ] |
66 | 67 |
67 for url in foreground_urls_list: | 68 for url in foreground_urls_list: |
68 self.AddStory(KeyIdlePowerPage(url, self, False)) | 69 self.AddStory(KeyIdlePowerPage(url, self, False)) |
69 | 70 |
70 background_urls_list = [ | 71 background_urls_list = [ |
71 # Why: Ensure animated GIFs aren't processed when Chrome is backgrounded. | 72 # Why: Ensure animated GIFs aren't processed when Chrome is backgrounded. |
72 'file://key_idle_power_cases/animated-gif.html', | 73 'file://key_idle_power_cases/animated-gif.html', |
73 # Why: Ensure CSS animations aren't processed when Chrome is backgrounded. | 74 # Why: Ensure CSS animations aren't processed when Chrome is backgrounded. |
74 'file://key_idle_power_cases/css-animation.html', | 75 'file://key_idle_power_cases/css-animation.html', |
75 # Why: Ensure rAF is suppressed when Chrome is backgrounded. | 76 # Why: Ensure rAF is suppressed when Chrome is backgrounded. |
76 'file://key_idle_power_cases/request-animation-frame.html', | 77 'file://key_idle_power_cases/request-animation-frame.html', |
77 # Why: Ensure setTimeout is throttled when Chrome is backgrounded. | 78 # Why: Ensure setTimeout is throttled when Chrome is backgrounded. |
78 'file://key_idle_power_cases/set-timeout.html', | 79 'file://key_idle_power_cases/set-timeout.html', |
79 ] | 80 ] |
80 | 81 |
81 for url in background_urls_list: | 82 for url in background_urls_list: |
82 self.AddStory(KeyIdlePowerPage(url, self, True)) | 83 self.AddStory(KeyIdlePowerPage(url, self, True)) |
83 | 84 |
84 # Why: Ensure that activity strictly diminishes the longer the idle time. | 85 # Why: Ensure that activity strictly diminishes the longer the idle time. |
85 self.AddStory(KeyLongIdlePowerPage( | 86 self.AddStory(KeyLongIdlePowerPage( |
86 'file://key_idle_power_cases/set-timeout.html', self, True)) | 87 'file://key_idle_power_cases/set-timeout.html', self, True)) |
OLD | NEW |