OLD | NEW |
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 # pylint: disable=W0401,W0614 | 4 # pylint: disable=W0401,W0614 |
5 from telemetry.page.actions.all_page_actions import * | 5 from telemetry.page.actions.all_page_actions import * |
6 from telemetry.page import page as page_module | 6 from telemetry.page import page as page_module |
7 from telemetry.page import page_set as page_set_module | 7 from telemetry.page import page_set as page_set_module |
8 | 8 |
9 | 9 |
10 class ToughPinchZoomCasesPage(page_module.Page): | 10 class ToughPinchZoomCasesPage(page_module.Page): |
11 | 11 |
12 def __init__(self, url, page_set, name=''): | 12 def __init__(self, url, page_set, name=''): |
13 super(ToughPinchZoomCasesPage, self).__init__(url=url, page_set=page_set, | 13 super(ToughPinchZoomCasesPage, self).__init__(url=url, page_set=page_set, |
14 name=name) | 14 name=name) |
15 self.credentials_path = 'data/credentials.json' | 15 self.credentials_path = 'data/credentials.json' |
16 self.user_agent_type = 'desktop' | 16 self.user_agent_type = 'desktop' |
17 self.archive_data_file = 'data/tough_pinch_zoom_cases.json' | 17 self.archive_data_file = 'data/tough_pinch_zoom_cases.json' |
18 | 18 |
19 def RunSmoothness(self, action_runner): | 19 def RunSmoothness(self, action_runner): |
20 action_runner.RunAction(PinchAction()) | 20 interaction = action_runner.BeginGestureInteraction( |
| 21 'PinchAction', is_smooth=True) |
| 22 action_runner.PinchPage() |
| 23 interaction.End() |
21 | 24 |
22 | 25 |
23 class GoogleSearchPage(ToughPinchZoomCasesPage): | 26 class GoogleSearchPage(ToughPinchZoomCasesPage): |
24 | 27 |
25 """ Why: top google property; a google tab is often open. """ | 28 """ Why: top google property; a google tab is often open. """ |
26 | 29 |
27 def __init__(self, page_set): | 30 def __init__(self, page_set): |
28 super(GoogleSearchPage, self).__init__( | 31 super(GoogleSearchPage, self).__init__( |
29 url='https://www.google.com/#hl=en&q=barack+obama', | 32 url='https://www.google.com/#hl=en&q=barack+obama', |
30 page_set=page_set) | 33 page_set=page_set) |
(...skipping 30 matching lines...) Expand all Loading... |
61 url='https://www.google.com/calendar/', | 64 url='https://www.google.com/calendar/', |
62 page_set=page_set) | 65 page_set=page_set) |
63 | 66 |
64 self.credentials = 'google' | 67 self.credentials = 'google' |
65 | 68 |
66 def RunNavigateSteps(self, action_runner): | 69 def RunNavigateSteps(self, action_runner): |
67 action_runner.NavigateToPage(self) | 70 action_runner.NavigateToPage(self) |
68 action_runner.Wait(2) | 71 action_runner.Wait(2) |
69 | 72 |
70 def RunSmoothness(self, action_runner): | 73 def RunSmoothness(self, action_runner): |
71 action_runner.RunAction(PinchAction( | 74 interaction = action_runner.BeginGestureInteraction( |
72 { | 75 'PinchAction', is_smooth=True) |
73 'left_anchor_percentage': 0.1, | 76 action_runner.PinchPage(left_anchor_ratio=0.1, top_anchor_ratio=0.3) |
74 'top_anchor_percentage': 0.3 | 77 interaction.End() |
75 })) | |
76 | 78 |
77 | 79 |
78 class GoogleImageSearchPage(ToughPinchZoomCasesPage): | 80 class GoogleImageSearchPage(ToughPinchZoomCasesPage): |
79 | 81 |
80 """ Why: tough image case; top google properties """ | 82 """ Why: tough image case; top google properties """ |
81 | 83 |
82 def __init__(self, page_set): | 84 def __init__(self, page_set): |
83 super(GoogleImageSearchPage, self).__init__( | 85 super(GoogleImageSearchPage, self).__init__( |
84 url='https://www.google.com/search?q=cats&tbm=isch', | 86 url='https://www.google.com/search?q=cats&tbm=isch', |
85 page_set=page_set) | 87 page_set=page_set) |
(...skipping 10 matching lines...) Expand all Loading... |
96 url='https://plus.google.com/+BarackObama/posts', | 98 url='https://plus.google.com/+BarackObama/posts', |
97 page_set=page_set) | 99 page_set=page_set) |
98 | 100 |
99 self.credentials = 'google' | 101 self.credentials = 'google' |
100 | 102 |
101 def RunNavigateSteps(self, action_runner): | 103 def RunNavigateSteps(self, action_runner): |
102 action_runner.NavigateToPage(self) | 104 action_runner.NavigateToPage(self) |
103 action_runner.WaitForElement(text='Home') | 105 action_runner.WaitForElement(text='Home') |
104 | 106 |
105 def RunSmoothness(self, action_runner): | 107 def RunSmoothness(self, action_runner): |
106 action_runner.RunAction(PinchAction( | 108 interaction = action_runner.BeginGestureInteraction( |
107 { | 109 'PinchAction', is_smooth=True) |
108 'element_function': ''' | 110 action_runner.PinchElement(selector='110031535020051778989-tab-bar') |
109 function(callback) { | 111 interaction.End() |
110 callback(document.getElementById("110031535020051778989-tab-bar")) | |
111 }''' | |
112 })) | |
113 | 112 |
114 | 113 |
115 class YoutubePage(ToughPinchZoomCasesPage): | 114 class YoutubePage(ToughPinchZoomCasesPage): |
116 | 115 |
117 """ Why: #3 (Alexa global) """ | 116 """ Why: #3 (Alexa global) """ |
118 | 117 |
119 def __init__(self, page_set): | 118 def __init__(self, page_set): |
120 super(YoutubePage, self).__init__( | 119 super(YoutubePage, self).__init__( |
121 url='http://www.youtube.com', | 120 url='http://www.youtube.com', |
122 page_set=page_set) | 121 page_set=page_set) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 class YahooAnswersPage(ToughPinchZoomCasesPage): | 229 class YahooAnswersPage(ToughPinchZoomCasesPage): |
231 | 230 |
232 """ Why: #1 Alexa reference """ | 231 """ Why: #1 Alexa reference """ |
233 | 232 |
234 def __init__(self, page_set): | 233 def __init__(self, page_set): |
235 super(YahooAnswersPage, self).__init__( | 234 super(YahooAnswersPage, self).__init__( |
236 url='http://answers.yahoo.com', | 235 url='http://answers.yahoo.com', |
237 page_set=page_set) | 236 page_set=page_set) |
238 | 237 |
239 def RunSmoothness(self, action_runner): | 238 def RunSmoothness(self, action_runner): |
240 action_runner.RunAction(PinchAction( | 239 interaction = action_runner.BeginGestureInteraction( |
241 { | 240 'PinchAction', is_smooth=True) |
242 'element_function': ''' | 241 action_runner.PinchElement(selector='ya-content-apps') |
243 function(callback) { | 242 interaction.End() |
244 callback(document.getElementById("ya-content-apps")) | |
245 }''' | |
246 })) | |
247 | 243 |
248 | 244 |
249 class ToughPinchZoomCasesPageSet(page_set_module.PageSet): | 245 class ToughPinchZoomCasesPageSet(page_set_module.PageSet): |
250 | 246 |
251 """ Set of pages that are tricky to pinch-zoom """ | 247 """ Set of pages that are tricky to pinch-zoom """ |
252 | 248 |
253 def __init__(self): | 249 def __init__(self): |
254 super(ToughPinchZoomCasesPageSet, self).__init__( | 250 super(ToughPinchZoomCasesPageSet, self).__init__( |
255 credentials_path='data/credentials.json', | 251 credentials_path='data/credentials.json', |
256 user_agent_type='desktop', | 252 user_agent_type='desktop', |
(...skipping 30 matching lines...) Expand all Loading... |
287 | 283 |
288 self.AddPage(YahooGamePage(self)) | 284 self.AddPage(YahooGamePage(self)) |
289 | 285 |
290 # Why: #1 Alexa recreation | 286 # Why: #1 Alexa recreation |
291 self.AddPage(ToughPinchZoomCasesPage('http://booking.com', self)) | 287 self.AddPage(ToughPinchZoomCasesPage('http://booking.com', self)) |
292 | 288 |
293 self.AddPage(YahooAnswersPage(self)) | 289 self.AddPage(YahooAnswersPage(self)) |
294 | 290 |
295 # Why: #1 Alexa sports | 291 # Why: #1 Alexa sports |
296 self.AddPage(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self)) | 292 self.AddPage(ToughPinchZoomCasesPage('http://sports.yahoo.com/', self)) |
OLD | NEW |