| 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 telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
| 6 | 6 |
| 7 | 7 |
| 8 class KeyDesktopMoveCasesPage(page_module.Page): | 8 class KeyDesktopMoveCasesPage(page_module.Page): |
| 9 | 9 |
| 10 def __init__(self, url, page_set, name='', credentials=None): | 10 def __init__(self, url, page_set, name='', credentials=None): |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 def RunPageInteractions(self, action_runner): | 45 def RunPageInteractions(self, action_runner): |
| 46 action_runner.ExecuteJavaScript(''' | 46 action_runner.ExecuteJavaScript(''' |
| 47 gmonkey.load('2.0', function(api) { | 47 gmonkey.load('2.0', function(api) { |
| 48 window.__scrollableElementForTelemetry = api.getScrollableElement(); | 48 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
| 49 });''') | 49 });''') |
| 50 action_runner.WaitForJavaScriptCondition( | 50 action_runner.WaitForJavaScriptCondition( |
| 51 'window.__scrollableElementForTelemetry != null') | 51 'window.__scrollableElementForTelemetry != null') |
| 52 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner) | 52 scrollbar_x, start_y, end_y = self._CalculateScrollBarRatios(action_runner) |
| 53 | 53 |
| 54 interaction = action_runner.BeginGestureInteraction( | 54 with action_runner.CreateGestureInteraction('DragAction'): |
| 55 'DragAction') | 55 action_runner.DragPage(left_start_ratio=scrollbar_x, |
| 56 action_runner.DragPage(left_start_ratio=scrollbar_x, | 56 top_start_ratio=start_y, left_end_ratio=scrollbar_x, |
| 57 top_start_ratio=start_y, left_end_ratio=scrollbar_x, | 57 top_end_ratio=end_y, speed_in_pixels_per_second=100, |
| 58 top_end_ratio=end_y, speed_in_pixels_per_second=100, | 58 element_function='window.__scrollableElementForTelemetry') |
| 59 element_function='window.__scrollableElementForTelemetry') | |
| 60 interaction.End() | |
| 61 | 59 |
| 62 def _CalculateScrollBarRatios(self, action_runner): | 60 def _CalculateScrollBarRatios(self, action_runner): |
| 63 viewport_height = float(action_runner.EvaluateJavaScript( | 61 viewport_height = float(action_runner.EvaluateJavaScript( |
| 64 'window.__scrollableElementForTelemetry.clientHeight')) | 62 'window.__scrollableElementForTelemetry.clientHeight')) |
| 65 content_height = float(action_runner.EvaluateJavaScript( | 63 content_height = float(action_runner.EvaluateJavaScript( |
| 66 'window.__scrollableElementForTelemetry.scrollHeight')) | 64 'window.__scrollableElementForTelemetry.scrollHeight')) |
| 67 viewport_width = float(action_runner.EvaluateJavaScript( | 65 viewport_width = float(action_runner.EvaluateJavaScript( |
| 68 'window.__scrollableElementForTelemetry.offsetWidth')) | 66 'window.__scrollableElementForTelemetry.offsetWidth')) |
| 69 scrollbar_width = float(action_runner.EvaluateJavaScript(''' | 67 scrollbar_width = float(action_runner.EvaluateJavaScript(''' |
| 70 window.__scrollableElementForTelemetry.offsetWidth - | 68 window.__scrollableElementForTelemetry.offsetWidth - |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 112 |
| 115 """ Special cases for move gesture """ | 113 """ Special cases for move gesture """ |
| 116 | 114 |
| 117 def __init__(self): | 115 def __init__(self): |
| 118 super(KeyDesktopMoveCasesPageSet, self).__init__( | 116 super(KeyDesktopMoveCasesPageSet, self).__init__( |
| 119 archive_data_file='data/key_desktop_move_cases.json', | 117 archive_data_file='data/key_desktop_move_cases.json', |
| 120 bucket=page_set_module.PARTNER_BUCKET) | 118 bucket=page_set_module.PARTNER_BUCKET) |
| 121 | 119 |
| 122 self.AddUserStory(GmailMouseScrollPage(self)) | 120 self.AddUserStory(GmailMouseScrollPage(self)) |
| 123 self.AddUserStory(GoogleMapsPage(self)) | 121 self.AddUserStory(GoogleMapsPage(self)) |
| OLD | NEW |