[Pkg-mozext-commits] [requestpolicy] 55/80: Marionette: create "ui.addons.RequestPolicy"
David Prévot
taffit at moszumanska.debian.org
Sun Jul 5 15:02:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 51ddf0991d5db86534fd621fa1946bce4c6bd082
Author: Martin Kimmerle <dev at 256k.de>
Date: Fri Jun 19 20:01:23 2015 +0200
Marionette: create "ui.addons.RequestPolicy"
This class can be used to manage RP's status conveniently.
---
tests/marionette/rp_puppeteer/ui/addons.py | 39 +++++++++++++++++++++
tests/marionette/tests/test_restartlessness.py | 47 +++++++++++---------------
2 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/tests/marionette/rp_puppeteer/ui/addons.py b/tests/marionette/rp_puppeteer/ui/addons.py
index 163ca80..67845f7 100644
--- a/tests/marionette/rp_puppeteer/ui/addons.py
+++ b/tests/marionette/rp_puppeteer/ui/addons.py
@@ -53,6 +53,45 @@ class _InstallNotifications(object):
self.wait_until_hidden(notification_id)
+class RequestPolicy(BaseLib):
+ """With this class, RequestPolicy can be installed, enabled, disabled
+ or removed.
+ """
+
+ def __init__(self, marionette_getter):
+ BaseLib.__init__(self, marionette_getter)
+
+ self.pref_welcome_win = "extensions.requestpolicy.welcomeWindowShown"
+ self.addon_id = "rpcontinued at non-amo.requestpolicy.org"
+ self.install_url = ("http://localhost/link.html?"
+ ".dist/requestpolicy-unit-testing.xpi")
+
+ self.addons = Addons(marionette_getter)
+
+ @contextmanager
+ def install_in_two_steps(self):
+ with self.addons.install_addon_in_two_steps(self.install_url):
+ yield
+
+ def install(self):
+ self.addons.install_addon(self.install_url)
+
+ def remove(self):
+ self.addons.remove_addon_by_id(self.addon_id)
+
+ def enable(self):
+ self.addons.enable_addon_by_id(self.addon_id)
+
+ def disable(self):
+ self.addons.disable_addon_by_id(self.addon_id)
+
+ def is_installed(self):
+ return self.addons.is_addon_installed(self.addon_id)
+
+ def is_enabled(self):
+ return self.addons.is_addon_enabled(self.addon_id)
+
+
class Addons(BaseLib):
"""With this class, an addon can be installed, enabled, disabled
or removed. All actions required, such as opening `about:addons`,
diff --git a/tests/marionette/tests/test_restartlessness.py b/tests/marionette/tests/test_restartlessness.py
index 062e629..a634397 100644
--- a/tests/marionette/tests/test_restartlessness.py
+++ b/tests/marionette/tests/test_restartlessness.py
@@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from firefox_ui_harness import FirefoxTestCase
-from rp_puppeteer.ui.addons import Addons
+from rp_puppeteer.ui.addons import RequestPolicy
PREF_WELCOME_WIN_SHOWN = "extensions.requestpolicy.welcomeWindowShown"
RP_ID = "rpcontinued at non-amo.requestpolicy.org"
@@ -17,33 +17,26 @@ class TestRequestPolicyRestartlessness(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
- self.addons = Addons(lambda: self.marionette)
+ self.rp = RequestPolicy(lambda: self.marionette)
def test_disable_enable(self):
- with self.addons.using_addon_list() as about_addons:
- rp = about_addons.get_addon_by_id(RP_ID)
-
- self.assertTrue(rp.is_enabled(), msg="The addon is enabled.")
- about_addons.disable_addon(rp)
- self.assertFalse(rp.is_enabled(),
- msg="The addon has been disabled.")
- about_addons.enable_addon(rp)
- self.assertTrue(rp.is_enabled(),
- msg="The addon has been re-enabled.")
+ self.assertTrue(self.rp.is_enabled(), msg="The addon is enabled.")
+ self.rp.disable()
+ self.assertFalse(self.rp.is_enabled(),
+ msg="The addon has been disabled.")
+ self.rp.enable()
+ self.assertTrue(self.rp.is_enabled(),
+ msg="The addon has been re-enabled.")
def test_uninstall_install(self):
- with self.addons.using_addon_list() as about_addons:
- def is_rp_installed():
- return about_addons.is_addon_installed(RP_ID)
-
- # remove:
- self.assertTrue(is_rp_installed(), msg="The addon is installed.")
- about_addons.remove_addon(about_addons.get_addon_by_id(RP_ID))
- self.assertFalse(is_rp_installed(),
- msg="The addon has been removed.")
-
- # re-install:
- self.prefs.set_pref(PREF_WELCOME_WIN_SHOWN, True)
- self.addons.install_addon(INSTALL_URL)
- self.assertTrue(is_rp_installed(),
- msg="The addon has been re-installed.")
+ # remove:
+ self.assertTrue(self.rp.is_installed(), msg="The addon is installed.")
+ self.rp.remove()
+ self.assertFalse(self.rp.is_installed(),
+ msg="The addon has been removed.")
+
+ # re-install:
+ self.prefs.set_pref(PREF_WELCOME_WIN_SHOWN, True)
+ self.rp.install()
+ self.assertTrue(self.rp.is_installed(),
+ msg="The addon has been re-installed.")
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list