OLD | NEW |
(Empty) | |
| 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 |
| 5 import unittest |
| 6 |
| 7 from metrics import timeline_interaction_record |
| 8 from telemetry.core.timeline import async_slice |
| 9 |
| 10 |
| 11 class ParseTests(unittest.TestCase): |
| 12 def testParse(self): |
| 13 self.assertTrue(timeline_interaction_record.IsTimelineInteractionRecord( |
| 14 'Interaction.Foo')) |
| 15 self.assertTrue(timeline_interaction_record.IsTimelineInteractionRecord( |
| 16 'Interaction.Foo/Bar')) |
| 17 self.assertFalse(timeline_interaction_record.IsTimelineInteractionRecord( |
| 18 'SomethingRandom')) |
| 19 |
| 20 def CreateRecord(self, event_name): |
| 21 s = async_slice.AsyncSlice( |
| 22 'cat', event_name, |
| 23 timestamp=1, duration=2) |
| 24 return timeline_interaction_record.TimelineInteractionRecord(s) |
| 25 |
| 26 def testCreate(self): |
| 27 r = self.CreateRecord('Interaction.LogicalName') |
| 28 self.assertEquals('LogicalName', r.logical_name) |
| 29 self.assertEquals(False, r.is_smooth) |
| 30 self.assertEquals(False, r.is_loading_resources) |
| 31 |
| 32 r = self.CreateRecord('Interaction.LogicalName/is_smooth') |
| 33 self.assertEquals('LogicalName', r.logical_name) |
| 34 self.assertEquals(True, r.is_smooth) |
| 35 self.assertEquals(False, r.is_loading_resources) |
| 36 |
| 37 r = self.CreateRecord('Interaction.LogicalNameWith/Slash/is_smooth') |
| 38 self.assertEquals('LogicalNameWith/Slash', r.logical_name) |
| 39 self.assertEquals(True, r.is_smooth) |
| 40 self.assertEquals(False, r.is_loading_resources) |
| 41 |
| 42 r = self.CreateRecord( |
| 43 'Interaction.LogicalNameWith/Slash/is_smooth,is_loading_resources') |
| 44 self.assertEquals('LogicalNameWith/Slash', r.logical_name) |
| 45 self.assertEquals(True, r.is_smooth) |
| 46 self.assertEquals(True, r.is_loading_resources) |
OLD | NEW |