Bug 1271911 - Wait for the expected notifications in test_notifications.py to avoid transient popups. r?whimboo draft
authorDave Hunt <dhunt@mozilla.com>
Fri, 03 Jun 2016 11:03:14 +0100
changeset 375056 94bd10920434ad0ddde2ebb5c859dd20fe37e169
parent 375055 344f8fa299c63420f333b3f121b84c0cf1059d24
child 522746 09db1a5a65e3ab234610ea2b974c4c31c1c6142f
push id20149
push userdhunt@mozilla.com
push dateFri, 03 Jun 2016 10:07:55 +0000
reviewerswhimboo
bugs1271911
milestone49.0a1
Bug 1271911 - Wait for the expected notifications in test_notifications.py to avoid transient popups. r?whimboo MozReview-Commit-ID: ICsIE1wZctR
testing/firefox-ui/tests/puppeteer/test_notifications.py
--- a/testing/firefox-ui/tests/puppeteer/test_notifications.py
+++ b/testing/firefox-ui/tests/puppeteer/test_notifications.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from marionette_driver import By
 from marionette_driver.errors import TimeoutException
 
 from firefox_ui_harness.testcases import FirefoxTestCase
 from firefox_puppeteer.ui.browser.notifications import (
     AddOnInstallFailedNotification,
+    AddOnInstallConfirmationNotification
 )
 
 
 class TestNotifications(FirefoxTestCase):
 
     def setUp(self):
         FirefoxTestCase.setUp(self)
 
@@ -28,17 +29,17 @@ class TestNotifications(FirefoxTestCase)
             if self.browser.notification:
                 self.browser.notification.close(force=True)
         finally:
             FirefoxTestCase.tearDown(self)
 
     def test_open_close_notification(self):
         """Trigger and dismiss a notification"""
         self.assertIsNone(self.browser.notification)
-        self.trigger_addon_notification('restartless_addon_unsigned.xpi')
+        self.trigger_addon_notification('restartless_addon_signed.xpi')
         self.browser.notification.close()
         self.assertIsNone(self.browser.notification)
 
     def test_wait_for_notification_timeout(self):
         """Wait for a notification when one is not shown"""
         message = 'No notification was shown'
         with self.assertRaisesRegexp(TimeoutException, message):
             self.browser.wait_for_notification()
@@ -47,34 +48,32 @@ class TestNotifications(FirefoxTestCase)
         """Wait for a notification when one is not shown"""
         message = 'AddOnInstallFailedNotification was not shown'
         with self.assertRaisesRegexp(TimeoutException, message):
             self.browser.wait_for_notification(AddOnInstallFailedNotification)
 
     def test_wait_for_no_notification_timeout(self):
         """Wait for no notification when one is shown"""
         message = 'Unexpected notification shown'
-        self.trigger_addon_notification('restartless_addon_unsigned.xpi')
+        self.trigger_addon_notification('restartless_addon_signed.xpi')
         with self.assertRaisesRegexp(TimeoutException, message):
             self.browser.wait_for_notification(None)
 
     def test_notification_with_origin(self):
         """Trigger a notification with an origin"""
         self.trigger_addon_notification('restartless_addon_signed.xpi')
         self.assertIn(self.browser.notification.origin, self.marionette.baseurl)
         self.assertIsNotNone(self.browser.notification.label)
-        self.browser.notification.close()
 
     def test_addon_install_failed_notification(self):
         """Trigger add-on blocked notification using an unsigned add-on"""
         # Ensure that installing unsigned extensions will fail
         self.prefs.set_pref('xpinstall.signatures.required', True)
 
-        self.trigger_addon_notification('restartless_addon_unsigned.xpi')
-        self.assertIsInstance(self.browser.notification,
-                              AddOnInstallFailedNotification)
-        self.browser.notification.close()
+        self.trigger_addon_notification(
+            'restartless_addon_unsigned.xpi',
+            notification=AddOnInstallFailedNotification)
 
-    def trigger_addon_notification(self, addon):
+    def trigger_addon_notification(self, addon, notification=AddOnInstallConfirmationNotification):
         with self.marionette.using_context('content'):
             self.marionette.navigate(self.addons_url)
             self.marionette.find_element(By.LINK_TEXT, addon).click()
-        self.browser.wait_for_notification()
+        self.browser.wait_for_notification(notification)