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 import decorators | 8 from telemetry import decorators |
9 from telemetry.core.platform import tracing_category_filter | 9 from telemetry.core.platform import tracing_category_filter |
10 from telemetry.core.platform import tracing_options | 10 from telemetry.core.platform import tracing_options |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 self.assertEquals(adjusted_record_6.end, 25) | 96 self.assertEquals(adjusted_record_6.end, 25) |
97 self.assertTrue(adjusted_record_6 is not record_6) | 97 self.assertTrue(adjusted_record_6 is not record_6) |
98 | 98 |
99 | 99 |
100 class ScrollingPage(page_module.Page): | 100 class ScrollingPage(page_module.Page): |
101 def __init__(self, url, page_set, base_dir): | 101 def __init__(self, url, page_set, base_dir): |
102 super(ScrollingPage, self).__init__(url, page_set, base_dir) | 102 super(ScrollingPage, self).__init__(url, page_set, base_dir) |
103 | 103 |
104 def RunPageInteractions(self, action_runner): | 104 def RunPageInteractions(self, action_runner): |
105 interaction = action_runner.BeginGestureInteraction( | 105 interaction = action_runner.BeginGestureInteraction( |
106 'ScrollAction', is_smooth=True) | 106 'ScrollAction') |
107 # Add 0.5s gap between when Gesture records are issued to when we actually | 107 # Add 0.5s gap between when Gesture records are issued to when we actually |
108 # scroll the page. | 108 # scroll the page. |
109 time.sleep(0.5) | 109 time.sleep(0.5) |
110 action_runner.ScrollPage() | 110 action_runner.ScrollPage() |
111 time.sleep(0.5) | 111 time.sleep(0.5) |
112 interaction.End() | 112 interaction.End() |
113 | 113 |
114 | 114 |
115 class SmoothGestureTest(page_test_test_case.PageTestTestCase): | 115 class SmoothGestureTest(page_test_test_case.PageTestTestCase): |
116 @decorators.Disabled('mac') # crbug.com/450171. | 116 @decorators.Disabled('mac') # crbug.com/450171. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 adjusted_smooth_gesture = ( | 151 adjusted_smooth_gesture = ( |
152 sg_util.GetAdjustedInteractionIfContainGesture( | 152 sg_util.GetAdjustedInteractionIfContainGesture( |
153 timeline_model, smooth_record)) | 153 timeline_model, smooth_record)) |
154 # Test that the scroll gesture starts at at least 500ms after the start of | 154 # Test that the scroll gesture starts at at least 500ms after the start of |
155 # the interaction record and ends at at least 500ms before the end of | 155 # the interaction record and ends at at least 500ms before the end of |
156 # interaction record. | 156 # interaction record. |
157 self.assertLessEqual( | 157 self.assertLessEqual( |
158 500, adjusted_smooth_gesture.start - smooth_record.start) | 158 500, adjusted_smooth_gesture.start - smooth_record.start) |
159 self.assertLessEqual( | 159 self.assertLessEqual( |
160 500, smooth_record.end - adjusted_smooth_gesture.end) | 160 500, smooth_record.end - adjusted_smooth_gesture.end) |
OLD | NEW |