| 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 | |
| 8 from telemetry import decorators | |
| 9 from telemetry.core.platform import tracing_category_filter | 7 from telemetry.core.platform import tracing_category_filter |
| 10 from telemetry.core.platform import tracing_options | 8 from telemetry.core.platform import tracing_options |
| 9 from telemetry import decorators |
| 11 from telemetry.page import page as page_module | 10 from telemetry.page import page as page_module |
| 12 from telemetry.page import page_test | 11 from telemetry.page import page_test |
| 13 from telemetry.timeline import async_slice | 12 from telemetry.timeline import async_slice |
| 14 from telemetry.timeline import model as model_module | 13 from telemetry.timeline import model as model_module |
| 15 from telemetry.unittest_util import page_test_test_case | 14 from telemetry.unittest_util import page_test_test_case |
| 16 from telemetry.web_perf import timeline_interaction_record as tir_module | 15 from telemetry.web_perf import timeline_interaction_record as tir_module |
| 17 | 16 |
| 17 from measurements import smooth_gesture_util as sg_util |
| 18 |
| 18 | 19 |
| 19 class SmoothGestureUtilTest(unittest.TestCase): | 20 class SmoothGestureUtilTest(unittest.TestCase): |
| 20 def testGetAdjustedInteractionIfContainGesture(self): | 21 def testGetAdjustedInteractionIfContainGesture(self): |
| 21 model = model_module.TimelineModel() | 22 model = model_module.TimelineModel() |
| 22 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) | 23 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2) |
| 23 renderer_main.name = 'CrRendererMain' | 24 renderer_main.name = 'CrRendererMain' |
| 24 | 25 |
| 25 # [ X ] [ Y ] | 26 # [ X ] [ Y ] |
| 26 # [ sub_async_slice_X ] | 27 # [ sub_async_slice_X ] |
| 27 # [ record_1] | 28 # [ record_1] |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 adjusted_smooth_gesture = ( | 152 adjusted_smooth_gesture = ( |
| 152 sg_util.GetAdjustedInteractionIfContainGesture( | 153 sg_util.GetAdjustedInteractionIfContainGesture( |
| 153 timeline_model, smooth_record)) | 154 timeline_model, smooth_record)) |
| 154 # Test that the scroll gesture starts at at least 500ms after the start of | 155 # 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 | 156 # the interaction record and ends at at least 500ms before the end of |
| 156 # interaction record. | 157 # interaction record. |
| 157 self.assertLessEqual( | 158 self.assertLessEqual( |
| 158 500, adjusted_smooth_gesture.start - smooth_record.start) | 159 500, adjusted_smooth_gesture.start - smooth_record.start) |
| 159 self.assertLessEqual( | 160 self.assertLessEqual( |
| 160 500, smooth_record.end - adjusted_smooth_gesture.end) | 161 500, smooth_record.end - adjusted_smooth_gesture.end) |
| OLD | NEW |