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

Side by Side Diff: tools/perf/page_sets/top_7_stress.py

Issue 2719853003: [Telemetry refactor] Drop "2" from method calls to JS API (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « tools/perf/page_sets/top_25_smooth.py ('k') | tools/perf/page_sets/top_pages.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 telemetry.page import page as page_module 4 from telemetry.page import page as page_module
5 from telemetry.page import shared_page_state 5 from telemetry.page import shared_page_state
6 from telemetry import story 6 from telemetry import story
7 7
8 8
9 def _GetCurrentLocation(action_runner): 9 def _GetCurrentLocation(action_runner):
10 return action_runner.EvaluateJavaScript2('document.location.href') 10 return action_runner.EvaluateJavaScript('document.location.href')
11 11
12 12
13 def _WaitForLocationChange(action_runner, old_href): 13 def _WaitForLocationChange(action_runner, old_href):
14 action_runner.WaitForJavaScriptCondition2( 14 action_runner.WaitForJavaScriptCondition(
15 'document.location.href != {{ old_href }}', old_href=old_href) 15 'document.location.href != {{ old_href }}', old_href=old_href)
16 16
17 17
18 class Top7StressPage(page_module.Page): 18 class Top7StressPage(page_module.Page):
19 19
20 def __init__(self, url, page_set, name=''): 20 def __init__(self, url, page_set, name=''):
21 super(Top7StressPage, self).__init__( 21 super(Top7StressPage, self).__init__(
22 url=url, page_set=page_set, name=name, 22 url=url, page_set=page_set, name=name,
23 shared_page_state_class=shared_page_state.SharedDesktopPageState, 23 shared_page_state_class=shared_page_state.SharedDesktopPageState,
24 credentials_path = 'data/credentials.json') 24 credentials_path = 'data/credentials.json')
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 def __init__(self, page_set): 93 def __init__(self, page_set):
94 super(GmailPage, self).__init__( 94 super(GmailPage, self).__init__(
95 url='https://mail.google.com/mail/', 95 url='https://mail.google.com/mail/',
96 page_set=page_set) 96 page_set=page_set)
97 97
98 self.credentials = 'google' 98 self.credentials = 'google'
99 99
100 def RunNavigateSteps(self, action_runner): 100 def RunNavigateSteps(self, action_runner):
101 super(GmailPage, self).RunNavigateSteps(action_runner) 101 super(GmailPage, self).RunNavigateSteps(action_runner)
102 action_runner.WaitForJavaScriptCondition2( 102 action_runner.WaitForJavaScriptCondition(
103 'window.gmonkey !== undefined &&' 103 'window.gmonkey !== undefined &&'
104 'document.getElementById("gb") !== null') 104 'document.getElementById("gb") !== null')
105 105
106 def RunPageInteractions(self, action_runner): 106 def RunPageInteractions(self, action_runner):
107 old_href = _GetCurrentLocation(action_runner) 107 old_href = _GetCurrentLocation(action_runner)
108 action_runner.ClickElement( 108 action_runner.ClickElement(
109 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]') 109 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]')
110 _WaitForLocationChange(action_runner, old_href) 110 _WaitForLocationChange(action_runner, old_href)
111 old_href = _GetCurrentLocation(action_runner) 111 old_href = _GetCurrentLocation(action_runner)
112 action_runner.ClickElement( 112 action_runner.ClickElement(
113 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]') 113 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]')
114 _WaitForLocationChange(action_runner, old_href) 114 _WaitForLocationChange(action_runner, old_href)
115 115
116 116
117 class GoogleCalendarPage(Top7StressPage): 117 class GoogleCalendarPage(Top7StressPage):
118 118
119 """ Why: productivity, top google properties """ 119 """ Why: productivity, top google properties """
120 120
121 def __init__(self, page_set): 121 def __init__(self, page_set):
122 super(GoogleCalendarPage, self).__init__( 122 super(GoogleCalendarPage, self).__init__(
123 url='https://www.google.com/calendar/', 123 url='https://www.google.com/calendar/',
124 page_set=page_set) 124 page_set=page_set)
125 125
126 self.credentials = 'google' 126 self.credentials = 'google'
127 127
128 def RunNavigateSteps(self, action_runner): 128 def RunNavigateSteps(self, action_runner):
129 super(GoogleCalendarPage, self).RunNavigateSteps(action_runner) 129 super(GoogleCalendarPage, self).RunNavigateSteps(action_runner)
130 action_runner.Wait(2) 130 action_runner.Wait(2)
131 action_runner.WaitForElement('div[class~="navForward"]') 131 action_runner.WaitForElement('div[class~="navForward"]')
132 action_runner.ExecuteJavaScript2(''' 132 action_runner.ExecuteJavaScript('''
133 (function() { 133 (function() {
134 var elem = document.createElement('meta'); 134 var elem = document.createElement('meta');
135 elem.name='viewport'; 135 elem.name='viewport';
136 elem.content='initial-scale=1'; 136 elem.content='initial-scale=1';
137 document.body.appendChild(elem); 137 document.body.appendChild(elem);
138 })();''') 138 })();''')
139 action_runner.Wait(1) 139 action_runner.Wait(1)
140 140
141 def RunPageInteractions(self, action_runner): 141 def RunPageInteractions(self, action_runner):
142 action_runner.ClickElement('div[class~="navForward"]') 142 action_runner.ClickElement('div[class~="navForward"]')
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 self.credentials = 'facebook2' 288 self.credentials = 'facebook2'
289 289
290 def RunNavigateSteps(self, action_runner): 290 def RunNavigateSteps(self, action_runner):
291 super(FacebookPage, self).RunNavigateSteps(action_runner) 291 super(FacebookPage, self).RunNavigateSteps(action_runner)
292 action_runner.WaitForElement(text='About') 292 action_runner.WaitForElement(text='About')
293 293
294 def RunPageInteractions(self, action_runner): 294 def RunPageInteractions(self, action_runner):
295 # Scroll and wait for the next page to be loaded. 295 # Scroll and wait for the next page to be loaded.
296 with action_runner.CreateGestureInteraction('ScrollAction'): 296 with action_runner.CreateGestureInteraction('ScrollAction'):
297 action_runner.ScrollPage() 297 action_runner.ScrollPage()
298 action_runner.WaitForJavaScriptCondition2( 298 action_runner.WaitForJavaScriptCondition(
299 'document.documentElement.scrollHeight - window.innerHeight - ' 299 'document.documentElement.scrollHeight - window.innerHeight - '
300 'window.pageYOffset > 0') 300 'window.pageYOffset > 0')
301 301
302 # Scroll and wait again. 302 # Scroll and wait again.
303 with action_runner.CreateGestureInteraction('ScrollAction'): 303 with action_runner.CreateGestureInteraction('ScrollAction'):
304 action_runner.ScrollPage() 304 action_runner.ScrollPage()
305 action_runner.WaitForJavaScriptCondition2( 305 action_runner.WaitForJavaScriptCondition(
306 'document.documentElement.scrollHeight - window.innerHeight - ' 306 'document.documentElement.scrollHeight - window.innerHeight - '
307 'window.pageYOffset > 0') 307 'window.pageYOffset > 0')
308 308
309 class Top7StressPageSet(story.StorySet): 309 class Top7StressPageSet(story.StorySet):
310 310
311 """ Pages hand-picked for stress testing. """ 311 """ Pages hand-picked for stress testing. """
312 312
313 def __init__(self): 313 def __init__(self):
314 super(Top7StressPageSet, self).__init__( 314 super(Top7StressPageSet, self).__init__(
315 archive_data_file='data/top_7_stress.json', 315 archive_data_file='data/top_7_stress.json',
316 cloud_storage_bucket=story.PARTNER_BUCKET) 316 cloud_storage_bucket=story.PARTNER_BUCKET)
317 317
318 self.AddStory(GoogleWebSearchPage(self)) 318 self.AddStory(GoogleWebSearchPage(self))
319 self.AddStory(GmailPage(self)) 319 self.AddStory(GmailPage(self))
320 self.AddStory(GoogleCalendarPage(self)) 320 self.AddStory(GoogleCalendarPage(self))
321 self.AddStory(GooglePlusPage(self)) 321 self.AddStory(GooglePlusPage(self))
322 self.AddStory(BlogspotPage(self)) 322 self.AddStory(BlogspotPage(self))
323 self.AddStory(WordpressPage(self)) 323 self.AddStory(WordpressPage(self))
324 self.AddStory(FacebookPage(self)) 324 self.AddStory(FacebookPage(self))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/top_25_smooth.py ('k') | tools/perf/page_sets/top_pages.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698