2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
11 class TracingSmokeTest(pyauto.PyUITest):
12 """Test basic functionality of the tracing API."""
14 super(TracingSmokeTest, self).setUp()
15 self._tracer_factory = tracer.TracerFactory(self)
17 def testGetData(self):
18 """Check that we can find a CrBrowserMain thread."""
19 tracer = self._tracer_factory.Produce()
21 model = tracer.EndTracing()
22 self.assertEqual(1, len(model.FindAllThreadsNamed('CrBrowserMain')))
24 def testMultipleTraces(self):
25 """Check that we can run multiple traces on the same tracer."""
26 tracer = self._tracer_factory.Produce()
28 model1 = tracer.EndTracing()
30 model2 = tracer.EndTracing()
31 self.assertEqual(1, len(model1.FindAllThreadsNamed('CrBrowserMain')))
32 self.assertEqual(1, len(model2.FindAllThreadsNamed('CrBrowserMain')))
34 def testMultipleTracers(self):
35 """Check that we can run multiple traces with multiple tracers."""
36 tracer1 = self._tracer_factory.Produce()
37 tracer2 = self._tracer_factory.Produce()
38 # Nested calls to beginTracing is untested and probably won't work.
39 tracer1.BeginTracing()
40 model1 = tracer1.EndTracing()
41 tracer2.BeginTracing()
42 model2 = tracer2.EndTracing()
43 self.assertEqual(1, len(model1.FindAllThreadsNamed('CrBrowserMain')))
44 self.assertEqual(1, len(model2.FindAllThreadsNamed('CrBrowserMain')))
46 def testModelValidAfterTracer(self):
47 """Check that a TimelineModel is valid after its Tracer is gone."""
48 tracer = self._tracer_factory.Produce()
49 del self._tracer_factory
51 model = tracer.EndTracing()
53 self.assertEqual(1, len(model.FindAllThreadsNamed('CrBrowserMain')))
56 if __name__ == '__main__':