Beispiel #1
0
 def CaptureTraceMarkers(self):
     tracing_controller = self._browser.platform.tracing_controller
     options = tracing_config.TracingConfig()
     options.enable_chrome_trace = True
     tracing_controller.StartTracing(options)
     try:
         yield
     finally:
         trace_data = tracing_controller.StopTracing()
         self.markers = trace_processor.ExtractTimelineMarkers(trace_data)
    def testGotTrace(self):
        self.tracing_controller.StartTracing(self.config)
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('trace-event')

        trace_data = self.tracing_controller.StopTracing()
        self.assertFalse(self.tracing_controller.is_tracing_running)

        markers = trace_processor.ExtractTimelineMarkers(trace_data)
        self.assertIn('trace-event', markers)
Beispiel #3
0
 def testCreateInteraction(self):
   action_runner = action_runner_module.ActionRunner(self._tab)
   self.Navigate('interaction_enabled_page.html')
   action_runner.Wait(1)
   config = tracing_config.TracingConfig()
   config.chrome_trace_config.SetLowOverheadFilter()
   config.enable_chrome_trace = True
   self._browser.platform.tracing_controller.StartTracing(config)
   with action_runner.CreateInteraction('InteractionName', repeatable=True):
     pass
   trace_data = self._browser.platform.tracing_controller.StopTracing()
   markers = trace_processor.ExtractTimelineMarkers(trace_data)
   self.assertIn('Interaction.InteractionName/repeatable', markers)
    def testFlushTracing(self):
        self.tracing_controller.StartTracing(self.config)
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('before-flush')

        self.tracing_controller.FlushTracing()
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('after-flush')

        trace_data = self.tracing_controller.StopTracing()
        self.assertFalse(self.tracing_controller.is_tracing_running)

        # Both markers before and after flushing are found.
        markers = trace_processor.ExtractTimelineMarkers(trace_data)
        self.assertIn('before-flush', markers)
        self.assertIn('after-flush', markers)
    def testFlushTracingDiscardCurrent(self):
        self.tracing_controller.StartTracing(self.config)
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('before-flush')

        self.tracing_controller.FlushTracing(discard_current=True)
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('after-flush')

        trace_data = self.tracing_controller.StopTracing()
        self.assertFalse(self.tracing_controller.is_tracing_running)

        # The marker after flushing should be found, but not the one before.
        markers = trace_processor.ExtractTimelineMarkers(trace_data)
        self.assertIn('after-flush', markers)
        self.assertNotIn('before-flush', markers)
    def testStartAndStopTraceMultipleTimes(self):
        self.tracing_controller.StartTracing(self.config)
        self.assertTrue(self.tracing_controller.is_tracing_running)

        # Calling StartTracing again does nothing.
        self.assertFalse(self.tracing_controller.StartTracing(self.config))
        self.assertTrue(self.tracing_controller.is_tracing_running)

        self.AddTimelineMarker('trace-event')

        trace_data = self.tracing_controller.StopTracing()
        self.assertFalse(self.tracing_controller.is_tracing_running)

        markers = trace_processor.ExtractTimelineMarkers(trace_data)
        self.assertIn('trace-event', markers)

        # Calling StopTracing again will raise an exception.
        with self.assertRaises(Exception):
            self.tracing_controller.StopTracing()
 def StopTracingAndGetTimelineMarkers(self):
     self.assertTrue(self.tracing_controller.is_tracing_running)
     trace_data = self.tracing_controller.StopTracing()
     self.assertFalse(self.tracing_controller.is_tracing_running)
     return trace_processor.ExtractTimelineMarkers(trace_data)