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

Side by Side Diff: tools/telemetry/telemetry/page_action.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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 class PageActionNotSupported(Exception):
6 pass
7
8 class PageActionFailed(Exception):
9 pass
10
11 class PageAction(object):
12 """Represents an action that a user might try to perform to a page."""
13 def __init__(self, attributes=None):
14 if attributes:
15 for k, v in attributes.iteritems():
16 setattr(self, k, v)
17
18 def CustomizeBrowserOptions(self, options):
19 """Override to add action-specific options to the BrowserOptions
20 object."""
21 pass
22
23 def WillRunAction(self, page, tab):
24 """Override to do action-specific setup before
25 Test.WillRunAction is called."""
26 pass
27
28 def RunAction(self, page, tab, previous_action):
29 raise NotImplementedError()
30
31 def RunsPreviousAction(self):
32 """Some actions require some initialization to be performed before the
33 previous action. For example, wait for href change needs to record the old
34 href before the previous action changes it. Therefore, we allow actions to
35 run the previous action. An action that does this should override this to
36 return True in order to prevent the previous action from being run twice."""
37 return False
38
39 def CleanUp(self, page, tab):
40 pass
41
42 def CanBeBound(self):
43 """If this class implements BindMeasurementJavaScript, override CanBeBound
44 to return True so that a benchmark knows it can bind measurements."""
45 return False
46
47 def BindMeasurementJavaScript(
48 self, tab, start_js, stop_js): # pylint: disable=W0613
49 """Let this action determine when measurements should start and stop.
50
51 A benchmark or measurement can call this method to provide the action
52 with JavaScript code that starts and stops measurements. The action
53 determines when to execute the provided JavaScript code, for more accurate
54 timings.
55
56 Args:
57 tab: The tab to do everything on.
58 start_js: JavaScript code that starts measurements.
59 stop_js: JavaScript code that stops measurements.
60 """
61 raise Exception('This action cannot be bound.')
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/wait_action_unittest.py ('k') | tools/telemetry/telemetry/page_benchmark_results.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698