summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-29 20:38:49 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-29 20:38:49 +0000
commit1e55a10eb4cd8a39edfb8c06c80b7c24e70d3fce (patch)
tree0c2f0b745a2f895872a3db0ec400447a65b8aa2b /chrome
parent5ef980a5d66feacec7bbdc9e3972bc56d7f3e420 (diff)
downloadchromium_src-1e55a10eb4cd8a39edfb8c06c80b7c24e70d3fce.zip
chromium_src-1e55a10eb4cd8a39edfb8c06c80b7c24e70d3fce.tar.gz
chromium_src-1e55a10eb4cd8a39edfb8c06c80b7c24e70d3fce.tar.bz2
Fix flaky notification.NotificationsTest.testCancelNotification test.
BUG=none TEST=none Review URL: http://codereview.chromium.org/4140010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/data/notifications/notification_tester.html11
-rw-r--r--chrome/test/functional/notifications.py23
2 files changed, 22 insertions, 12 deletions
diff --git a/chrome/test/data/notifications/notification_tester.html b/chrome/test/data/notifications/notification_tester.html
index 7a4aec3..0b6904c 100644
--- a/chrome/test/data/notifications/notification_tester.html
+++ b/chrome/test/data/notifications/notification_tester.html
@@ -41,16 +41,19 @@ function createHTMLNotification(contentUrl, replaceId) {
sendResultToTest(createNotificationHelper(note, replaceId));
}
-// Cancels a notification with the given id. Returns 1 on success.
+// Cancels a notification with the given id. The notification must be showing,
+// as opposed to waiting to be shown in the display queue.
+// Returns '1' on success.
function cancelNotification(id) {
if (id < 0 || id > g_notifications.length) {
var errorMsg = "Attempted to cancel notification with invalid ID.\n" +
"ID: " + id + "\n# of notifications: " + g_notifications.length;
- window.domAutomationController.send(errorMsg);
- alert(errorMsg);
+ sendResultToTest(errorMsg);
+ }
+ g_notifications[id].onclose = function() {
+ sendResultToTest(1);
}
g_notifications[id].cancel();
- sendResultToTest(1);
}
// Requests permission for this origin to create notifications.
diff --git a/chrome/test/functional/notifications.py b/chrome/test/functional/notifications.py
index 1cf414b..9d19ba0 100644
--- a/chrome/test/functional/notifications.py
+++ b/chrome/test/functional/notifications.py
@@ -224,23 +224,29 @@ class NotificationsTest(pyauto.PyUITest):
This canceling is done in the page that showed that notification and so
follows a different path than closing a notification via the UI.
- A notification can be canceled even if it has not been shown yet.
+ This function should NOT be called until |WaitForNotificationCount| has been
+ used to verify the notification is showing. This function cannot be used to
+ cancel a notification that is in the display queue.
+
This will only work if the page is navigated to |TEST_PAGE_URL|.
Args:
+ notification_id: id of the notification to cancel
tab_index: index of the tab within the given window that created the
notification
windex: index of the window
"""
- self._CallJavascriptFunc(
+ msg = self._CallJavascriptFunc(
'cancelNotification', [notification_id], tab_index, windex)
+ # '1' signifies success.
+ self.assertEquals('1', msg)
def testCreateSimpleNotification(self):
"""Creates a simple notification."""
self._AllowAllOrigins()
self.NavigateToURL(self.TEST_PAGE_URL)
self._CreateSimpleNotification('no_such_file.png', 'My Title', 'My Body')
- self.assertEquals(len(self.GetActiveNotifications()), 1)
+ self.assertEquals(1, len(self.GetActiveNotifications()))
notification = self.GetActiveNotifications()[0]
html_data = urllib.unquote(notification['content_url'])
self.assertTrue('no_such_file.png' in html_data)
@@ -252,7 +258,7 @@ class NotificationsTest(pyauto.PyUITest):
self._AllowAllOrigins()
self.NavigateToURL(self.TEST_PAGE_URL)
self._CreateHTMLNotification(self.NO_SUCH_URL)
- self.assertEquals(len(self.GetActiveNotifications()), 1)
+ self.assertEquals(1, len(self.GetActiveNotifications()))
notification = self.GetActiveNotifications()[0]
self.assertEquals(self.NO_SUCH_URL, notification['content_url'])
self.assertEquals('', notification['display_source'])
@@ -264,7 +270,7 @@ class NotificationsTest(pyauto.PyUITest):
self.NavigateToURL(self.TEST_PAGE_URL)
self._CreateHTMLNotification(self.NO_SUCH_URL)
self.CloseNotification(0)
- self.assertEquals(len(self.GetActiveNotifications()), 0)
+ self.assertFalse(self.GetActiveNotifications())
def testCancelNotification(self):
"""Creates a notification and cancels it in the origin page."""
@@ -272,15 +278,16 @@ class NotificationsTest(pyauto.PyUITest):
self.NavigateToURL(self.TEST_PAGE_URL)
note_id = self._CreateHTMLNotification(self.NO_SUCH_URL)
self.assertNotEquals(-1, note_id)
+ self.WaitForNotificationCount(1)
self._CancelNotification(note_id)
- self.assertEquals(len(self.GetActiveNotifications()), 0)
+ self.assertFalse(self.GetActiveNotifications())
def testPermissionInfobarAppears(self):
"""Requests notification privileges and verifies the infobar appears."""
self.NavigateToURL(self.TEST_PAGE_URL)
self._RequestPermission()
self.assertTrue(self.WaitForInfobarCount(1))
- self.assertEquals(len(self.GetActiveNotifications()), 0)
+ self.assertFalse(self.GetActiveNotifications())
self._VerifyInfobar('') # file:/// origins are blank
def testAllowOnPermissionInfobar(self):
@@ -288,7 +295,7 @@ class NotificationsTest(pyauto.PyUITest):
self.NavigateToURL(self.TEST_PAGE_URL)
# This notification should not be shown because we don't have permission.
self._CreateHTMLNotification(self.NO_SUCH_URL)
- self.assertEquals(len(self.GetActiveNotifications()), 0)
+ self.assertFalse(self.GetActiveNotifications())
self._RequestPermission()
self.assertTrue(self.WaitForInfobarCount(1))