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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 9372120: Implementation of AutomationEventQueue and associated framework to support generic non-blocking aut… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made CompareEventId predicate class private to AutomationEventQueue. Created 8 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
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 793dd95b33db6998dca35c275dd44bb104e626b8..45fbe0c9f862e6cc15dc4c9e7fbd1743adc66f75 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -2798,6 +2798,102 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
return self._GetResultFromJSONRequest(cmd_dict, windex=windex,
timeout=timeout)
+ def AddDomRaisedEventObserver(self, event_name='', tab_index=0, windex=0,
+ frame_xpath=''):
+ """Adds a DomRaisedEventObserver associated with the AutomationEventQueue.
+
+ Args:
+ event_name: The raised event name to watch for. By default all raised
+ events are observed.
+ tab_index: index of the tab.
+ windex: index of the window.
+ frame_xpath: XPath of the frame to execute the script. Default is no
+ frame. Example: '//frames[1]'.
+
+ Returns:
+ The id of the created observer, which can be used with GetNextEvent(id)
+ and RemoveEventObserver(id).
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ # TODO(craigdh): Add a corresponding method for extension views.
+ # TODO(craigdh): Add documentation for raising an event once it has been
+ # implemented.
+ cmd_dict = {
+ 'command': 'AddDomRaisedEventObserver',
+ 'event_name': event_name,
+ 'tab_index' : tab_index,
+ 'windex' : windex,
+ 'frame_xpath' : frame_xpath,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict,
+ windex=windex)['observer_id']
Nirnimesh 2012/03/01 10:34:12 You've added AddDomRaisedEventObserver to handler_
craigdh 2012/03/01 21:34:18 Fixed. This was left over from a time when creatin
+
+ def GetNextEvent(self, observer_id=-1, blocking=True, timeout=-1):
+ """Waits for an observed event to occur.
+
+ The returned event is removed from the Event Queue. If there is already a
+ matching event in the queue it is returned immediately, otherwise the call
+ blocks until a matching event occurs. If blocking is disabled and no
+ matching event is in the queue this function will immediately return None.
+
+ Args:
+ observer_id: The id of the observer to wait for, matches any event by
+ default.
+ blocking: If True waits until there is a matching event in the queue,
+ if False and there is no event waiting in the queue returns None
+ immediately.
+ timeout: Time to wait for a matching event, defaults to
+ self.large_test_timeout_ms().
Nirnimesh 2012/03/01 10:34:12 fix comment. defaults to automation timeout
craigdh 2012/03/01 21:34:18 Done.
+
+ Returns:
+ Event response dictionary, or None if blocking is disabled and there is no
+ matching event in the queue.
+ SAMPLE:
+ { 'observer_id': 1,
+ 'name': 'login completed',
+ 'type': 'raised_event'}
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'GetNextEvent',
+ 'observer_id' : observer_id,
+ 'blocking' : blocking,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None,
+ timeout=timeout)
+
+ def RemoveEventObserver(self, observer_id):
+ """Removes an Event Observer from the AutomationEventQueue.
+
+ Expects a valid observer_id.
+
+ Args:
+ observer_id: The id of the observer to remove.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'RemoveEventObserver',
+ 'observer_id' : observer_id,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None)
+
+ def ClearEventQueue(self):
+ """Removes all events currently in the AutomationEventQueue.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'ClearEventQueue',
+ }
+ return self._GetResultFromJSONRequest(cmd_dict, windex=None)
+
def ExecuteJavascript(self, js, tab_index=0, windex=0, frame_xpath=''):
"""Executes a script in the specified frame of a tab.
« chrome/browser/automation/testing_automation_provider.cc ('K') | « chrome/test/functional/apptest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698