Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: chrome/test/functional/tracing.py

Issue 10736055: Smoke test for tracing infrastructure in PyAuto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_functional
9 import pyauto
nduca 2012/07/13 17:36:08 Lets split this into timeline_model.pyand tracing_
10 import inspect
11 import json
12 import string
13
14 class TimelineModel:
nduca 2012/07/13 09:47:56 TimelineModelProxy
15 def __init__(self, test):
nduca 2012/07/13 09:47:56 test -> automationController? So you're initializ
16 self._test = test
17
18 # Do note that the JSON serialization process removes cyclic references.
19 # TODO(eatnumber) regenerate these cyclic references on deserialization.
20 def __js_call__(self, name, *args):
nduca 2012/07/13 09:47:56 python convention say def _js_call(self, name, *a
21 return json.loads(self._test.ExecuteJavascript("""
22 var self = profilingView.timelineView.model;
23 var res = self['%s'].apply(self, JSON.parse('%s'));
nduca 2012/07/13 09:47:56 why [%s]? var res = %s.%s(%s)" % (self._remoteObj
24 window.domAutomationController.sendJSON(
25 JSON.stringify(JSON.stringify(res))
nduca 2012/07/13 09:47:56 Probably worth setting up some basic error handlin
26 );
27 """ % (
28 # Poor man's string escape.
29 string.replace(name, "'", "\\'"),
nduca 2012/07/13 09:47:56 make this a method called escapeForJavascriptExecu
30 string.replace(json.dumps(args), "'", "\\'")
31 ), 0, self._test.trace_win))
32
33 def getAllThreads(self):
34 return self.__js_call__(inspect.stack()[0][3]);
nduca 2012/07/13 09:47:56 Too magic. Hard code it. Also, does PyAuto not fol
35
36 def getAllCpus(self):
37 return self.__js_call__(inspect.stack()[0][3]);
38
39 def getAllProcesses(self):
40 return self.__js_call__(inspect.stack()[0][3]);
41
42 def getAllCounters(self):
43 return self.__js_call__(inspect.stack()[0][3]);
44
45 class TraceTest(pyauto.PyUITest):
46 def setUp(self):
47 super(TraceTest, self).setUp()
48 self.trace_win = self.GetBrowserWindowCount()
49 self.OpenNewBrowserWindow(False)
50 self.NavigateToURL('chrome://tracing', self.trace_win)
nduca 2012/07/13 09:47:56 do we know if NavigateToURL waits for the DOMConte
Russ Harmon 2012/07/13 23:24:24 Other tests do it this way, so I'd assume yes.
51 self.ExecuteJavascript("""
52 tracingController.addEventListener("traceEnded", function() {
nduca 2012/07/13 09:47:56 single quotes in javascript
53 window.domAutomationController.send("");
nduca 2012/07/13 09:47:56 So if you pair this with the codereview I just pos
54 });
55 window.domAutomationController.send("");
56 """, 0, self.trace_win)
57
58 def tearDown(self):
59 self.CloseBrowserWindow(self.trace_win)
60 self.trace_win = None
nduca 2012/07/13 09:47:56 presumably this is _trace_win since you probably d
61 super(TraceTest, self).tearDown()
62
63 def _BeginTracing(self):
64 # TODO(nduca) Make the chrome tracing ui easier to automate
65 self.ExecuteJavascript("""
66 tracingController.beginTracing(true);
67 window.domAutomationController.send("");
68 """, 0, self.trace_win)
69
70 def _EndTracing(self):
71 # TODO(nduca) Make the chrome tracing ui easier to automate
72 self.ExecuteJavascript("""
73 tracingController.endTracing();
74 """, 0, self.trace_win)
75 return TimelineModel(self);
nduca 2012/07/13 09:47:56 What in the test does this cause us to wait on the
Russ Harmon 2012/07/13 23:24:24 I hope I understand this question correctly. Exec
76
77 def testBlah(self):
78 self._BeginTracing()
79 self.NavigateToURL('http://google.com')
80 model = self._EndTracing()
81
82
83 if __name__ == '__main__':
84 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698