- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / timeline / slice_unittest.py
1 # Copyright 2013 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
5 import unittest
6
7 from telemetry.core.timeline.slice import Slice
8
9 class SliceTest(unittest.TestCase):
10   def testChildrenLogic(self):
11     # [      top          ]
12     #   [ a  ]    [  b  ]
13     #    [x]
14     top = Slice(None, 'cat', 'top', 0, duration=10)
15     a = Slice(None, 'cat', 'a', 1, duration=2)
16     x = Slice(None, 'cat', 'x', 1.5, duration=0.25)
17     b = Slice(None, 'cat', 'b', 5, duration=2)
18     top.sub_slices.extend([a, b])
19     a.sub_slices.append(x)
20
21     all_children = list(top.IterEventsInThisContainerRecrusively())
22     self.assertEquals([a, x, b], all_children)
23
24     self.assertEquals(x.self_time, 0.25)
25     self.assertEquals(a.self_time, 1.75) # 2 - 0.25
26     self.assertEquals(top.self_time, 6) # 10 - 2 -2