Mojo C++ bindings: better log message for serialization warnings.
[chromium-blink-merge.git] / tools / perf / measurements / smooth_gesture_util_unittest.py
blobc3cbbee2ad45f28bdf5318cc691e3532f82b2f70
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
3 # found in the LICENSE file.
4 import unittest
6 from telemetry.timeline import model as model_module
7 from telemetry.web_perf import timeline_interaction_record as tir_module
8 from measurements import smooth_gesture_util as sg_util
10 class SmoothGestureUtilTest(unittest.TestCase):
11 def testGetAdjustedInteractionIfContainGesture(self):
12 model = model_module.TimelineModel()
13 renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
14 renderer_main.name = 'CrRendererMain'
16 # [ X ] [ Y ]
17 # [ record_1]
18 # [ record_6]
19 # [ record_2 ] [ record_3 ]
20 # [ record_4 ]
21 # [ record_5 ]
22 renderer_main.BeginSlice('X', 'SyntheticGestureController::running', 10, 0)
23 renderer_main.EndSlice(30, 30)
24 renderer_main.BeginSlice('Y', 'SyntheticGestureController::running', 60, 0)
25 renderer_main.EndSlice(80, 80)
27 model.FinalizeImport(shift_world_to_zero=False)
29 record_1 = tir_module.TimelineInteractionRecord('Gesture_included', 15, 25)
30 record_2 = tir_module.TimelineInteractionRecord(
31 'Gesture_overlapped_left', 5, 25)
32 record_3 = tir_module.TimelineInteractionRecord(
33 'Gesture_overlapped_right', 25, 35)
34 record_4 = tir_module.TimelineInteractionRecord(
35 'Gesture_containing', 5, 35)
36 record_5 = tir_module.TimelineInteractionRecord(
37 'Gesture_non_overlapped', 35, 45)
38 record_6 = tir_module.TimelineInteractionRecord('Action_included', 15, 25)
40 adjusted_record_1 = sg_util.GetAdjustedInteractionIfContainGesture(
41 model, record_1)
42 self.assertEquals(adjusted_record_1.start, 10)
43 self.assertEquals(adjusted_record_1.end, 30)
44 self.assertTrue(adjusted_record_1 is not record_1)
46 adjusted_record_2 = sg_util.GetAdjustedInteractionIfContainGesture(
47 model, record_2)
48 self.assertEquals(adjusted_record_2.start, 10)
49 self.assertEquals(adjusted_record_2.end, 30)
51 adjusted_record_3 = sg_util.GetAdjustedInteractionIfContainGesture(
52 model, record_3)
53 self.assertEquals(adjusted_record_3.start, 10)
54 self.assertEquals(adjusted_record_3.end, 30)
56 adjusted_record_4 = sg_util.GetAdjustedInteractionIfContainGesture(
57 model, record_4)
58 self.assertEquals(adjusted_record_4.start, 10)
59 self.assertEquals(adjusted_record_4.end, 30)
61 adjusted_record_5 = sg_util.GetAdjustedInteractionIfContainGesture(
62 model, record_5)
63 self.assertEquals(adjusted_record_5.start, 35)
64 self.assertEquals(adjusted_record_5.end, 45)
65 self.assertTrue(adjusted_record_5 is not record_5)
67 adjusted_record_6 = sg_util.GetAdjustedInteractionIfContainGesture(
68 model, record_6)
69 self.assertEquals(adjusted_record_6.start, 15)
70 self.assertEquals(adjusted_record_6.end, 25)
71 self.assertTrue(adjusted_record_6 is not record_6)