OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
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. | |
5 | |
6 import pyauto_tracing | |
7 import pyauto | |
8 import tracer | |
9 | |
10 | |
11 class TracingSmokeTest(pyauto.PyUITest): | |
12 """Test basic functionality of the tracing API.""" | |
13 def setUp(self): | |
14 super(TracingSmokeTest, self).setUp() | |
15 self._tracer_factory = tracer.TracerFactory(self) | |
16 | |
17 def testGetData(self): | |
18 """Check that we can find a CrBrowserMain thread.""" | |
19 tracer = self._tracer_factory.Produce() | |
20 tracer.BeginTracing() | |
21 model = tracer.EndTracing() | |
22 self.assertEqual(1, len(model.FindAllThreadsNamed('CrBrowserMain'))) | |
23 | |
24 def testMultipleTraces(self): | |
25 """Check that we can run multiple traces on the same tracer.""" | |
26 tracer = self._tracer_factory.Produce() | |
27 tracer.BeginTracing() | |
28 model1 = tracer.EndTracing() | |
29 tracer.BeginTracing() | |
30 model2 = tracer.EndTracing() | |
31 self.assertEqual(1, len(model1.FindAllThreadsNamed('CrBrowserMain'))) | |
32 self.assertEqual(1, len(model2.FindAllThreadsNamed('CrBrowserMain'))) | |
33 | |
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'))) | |
45 | |
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 | |
50 tracer.BeginTracing() | |
51 model = tracer.EndTracing() | |
52 del tracer | |
53 self.assertEqual(1, len(model.FindAllThreadsNamed('CrBrowserMain'))) | |
54 | |
55 | |
56 if __name__ == '__main__': | |
57 pyauto_tracing.Main() | |
OLD | NEW |