Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/test/media_router/telemetry/benchmarks/pagesets/media_router_perf_pages.py

Issue 2672803002: [Telemetry refactor] Migrate clients to new JavaScript API (batch 3) (Closed)
Patch Set: add comment on tools/android Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 4
5 import utils 5 import utils
6 6
7 from telemetry import page 7 from telemetry import page
8 from telemetry import story 8 from telemetry import story
9 from benchmarks.pagesets import media_router_page 9 from benchmarks.pagesets import media_router_page
10 from telemetry.core import exceptions 10 from telemetry.core import exceptions
11 from telemetry.page import shared_page_state 11 from telemetry.page import shared_page_state
12 from telemetry.util import js_template
13
12 14
13 SESSION_TIME = 300 # 5 minutes 15 SESSION_TIME = 300 # 5 minutes
14 16
17
15 class SharedState(shared_page_state.SharedPageState): 18 class SharedState(shared_page_state.SharedPageState):
16 """Shared state that restarts the browser for every single story.""" 19 """Shared state that restarts the browser for every single story."""
17 20
18 def __init__(self, test, finder_options, story_set): 21 def __init__(self, test, finder_options, story_set):
19 super(SharedState, self).__init__( 22 super(SharedState, self).__init__(
20 test, finder_options, story_set) 23 test, finder_options, story_set)
21 24
22 def DidRunStory(self, results): 25 def DidRunStory(self, results):
23 super(SharedState, self).DidRunStory(results) 26 super(SharedState, self).DidRunStory(results)
24 self._StopBrowser() 27 self._StopBrowser()
(...skipping 27 matching lines...) Expand all
52 def __init__(self, page_set): 55 def __init__(self, page_set):
53 super(CastIdlePage, self).__init__( 56 super(CastIdlePage, self).__init__(
54 page_set=page_set, 57 page_set=page_set,
55 url='file://basic_test.html', 58 url='file://basic_test.html',
56 shared_page_state_class=SharedState) 59 shared_page_state_class=SharedState)
57 60
58 def RunPageInteractions(self, action_runner): 61 def RunPageInteractions(self, action_runner):
59 # Wait for 5s after Chrome is opened in order to get consistent results. 62 # Wait for 5s after Chrome is opened in order to get consistent results.
60 action_runner.Wait(5) 63 action_runner.Wait(5)
61 with action_runner.CreateInteraction('Idle'): 64 with action_runner.CreateInteraction('Idle'):
62 action_runner.ExecuteJavaScript('collectPerfData();') 65 action_runner.ExecuteJavaScript2('collectPerfData();')
63 action_runner.Wait(SESSION_TIME) 66 action_runner.Wait(SESSION_TIME)
64 67
65 68
66 class CastFlingingPage(media_router_page.CastPage): 69 class CastFlingingPage(media_router_page.CastPage):
67 """Cast page to fling a video to Chromecast device.""" 70 """Cast page to fling a video to Chromecast device."""
68 71
69 def __init__(self, page_set): 72 def __init__(self, page_set):
70 super(CastFlingingPage, self).__init__( 73 super(CastFlingingPage, self).__init__(
71 page_set=page_set, 74 page_set=page_set,
72 url='file://basic_test.html#flinging', 75 url='file://basic_test.html#flinging',
73 shared_page_state_class=SharedState) 76 shared_page_state_class=SharedState)
74 77
75 def RunPageInteractions(self, action_runner): 78 def RunPageInteractions(self, action_runner):
76 sink_name = self._GetDeviceName() 79 sink_name = self._GetDeviceName()
77 # Wait for 5s after Chrome is opened in order to get consistent results. 80 # Wait for 5s after Chrome is opened in order to get consistent results.
78 action_runner.Wait(5) 81 action_runner.Wait(5)
79 with action_runner.CreateInteraction('flinging'): 82 with action_runner.CreateInteraction('flinging'):
80 83
81 self._WaitForResult( 84 self._WaitForResult(
82 action_runner, 85 action_runner,
83 lambda: action_runner.EvaluateJavaScript('initialized'), 86 lambda: action_runner.EvaluateJavaScript2('initialized'),
84 'Failed to initialize', 87 'Failed to initialize',
85 timeout=30) 88 timeout=30)
86 self.CloseExistingRoute(action_runner, sink_name) 89 self.CloseExistingRoute(action_runner, sink_name)
87 90
88 # Start session 91 # Start session
89 action_runner.TapElement(selector='#start_session_button') 92 action_runner.TapElement(selector='#start_session_button')
90 self._WaitForResult( 93 self._WaitForResult(
91 action_runner, 94 action_runner,
92 lambda: len(action_runner.tab.browser.tabs) >= 2, 95 lambda: len(action_runner.tab.browser.tabs) >= 2,
93 'MR dialog never showed up.') 96 'MR dialog never showed up.')
94 97
95 for tab in action_runner.tab.browser.tabs: 98 for tab in action_runner.tab.browser.tabs:
96 # Choose sink 99 # Choose sink
97 if tab.url == 'chrome://media-router/': 100 if tab.url == 'chrome://media-router/':
98 self.WaitUntilDialogLoaded(action_runner, tab) 101 self.WaitUntilDialogLoaded(action_runner, tab)
99 self.ChooseSink(tab, sink_name) 102 self.ChooseSink(tab, sink_name)
100 103
101 self._WaitForResult( 104 self._WaitForResult(
102 action_runner, 105 action_runner,
103 lambda: action_runner.EvaluateJavaScript('currentSession'), 106 lambda: action_runner.EvaluateJavaScript2('currentSession'),
104 'Failed to start session', 107 'Failed to start session',
105 timeout=10) 108 timeout=10)
106 109
107 # Load Media 110 # Load Media
108 self.ExecuteAsyncJavaScript( 111 self.ExecuteAsyncJavaScript2(
109 action_runner, 112 action_runner,
110 'loadMedia("%s");' % utils.GetInternalVideoURL(), 113 js_template.Render(
111 lambda: action_runner.EvaluateJavaScript('currentMedia'), 114 'loadMedia({{ url }});', url=utils.GetInternalVideoURL()),
115 lambda: action_runner.EvaluateJavaScript2('currentMedia'),
112 'Failed to load media', 116 'Failed to load media',
113 timeout=120) 117 timeout=120)
114 118
115 action_runner.Wait(5) 119 action_runner.Wait(5)
116 action_runner.ExecuteJavaScript('collectPerfData();') 120 action_runner.ExecuteJavaScript2('collectPerfData();')
117 action_runner.Wait(SESSION_TIME) 121 action_runner.Wait(SESSION_TIME)
118 # Stop session 122 # Stop session
119 self.ExecuteAsyncJavaScript( 123 self.ExecuteAsyncJavaScript2(
120 action_runner, 124 action_runner,
121 'stopSession();', 125 'stopSession();',
122 lambda: not action_runner.EvaluateJavaScript('currentSession'), 126 lambda: not action_runner.EvaluateJavaScript2('currentSession'),
123 'Failed to stop session', 127 'Failed to stop session',
124 timeout=30) 128 timeout=30)
125 129
126 130
127 class CastMirroringPage(media_router_page.CastPage): 131 class CastMirroringPage(media_router_page.CastPage):
128 """Cast page to mirror a tab to Chromecast device.""" 132 """Cast page to mirror a tab to Chromecast device."""
129 133
130 def __init__(self, page_set): 134 def __init__(self, page_set):
131 super(CastMirroringPage, self).__init__( 135 super(CastMirroringPage, self).__init__(
132 page_set=page_set, 136 page_set=page_set,
(...skipping 26 matching lines...) Expand all
159 self._WaitForResult( 163 self._WaitForResult(
160 action_runner, 164 action_runner,
161 lambda: len(action_runner.tab.browser.tabs) >= 2, 165 lambda: len(action_runner.tab.browser.tabs) >= 2,
162 'MR dialog never showed up.') 166 'MR dialog never showed up.')
163 167
164 for tab in action_runner.tab.browser.tabs: 168 for tab in action_runner.tab.browser.tabs:
165 if tab.url == 'chrome://media-router/': 169 if tab.url == 'chrome://media-router/':
166 self.WaitUntilDialogLoaded(action_runner, tab) 170 self.WaitUntilDialogLoaded(action_runner, tab)
167 if not self.CheckIfExistingRoute(tab, sink_name): 171 if not self.CheckIfExistingRoute(tab, sink_name):
168 raise page.page_test.Failure('Failed to start mirroring session.') 172 raise page.page_test.Failure('Failed to start mirroring session.')
169 action_runner.ExecuteJavaScript('collectPerfData();') 173 action_runner.ExecuteJavaScript2('collectPerfData();')
170 action_runner.Wait(SESSION_TIME) 174 action_runner.Wait(SESSION_TIME)
171 self.CloseExistingRoute(action_runner, sink_name) 175 self.CloseExistingRoute(action_runner, sink_name)
172 176
173 177
174 class MediaRouterDialogPageSet(story.StorySet): 178 class MediaRouterDialogPageSet(story.StorySet):
175 """Pageset for media router dialog latency tests.""" 179 """Pageset for media router dialog latency tests."""
176 180
177 def __init__(self): 181 def __init__(self):
178 super(MediaRouterDialogPageSet, self).__init__( 182 super(MediaRouterDialogPageSet, self).__init__(
179 cloud_storage_bucket=story.PARTNER_BUCKET) 183 cloud_storage_bucket=story.PARTNER_BUCKET)
(...skipping 11 matching lines...) Expand all
191 self.AddStory(CastMirroringPage(self)) 195 self.AddStory(CastMirroringPage(self))
192 196
193 197
194 class CPUMemoryPageSet(story.StorySet): 198 class CPUMemoryPageSet(story.StorySet):
195 """Pageset to get baseline CPU and memory usage.""" 199 """Pageset to get baseline CPU and memory usage."""
196 200
197 def __init__(self): 201 def __init__(self):
198 super(CPUMemoryPageSet, self).__init__( 202 super(CPUMemoryPageSet, self).__init__(
199 cloud_storage_bucket=story.PARTNER_BUCKET) 203 cloud_storage_bucket=story.PARTNER_BUCKET)
200 self.AddStory(CastIdlePage(self)) 204 self.AddStory(CastIdlePage(self))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698