OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2011 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 unittest | |
7 | |
8 import pyauto_tracing | |
9 import pyauto | |
10 | |
11 from timeline_model import TimelineModel | |
12 | |
13 class TracingTestBase(pyauto.PyUITest): | |
nduca
2012/07/18 05:51:35
Typically, python code names the file after the cl
| |
14 def setUp(self): | |
15 super(TracingTestBase, self).setUp() | |
16 self._trace_win = self.GetBrowserWindowCount() | |
17 self.OpenNewBrowserWindow(False) | |
18 self.NavigateToURL('chrome://tracing', self._trace_win) | |
19 self.ExecuteJavascript(""" | |
20 tracingController.addEventListener('traceEnded', function() { | |
nduca
2012/07/18 05:51:35
This feels like it could be in the shim code.
E.g
| |
21 window.pyauto_timeline_model = new tracing.TimelineModel(); | |
nduca
2012/07/18 05:51:35
Instead of creating a timeline model directly, cre
nduca
2012/07/18 05:51:35
We use window.fooBar convention in js for globals.
| |
22 var events = [tracingController.traceEvents_]; | |
Russ Harmon
2012/07/14 11:58:45
I wasn't able to use tracingController.traceData a
| |
23 if (tracingController.supportsSystemTracing) | |
24 events.push(tracingController.systemTraceEvents_); | |
25 window.pyauto_timeline_model.importTraces(events); | |
26 window.domAutomationController.send(''); | |
27 }); | |
28 window.domAutomationController.send(''); | |
29 """, 0, self._trace_win) | |
30 | |
31 def tearDown(self): | |
32 self.CloseBrowserWindow(self._trace_win) | |
33 self._trace_win = None | |
nduca
2012/07/18 05:51:35
Is this conventional, to assign the trace_win to n
| |
34 super(TracingTestBase, self).tearDown() | |
35 | |
36 def _BeginTracing(self, system_tracing=True): | |
nduca
2012/07/18 05:51:35
Where's this get called from?
| |
37 # TODO(nduca) Make the chrome tracing ui easier to automate | |
38 self.ExecuteJavascript(""" | |
39 tracingController.beginTracing( | |
40 // Warning, possible javascript injection here! | |
41 tracingController.supportsSystemTracing ? %s : false | |
42 ); | |
43 window.domAutomationController.send(''); | |
44 """ % ("true" if system_tracing else "false"), 0, self._trace_win) | |
45 | |
46 def _EndTracing(self): | |
nduca
2012/07/18 05:51:35
Where's this called from?
| |
47 # TODO(nduca) Make the chrome tracing ui easier to automate | |
48 self.ExecuteJavascript(""" | |
49 tracingController.endTracing(); | |
50 """, 0, self._trace_win) | |
51 return TimelineModel(self, "window.pyauto_timeline_model") | |
OLD | NEW |