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

Side by Side Diff: tools/telemetry/telemetry/compound_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 from telemetry import page_action
5
6 class CompoundAction(page_action.PageAction):
7 def __init__(self, attributes=None):
8 super(CompoundAction, self).__init__(attributes)
9 self._actions = []
10 from telemetry import all_page_actions
11 for action_data in self.actions:
12 action = all_page_actions.FindClassWithName(
13 action_data['action'])(action_data)
14 self._actions.append(action)
15
16 def CustomizeBrowserOptions(self, options):
17 for action in self._actions:
18 action.CustomizeBrowserOptions(options)
19
20 def RunsPreviousAction(self):
21 return self._actions and self._actions[0].RunsPreviousAction()
22
23 def RunAction(self, page, tab, previous_action):
24 for i, action in enumerate(self._actions):
25 prev_action = self._actions[i - 1] if i > 0 else previous_action
26 next_action = self._actions[i + 1] if i < len(self._actions) - 1 else None
27
28 if (action.RunsPreviousAction() and
29 next_action and next_action.RunsPreviousAction()):
30 raise page_action.PageActionFailed('Consecutive actions cannot both '
31 'have RunsPreviousAction() == True.')
32
33 if not (next_action and next_action.RunsPreviousAction()):
34 action.WillRunAction(page, tab)
35 action.RunAction(page, tab, prev_action)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/click_element_action_unittest.py ('k') | tools/telemetry/telemetry/compound_action_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698