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

Side by Side Diff: tools/telemetry/telemetry/page/actions/media_action.py

Issue 21134002: Add Telemetry media loop action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 3 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 | « tools/telemetry/telemetry/page/actions/loop_unittest.py ('k') | 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
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Common media action functions.""" 5 """Common media action functions."""
6 6
7 import os 7 import os
8 8
9 from telemetry.core import util 9 from telemetry.core import util
10 from telemetry.page.actions import page_action 10 from telemetry.page.actions import page_action
11 11
12 12
13 class MediaAction(page_action.PageAction): 13 class MediaAction(page_action.PageAction):
14 def __init__(self, attributes=None):
15 super(MediaAction, self).__init__(attributes)
16
17 def WillRunAction(self, page, tab): 14 def WillRunAction(self, page, tab):
18 """Loads the common media action JS code prior to running the action.""" 15 """Loads the common media action JS code prior to running the action."""
19 self.LoadJS(tab, 'media_action.js') 16 self.LoadJS(tab, 'media_action.js')
20 17
21 def RunAction(self, page, tab, previous_action): 18 def RunAction(self, page, tab, previous_action):
22 super(MediaAction, self).RunAction(page, tab, previous_action) 19 super(MediaAction, self).RunAction(page, tab, previous_action)
23 20
24 def LoadJS(self, tab, js_file_name): 21 def LoadJS(self, tab, js_file_name):
25 """Loads and executes a JS file in the tab.""" 22 """Loads and executes a JS file in the tab."""
26 with open(os.path.join(os.path.dirname(__file__), js_file_name)) as f: 23 with open(os.path.join(os.path.dirname(__file__), js_file_name)) as f:
(...skipping 10 matching lines...) Expand all
37 event_name: Name of the event to check if fired or not. 34 event_name: Name of the event to check if fired or not.
38 timeout: Timeout to check for event, throws an exception if not fired. 35 timeout: Timeout to check for event, throws an exception if not fired.
39 poll_interval: Interval to poll for event firing status. 36 poll_interval: Interval to poll for event firing status.
40 """ 37 """
41 util.WaitFor(lambda: self.HasEventCompleted(tab, selector, event_name), 38 util.WaitFor(lambda: self.HasEventCompleted(tab, selector, event_name),
42 timeout=timeout, poll_interval=poll_interval) 39 timeout=timeout, poll_interval=poll_interval)
43 40
44 def HasEventCompleted(self, tab, selector, event_name): 41 def HasEventCompleted(self, tab, selector, event_name):
45 return tab.EvaluateJavaScript( 42 return tab.EvaluateJavaScript(
46 'window.__hasEventCompleted("%s", "%s");' % (selector, event_name)) 43 'window.__hasEventCompleted("%s", "%s");' % (selector, event_name))
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page/actions/loop_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698