summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib/pyauto.py
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 20:18:45 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-26 20:18:45 +0000
commitac43f703a731d232ea095c28a5367f2cdd2bd7b2 (patch)
treeac0c6932285989054cea2c5c8445f31c89364b6e /chrome/test/pyautolib/pyauto.py
parent248e199c68b9e77b20450ef6851676bd43f8394c (diff)
downloadchromium_src-ac43f703a731d232ea095c28a5367f2cdd2bd7b2.zip
chromium_src-ac43f703a731d232ea095c28a5367f2cdd2bd7b2.tar.gz
chromium_src-ac43f703a731d232ea095c28a5367f2cdd2bd7b2.tar.bz2
Add pyauto hook for HTML5 notifications, tests, and helpers.
BUG=55125 TEST=none Review URL: http://codereview.chromium.org/3822001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63935 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib/pyauto.py')
-rw-r--r--chrome/test/pyautolib/pyauto.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 02d342e..60b4728 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -188,6 +188,15 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
return 'file://' + quoted_path
@staticmethod
+ def GetFileURLForDataPath(relative_path):
+ """Get file:// url for the given path relative to the chrome test data dir.
+
+ Also quotes the url using urllib.quote().
+ """
+ return PyUITest.GetFileURLForPath(
+ os.path.join(PyUITest.DataDir(), relative_path))
+
+ @staticmethod
def IsMac():
"""Are we on Mac?"""
return 'darwin' == sys.platform
@@ -1497,6 +1506,60 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
}
return self._GetResultFromJSONRequest(cmd_dict)
+ def GetActiveNotifications(self):
+ """Gets a list of the currently active/shown HTML5 notifications.
+
+ Returns:
+ a list containing info about each active notification, with the
+ first item in the list being the notification on the bottom of the
+ notification stack. The 'content_url' key can refer to a URL or a data
+ URI.
+
+ SAMPLE:
+ [ { u'content_url': u'data:text/html;charset=utf-8,%3C!DOCTYPE%l%3E%0Atm...'
+ u'display_source': 'www.corp.google.com',
+ u'origin_url': 'http://www.corp.google.com/'},
+ { u'content_url': 'http://www.gmail.com/special_notification.html',
+ u'display_source': 'www.gmail.com',
+ u'origin_url': 'http://www.gmail.com/'}]
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'GetActiveNotifications',
+ }
+ return self._GetResultFromJSONRequest(cmd_dict)['notifications']
+
+ def CloseNotification(self, index):
+ """Closes the active HTML5 notification at the given index.
+
+ Args:
+ index: the index of the notification to close. 0 refers to the
+ notification on the bottom of the notification stack.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'CloseNotification',
+ 'index': index,
+ }
+ return self._GetResultFromJSONRequest(cmd_dict)
+
+ def WaitForNotificationCount(self, count):
+ """Waits for the number of active HTML5 notifications to reach the given
+ count.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'WaitForNotificationCount',
+ 'count': count,
+ }
+ self._GetResultFromJSONRequest(cmd_dict)
+
def FindInPage(self, search_string, forward=True,
match_case=False, find_next=False,
tab_index=0, windex=0):