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

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

Issue 222873002: Remove pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 8 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
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 import os
7
8
9 class TimelineModel(object):
10 """A proxy for about:tracing's TimelineModel class.
11
12 Test authors should never need to know that this class is a proxy.
13 """
14 @staticmethod
15 def _EscapeForQuotedJavascriptExecution(js):
16 # Poor man's string escape.
17 return js.replace('\'', '\\\'');
18
19 def __init__(self, js_executor, shim_id):
20 self._js_executor = js_executor
21 self._shim_id = shim_id
22
23 # Warning: The JSON serialization process removes cyclic references.
24 # TODO(eatnumber): regenerate these cyclic references on deserialization.
25 def _CallModelMethod(self, method_name, *args):
26 result = self._js_executor(
27 """window.timelineModelShims['%s'].invokeMethod('%s', '%s')""" % (
28 self._shim_id,
29 self._EscapeForQuotedJavascriptExecution(method_name),
30 self._EscapeForQuotedJavascriptExecution(json.dumps(args))
31 )
32 )
33 if result['success']:
34 return result['data']
35 # TODO(eatnumber): Make these exceptions more reader friendly.
36 raise RuntimeError(result)
37
38 def __del__(self):
39 self._js_executor("""
40 window.timelineModelShims['%s'] = undefined;
41 window.domAutomationController.send('');
42 """ % self._shim_id)
43
44 def GetAllThreads(self):
45 return self._CallModelMethod('getAllThreads')
46
47 def GetAllCpus(self):
48 return self._CallModelMethod('getAllCpus')
49
50 def GetAllProcesses(self):
51 return self._CallModelMethod('getAllProcesses')
52
53 def GetAllCounters(self):
54 return self._CallModelMethod('getAllCounters')
55
56 def FindAllThreadsNamed(self, name):
57 return self._CallModelMethod('findAllThreadsNamed', name);
OLDNEW
« no previous file with comments | « chrome/test/functional/tracing/tab_tracker.py ('k') | chrome/test/functional/tracing/timeline_model_shim.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698