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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 # scroll the page. | 107 # scroll the page. |
108 time.sleep(0.5) | 108 time.sleep(0.5) |
109 action_runner.ScrollPage() | 109 action_runner.ScrollPage() |
110 time.sleep(0.5) | 110 time.sleep(0.5) |
111 interaction.End() | 111 interaction.End() |
112 | 112 |
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.AddUserStory(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 | 123 # pylint: disable=bad-super-call |
124 super(ScrollingGestureTestMeasurement, self).__init__( | 124 super(ScrollingGestureTestMeasurement, self).__init__( |
125 'RunSmoothness', False) | 125 'RunSmoothness', False) |
126 | 126 |
127 def WillRunActions(self, _page, tab): | 127 def WillRunActions(self, _page, tab): |
(...skipping 22 matching lines...) Expand all Loading... |
150 adjusted_smooth_gesture = ( | 150 adjusted_smooth_gesture = ( |
151 sg_util.GetAdjustedInteractionIfContainGesture( | 151 sg_util.GetAdjustedInteractionIfContainGesture( |
152 timeline_model, smooth_record)) | 152 timeline_model, smooth_record)) |
153 # Test that the scroll gesture starts at at least 500ms after the start of | 153 # Test that the scroll gesture starts at at least 500ms after the start of |
154 # the interaction record and ends at at least 500ms before the end of | 154 # the interaction record and ends at at least 500ms before the end of |
155 # interaction record. | 155 # interaction record. |
156 self.assertLessEqual( | 156 self.assertLessEqual( |
157 500, adjusted_smooth_gesture.start - smooth_record.start) | 157 500, adjusted_smooth_gesture.start - smooth_record.start) |
158 self.assertLessEqual( | 158 self.assertLessEqual( |
159 500, smooth_record.end - adjusted_smooth_gesture.end) | 159 500, smooth_record.end - adjusted_smooth_gesture.end) |
OLD | NEW |