OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 | 4 |
5 import unittest | 5 import unittest |
6 | 6 |
7 from telemetry.timeline_event import TimelineEvent | 7 from telemetry.core.chrome import timeline_event |
8 | 8 |
9 class TimelineEventTest(unittest.TestCase): | 9 class TimelineEventTest(unittest.TestCase): |
10 def testChildrenLogic(self): | 10 def testChildrenLogic(self): |
11 # [ top ] | 11 # [ top ] |
12 # [ a ] [ b ] | 12 # [ a ] [ b ] |
13 # [x] | 13 # [x] |
14 top = TimelineEvent('top', 0, 10) | 14 top = timeline_event.TimelineEvent('top', 0, 10) |
15 a = TimelineEvent('a', 1, 2) | 15 a = timeline_event.TimelineEvent('a', 1, 2) |
16 x = TimelineEvent('x', 1.5, 0.25) | 16 x = timeline_event.TimelineEvent('x', 1.5, 0.25) |
17 b = TimelineEvent('b', 5, 2) | 17 b = timeline_event.TimelineEvent('b', 5, 2) |
18 top.children.extend([a, b]) | 18 top.children.extend([a, b]) |
19 a.children.append(x) | 19 a.children.append(x) |
20 | 20 |
21 all_children = top.GetAllChildrenRecursive(include_self=True) | 21 all_children = top.GetAllChildrenRecursive(include_self=True) |
22 self.assertEquals([top, a, x, b], all_children) | 22 self.assertEquals([top, a, x, b], all_children) |
23 | 23 |
24 self.assertEquals(x.self_time_ms, 0.25) | 24 self.assertEquals(x.self_time_ms, 0.25) |
25 self.assertEquals(a.self_time_ms, 1.75) # 2 - 0.25 | 25 self.assertEquals(a.self_time_ms, 1.75) # 2 - 0.25 |
26 self.assertEquals(top.self_time_ms, 6) # 10 - 2 -2 | 26 self.assertEquals(top.self_time_ms, 6) # 10 - 2 -2 |
27 | 27 |
OLD | NEW |