| 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 import time | 4 import time |
| 5 import unittest | 5 import unittest |
| 6 | 6 |
| 7 from measurements import smooth_gesture_util as sg_util | 7 from measurements import smooth_gesture_util as sg_util |
| 8 from telemetry.core.platform import tracing_category_filter | 8 from telemetry.core.platform import tracing_category_filter |
| 9 from telemetry.core.platform import tracing_options | 9 from telemetry.core.platform import tracing_options |
| 10 from telemetry.page import page as page_module | 10 from telemetry.page import page as page_module |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 class SmoothGestureTest(page_test_test_case.PageTestTestCase): | 114 class SmoothGestureTest(page_test_test_case.PageTestTestCase): |
| 115 def testSmoothGestureAdjusted(self): | 115 def testSmoothGestureAdjusted(self): |
| 116 ps = self.CreateEmptyPageSet() | 116 ps = self.CreateEmptyPageSet() |
| 117 ps.AddPage(ScrollingPage( | 117 ps.AddPage(ScrollingPage( |
| 118 'file://scrollable_page.html', ps, base_dir=ps.base_dir)) | 118 'file://scrollable_page.html', ps, base_dir=ps.base_dir)) |
| 119 models = [] | 119 models = [] |
| 120 tab_ids = [] | 120 tab_ids = [] |
| 121 class ScrollingGestureTestMeasurement(page_test.PageTest): | 121 class ScrollingGestureTestMeasurement(page_test.PageTest): |
| 122 def __init__(self): | 122 def __init__(self): |
| 123 # pylint: disable=bad-super-call | |
| 124 super(ScrollingGestureTestMeasurement, self).__init__( | 123 super(ScrollingGestureTestMeasurement, self).__init__( |
| 125 'RunSmoothness', False) | 124 'RunSmoothness', False) |
| 126 | 125 |
| 127 def WillRunActions(self, _page, tab): | 126 def WillRunActions(self, _page, tab): |
| 128 options = tracing_options.TracingOptions() | 127 options = tracing_options.TracingOptions() |
| 129 options.enable_chrome_trace = True | 128 options.enable_chrome_trace = True |
| 130 tab.browser.platform.tracing_controller.Start( | 129 tab.browser.platform.tracing_controller.Start( |
| 131 options, tracing_category_filter.TracingCategoryFilter()) | 130 options, tracing_category_filter.TracingCategoryFilter()) |
| 132 | 131 |
| 133 def DidRunActions(self, _page, tab): | 132 def DidRunActions(self, _page, tab): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 147 adjusted_smooth_gesture = ( | 146 adjusted_smooth_gesture = ( |
| 148 sg_util.GetAdjustedInteractionIfContainGesture( | 147 sg_util.GetAdjustedInteractionIfContainGesture( |
| 149 timeline_model, smooth_record)) | 148 timeline_model, smooth_record)) |
| 150 # Test that the scroll gesture starts at at least 500ms after the start of | 149 # Test that the scroll gesture starts at at least 500ms after the start of |
| 151 # the interaction record and ends at at least 500ms before the end of | 150 # the interaction record and ends at at least 500ms before the end of |
| 152 # interaction record. | 151 # interaction record. |
| 153 self.assertLessEqual( | 152 self.assertLessEqual( |
| 154 500, adjusted_smooth_gesture.start - smooth_record.start) | 153 500, adjusted_smooth_gesture.start - smooth_record.start) |
| 155 self.assertLessEqual( | 154 self.assertLessEqual( |
| 156 500, smooth_record.end - adjusted_smooth_gesture.end) | 155 500, smooth_record.end - adjusted_smooth_gesture.end) |
| OLD | NEW |