Chromium Code Reviews| Index: chrome/test/functional/tracing/tracing_base.py |
| diff --git a/chrome/test/functional/tracing/tracing_base.py b/chrome/test/functional/tracing/tracing_base.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..deb533a9f600c13dc2b8bad6d34ad7cecacb3785 |
| --- /dev/null |
| +++ b/chrome/test/functional/tracing/tracing_base.py |
| @@ -0,0 +1,51 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| + |
| +import pyauto_tracing |
| +import pyauto |
| + |
| +from timeline_model import TimelineModel |
| + |
| +class TracingTestBase(pyauto.PyUITest): |
|
nduca
2012/07/18 05:51:35
Typically, python code names the file after the cl
|
| + def setUp(self): |
| + super(TracingTestBase, self).setUp() |
| + self._trace_win = self.GetBrowserWindowCount() |
| + self.OpenNewBrowserWindow(False) |
| + self.NavigateToURL('chrome://tracing', self._trace_win) |
| + self.ExecuteJavascript(""" |
| + tracingController.addEventListener('traceEnded', function() { |
|
nduca
2012/07/18 05:51:35
This feels like it could be in the shim code.
E.g
|
| + 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.
|
| + var events = [tracingController.traceEvents_]; |
|
Russ Harmon
2012/07/14 11:58:45
I wasn't able to use tracingController.traceData a
|
| + if (tracingController.supportsSystemTracing) |
| + events.push(tracingController.systemTraceEvents_); |
| + window.pyauto_timeline_model.importTraces(events); |
| + window.domAutomationController.send(''); |
| + }); |
| + window.domAutomationController.send(''); |
| + """, 0, self._trace_win) |
| + |
| + def tearDown(self): |
| + self.CloseBrowserWindow(self._trace_win) |
| + self._trace_win = None |
|
nduca
2012/07/18 05:51:35
Is this conventional, to assign the trace_win to n
|
| + super(TracingTestBase, self).tearDown() |
| + |
| + def _BeginTracing(self, system_tracing=True): |
|
nduca
2012/07/18 05:51:35
Where's this get called from?
|
| + # TODO(nduca) Make the chrome tracing ui easier to automate |
| + self.ExecuteJavascript(""" |
| + tracingController.beginTracing( |
| + // Warning, possible javascript injection here! |
| + tracingController.supportsSystemTracing ? %s : false |
| + ); |
| + window.domAutomationController.send(''); |
| + """ % ("true" if system_tracing else "false"), 0, self._trace_win) |
| + |
| + def _EndTracing(self): |
|
nduca
2012/07/18 05:51:35
Where's this called from?
|
| + # TODO(nduca) Make the chrome tracing ui easier to automate |
| + self.ExecuteJavascript(""" |
| + tracingController.endTracing(); |
| + """, 0, self._trace_win) |
| + return TimelineModel(self, "window.pyauto_timeline_model") |