1f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)# Copyright 2014 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)# found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)import unittest 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)from telemetry.timeline import event 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class TimelineEventTest(unittest.TestCase): 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) def testHasThreadTimestamps(self): 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) # No thread_start and no thread_duration 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) event_1 = event.TimelineEvent('test', 'foo', 0, 10) 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) # Has thread_start but no thread_duration 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) event_2 = event.TimelineEvent('test', 'foo', 0, 10, 2) 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) # Has thread_duration but no thread_start 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) event_3 = event.TimelineEvent('test', 'foo', 0, 10, None, 4) 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) # Has thread_start and thread_duration 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) event_4 = event.TimelineEvent('test', 'foo', 0, 10, 2, 4) 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) self.assertFalse(event_1.has_thread_timestamps) 22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) self.assertFalse(event_2.has_thread_timestamps) 23cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) self.assertFalse(event_3.has_thread_timestamps) 24cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) self.assertTrue(event_4.has_thread_timestamps) 25