| 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 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 from page_sets.login_helpers import google_login |
| 8 from page_sets import top_pages | 9 from page_sets import top_pages |
| 9 | 10 |
| 10 | 11 |
| 11 def _IssueMarkerAndScroll(action_runner): | 12 def _IssueMarkerAndScroll(action_runner): |
| 12 with action_runner.CreateGestureInteraction('ScrollAction'): | 13 with action_runner.CreateGestureInteraction('ScrollAction'): |
| 13 action_runner.ScrollPage() | 14 action_runner.ScrollPage() |
| 14 | 15 |
| 15 | 16 |
| 16 def _CreatePageClassWithSmoothInteractions(page_cls): | 17 def _CreatePageClassWithSmoothInteractions(page_cls): |
| 17 class DerivedSmoothPage(page_cls): # pylint: disable=no-init | 18 class DerivedSmoothPage(page_cls): # pylint: disable=no-init |
| 18 | 19 |
| 19 def RunPageInteractions(self, action_runner): | 20 def RunPageInteractions(self, action_runner): |
| 20 _IssueMarkerAndScroll(action_runner) | 21 _IssueMarkerAndScroll(action_runner) |
| 21 return DerivedSmoothPage | 22 return DerivedSmoothPage |
| 22 | 23 |
| 23 | 24 |
| 24 class TopSmoothPage(page_module.Page): | 25 class TopSmoothPage(page_module.Page): |
| 25 | 26 |
| 26 def __init__(self, url, page_set, name='', credentials=None): | 27 def __init__(self, url, page_set, name='', credentials=None): |
| 27 super(TopSmoothPage, self).__init__( | 28 super(TopSmoothPage, self).__init__( |
| 28 url=url, page_set=page_set, name=name, | 29 url=url, page_set=page_set, name=name, |
| 29 shared_page_state_class=shared_page_state.SharedDesktopPageState, | 30 shared_page_state_class=shared_page_state.SharedDesktopPageState, |
| 30 credentials_path='data/credentials.json') | 31 credentials_path='data/credentials.json') |
| 31 self.credentials = credentials | 32 self.credentials = credentials |
| 32 | 33 |
| 33 def RunPageInteractions(self, action_runner): | 34 def RunPageInteractions(self, action_runner): |
| 34 _IssueMarkerAndScroll(action_runner) | 35 _IssueMarkerAndScroll(action_runner) |
| 35 | 36 |
| 36 | 37 |
| 37 class GmailSmoothPage(top_pages.GmailPage): | 38 class GmailSmoothPage(top_pages.TopPages): |
| 38 | 39 |
| 39 """ Why: productivity, top google properties """ | 40 """ Why: productivity, top google properties """ |
| 40 | 41 |
| 42 def __init__(self, page_set, |
| 43 shared_page_state_class=shared_page_state.SharedPageState): |
| 44 # TODO(flackr): This is duplicating page logic from top_pages.py but is |
| 45 # the only way to update https://mail.google.com/mail/ for this test without |
| 46 # updating the 14 other recordings, as the gmail login flow has changed. |
| 47 # https://crbug.com/590766 tracks updating google_login.py to support |
| 48 # legacy and new login flow. |
| 49 super(GmailSmoothPage, self).__init__( |
| 50 url='https://mail.google.com/mail/', |
| 51 page_set=page_set, |
| 52 shared_page_state_class=shared_page_state_class) |
| 53 |
| 54 def RunNavigateSteps(self, action_runner): |
| 55 google_login.LoginGoogleAccount(action_runner, 'google3', |
| 56 self.credentials_path) |
| 57 super(GmailSmoothPage, self).RunNavigateSteps(action_runner) |
| 58 action_runner.WaitForJavaScriptCondition( |
| 59 'window.gmonkey !== undefined &&' |
| 60 'document.getElementById("gb") !== null', |
| 61 timeout_in_seconds=120) |
| 62 |
| 41 def RunPageInteractions(self, action_runner): | 63 def RunPageInteractions(self, action_runner): |
| 42 action_runner.ExecuteJavaScript(''' | 64 action_runner.ExecuteJavaScript(''' |
| 43 gmonkey.load('2.0', function(api) { | 65 gmonkey.load('2.0', function(api) { |
| 44 window.__scrollableElementForTelemetry = api.getScrollableElement(); | 66 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
| 45 });''') | 67 });''') |
| 46 action_runner.WaitForJavaScriptCondition( | 68 action_runner.WaitForJavaScriptCondition( |
| 47 'window.__scrollableElementForTelemetry != null') | 69 'window.__scrollableElementForTelemetry != null') |
| 48 with action_runner.CreateGestureInteraction('ScrollAction'): | 70 with action_runner.CreateGestureInteraction('ScrollAction'): |
| 49 action_runner.ScrollElement( | 71 action_runner.ScrollElement( |
| 50 element_function='window.__scrollableElementForTelemetry') | 72 element_function='window.__scrollableElementForTelemetry') |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 other_urls.append('http://techcrunch.com') | 165 other_urls.append('http://techcrunch.com') |
| 144 | 166 |
| 145 for url in other_urls: | 167 for url in other_urls: |
| 146 self.AddStory(TopSmoothPage(url, self)) | 168 self.AddStory(TopSmoothPage(url, self)) |
| 147 | 169 |
| 148 | 170 |
| 149 class V8Top25SmoothPageSet(Top25SmoothPageSet): | 171 class V8Top25SmoothPageSet(Top25SmoothPageSet): |
| 150 def __init__(self): | 172 def __init__(self): |
| 151 # Disabled for V8 because of crbug.com/507836, crbug.com/527425 | 173 # Disabled for V8 because of crbug.com/507836, crbug.com/527425 |
| 152 super(V8Top25SmoothPageSet, self).__init__(techcrunch=False) | 174 super(V8Top25SmoothPageSet, self).__init__(techcrunch=False) |
| OLD | NEW |