def testTracingTrackSerialization(self): self._HandleEvents(self._MIXED_EVENTS) json_dict = self.track.ToJsonDict() self.assertTrue('events' in json_dict) deserialized_track = TracingTrack.FromJsonDict(json_dict) self.assertEquals(len(self.track._events), len(deserialized_track._events)) for (e1, e2) in zip(self.track._events, deserialized_track._events): self.assertEquals(e1.tracing_event, e2.tracing_event)
def testTracingTrackSerialization(self): events = self._MIXED_EVENTS self.track.Handle('Tracing.dataCollected', {'params': {'value': [self.EventToMicroseconds(e) for e in events]}}) json_dict = self.track.ToJsonDict() self.assertTrue('events' in json_dict) deserialized_track = TracingTrack.FromJsonDict(json_dict) self.assertEquals( len(self.track._events), len(deserialized_track._events)) for (e1, e2) in zip(self.track._events, deserialized_track._events): self.assertEquals(e1.tracing_event, e2.tracing_event)
def testHasLoadingSucceeded(self): cat = 'navigation' on_navigate = 'RenderFrameImpl::OnNavigate' fail_provisional = 'RenderFrameImpl::didFailProvisionalLoad' fail_load = 'RenderFrameImpl::didFailLoad' track = TracingTrack.FromJsonDict({'categories': [cat], 'events': []}) with self.assertRaises(AssertionError): track.HasLoadingSucceeded() track = TracingTrack.FromJsonDict({ 'categories': [cat], 'events': [{ 'cat': cat, 'name': on_navigate, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }] }) self.assertTrue(track.HasLoadingSucceeded()) track = TracingTrack.FromJsonDict({ 'categories': [cat], 'events': [{ 'cat': cat, 'name': on_navigate, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }, { 'cat': cat, 'name': on_navigate, 'args': { 'id': 2 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }, { 'cat': cat, 'name': fail_provisional, 'args': { 'id': 2 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }] }) self.assertTrue(track.HasLoadingSucceeded()) track = TracingTrack.FromJsonDict({ 'categories': [cat], 'events': [{ 'cat': cat, 'name': on_navigate, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }, { 'cat': cat, 'name': fail_provisional, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }] }) self.assertFalse(track.HasLoadingSucceeded()) track = TracingTrack.FromJsonDict({ 'categories': [cat], 'events': [{ 'cat': cat, 'name': on_navigate, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }, { 'cat': cat, 'name': fail_load, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }] }) self.assertFalse(track.HasLoadingSucceeded()) track = TracingTrack.FromJsonDict({ 'categories': [cat], 'events': [{ 'cat': cat, 'name': on_navigate, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }, { 'cat': cat, 'name': fail_load, 'args': { 'id': 1 }, 'ts': 5, 'ph': 'X', 'dur': 10, 'pid': 1, 'tid': 1 }] }) self.assertFalse(track.HasLoadingSucceeded())