Home | History | Annotate | Download | only in timeline
      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
      5 
      6 from telemetry.timeline import model as model_module
      7 
      8 
      9 class ThreadUnittest(unittest.TestCase):
     10 
     11   def testIterAllSlicesInRange(self):
     12     model = model_module.TimelineModel()
     13     renderer_main = model.GetOrCreateProcess(1).GetOrCreateThread(2)
     14     #    [       X     ] [   Y    ] [   U   ]
     15     #        [   Z   ]     [ T ]
     16     #      |                           |
     17     #    start                        end
     18     renderer_main.BeginSlice('cat1', 'X', 10)
     19     renderer_main.BeginSlice('cat1', 'Z', 20)
     20     renderer_main.EndSlice(30)
     21     renderer_main.EndSlice(40)
     22     renderer_main.BeginSlice('cat1', 'Y', 50)
     23     renderer_main.BeginSlice('cat1', 'T', 52)
     24     renderer_main.EndSlice(55)
     25     renderer_main.EndSlice(60)
     26     renderer_main.BeginSlice('cat1', 'U', 60)
     27     renderer_main.EndSlice(70)
     28 
     29     model.FinalizeImport(shift_world_to_zero=False)
     30     slice_names = set(s.name for s in
     31                       renderer_main.IterAllSlicesInRange(start=12, end=65))
     32     self.assertEqual(slice_names, {'Z', 'Y', 'T'})
     33