Bug 1271911 - Wait for the expected notifications in test_notifications.py to avoid transient popups. r=whimboo
authorDave Hunt <dhunt@mozilla.com>
Fri, 03 Jun 2016 11:03:14 +0100
changeset 341482 465fe1502bf49a376d9237bd1438d8a729adb770
parent 341481 e845e5efd23040e5afd4d43ae6b25439ad96fbd4
child 341483 e8d8e9ee556559be8abf1944099617970d6a07ff
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1271911
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)