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

Unified Diff: tools/telemetry/telemetry/wait_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/util_unittest.py ('k') | tools/telemetry/telemetry/wait_action_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/wait_action.py
diff --git a/tools/telemetry/telemetry/wait_action.py b/tools/telemetry/telemetry/wait_action.py
deleted file mode 100644
index b078f7e91f3abc5c7b3381c6e4f4ac619c8b9b1d..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/wait_action.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import time
-
-from telemetry import page_action
-from telemetry import util
-
-class WaitAction(page_action.PageAction):
- DEFAULT_TIMEOUT = 60
-
- def __init__(self, attributes=None):
- super(WaitAction, self).__init__(attributes)
-
- def RunsPreviousAction(self):
- assert hasattr(self, 'condition')
- return self.condition == 'navigate' or self.condition == 'href_change'
-
- def RunAction(self, page, tab, previous_action):
- assert hasattr(self, 'condition')
-
- if self.condition == 'duration':
- assert hasattr(self, 'seconds')
- time.sleep(self.seconds)
-
- elif self.condition == 'navigate':
- if not previous_action:
- raise page_action.PageActionFailed('You need to perform an action '
- 'before waiting for navigate.')
- previous_action.WillRunAction()
- action_to_perform = lambda: previous_action.RunAction(page, tab, None)
- tab.PerformActionAndWaitForNavigate(action_to_perform)
-
- elif self.condition == 'href_change':
- if not previous_action:
- raise page_action.PageActionFailed('You need to perform an action '
- 'before waiting for a href change.')
- previous_action.WillRunAction()
- old_url = tab.EvaluateJavaScript('document.location.href')
- previous_action.RunAction(page, tab, None)
- util.WaitFor(lambda: tab.EvaluateJavaScript(
- 'document.location.href') != old_url, self.DEFAULT_TIMEOUT)
-
- elif self.condition == 'element':
- assert hasattr(self, 'text') or hasattr(self, 'selector')
- if self.text:
- callback_code = 'function(element) { return element != null; }'
- util.WaitFor(
- lambda: util.FindElementAndPerformAction(
- tab, self.text, callback_code), self.DEFAULT_TIMEOUT)
- elif self.selector:
- util.WaitFor(lambda: tab.EvaluateJavaScript(
- 'document.querySelector("%s") != null' % self.selector),
- self.DEFAULT_TIMEOUT)
-
- elif self.condition == 'javascript':
- assert hasattr(self, 'javascript')
- util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript),
- self.DEFAULT_TIMEOUT)
« no previous file with comments | « tools/telemetry/telemetry/util_unittest.py ('k') | tools/telemetry/telemetry/wait_action_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698