Bug 1143928 - Refactor firefox puppeteer Deck and Panel classes to reduce code duplication. r=whimboo
authorHenrik Skupin <mail@hskupin.info>
Tue, 01 Mar 2016 03:23:00 +0100
changeset 324693 a4315513655cd5499289311152d3cdc65a2561d6
parent 324692 52f996dacd8cc8c0465d52b30d3c67f7d667c73b
child 324694 3f9ad35634177abfa44b4ab701487c1d3f67f527
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1143928
milestone47.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 1143928 - Refactor firefox puppeteer Deck and Panel classes to reduce code duplication. r=whimboo MozReview-Commit-ID: 4j3EzKJ47nm
testing/puppeteer/firefox/docs/index.rst
testing/puppeteer/firefox/docs/ui/deck.rst
testing/puppeteer/firefox/docs/ui/pageinfo/window.rst
testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/deck.py
testing/puppeteer/firefox/firefox_puppeteer/ui/deck.py
testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/deck.py
testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
--- a/testing/puppeteer/firefox/docs/index.rst
+++ b/testing/puppeteer/firefox/docs/index.rst
@@ -30,16 +30,17 @@ Libraries
 ---------
 
 The following libraries are currently implemented. More will be added in the
 future. Each library is available from an instance of the FirefoxTestCase class.
 
 .. toctree::
 
    ui/about_window/window
+   ui/deck
    ui/menu
    ui/pageinfo/window
    ui/browser/tabbar
    ui/browser/toolbars
    ui/browser/window
    ui/update_wizard/dialog
    ui/windows
    api/appinfo
new file mode 100644
--- /dev/null
+++ b/testing/puppeteer/firefox/docs/ui/deck.rst
@@ -0,0 +1,9 @@
+Deck
+=====
+
+Panel
+------
+
+.. autoclass:: firefox_puppeteer.ui.deck.Panel
+   :members:
+   :inherited-members:
--- a/testing/puppeteer/firefox/docs/ui/pageinfo/window.rst
+++ b/testing/puppeteer/firefox/docs/ui/pageinfo/window.rst
@@ -10,14 +10,21 @@ PageInfoWindow
 
 Deck
 ----
 
 .. autoclass:: firefox_puppeteer.ui.pageinfo.deck.Deck
    :members:
    :inherited-members:
 
+PageInfoPanel
+-------------
+
+.. autoclass:: firefox_puppeteer.ui.pageinfo.deck.PageInfoPanel
+   :members:
+   :inherited-members:
+
 SecurityPanel
 -------------
 
 .. autoclass:: firefox_puppeteer.ui.pageinfo.deck.SecurityPanel
    :members:
    :inherited-members:
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/deck.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/about_window/deck.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from marionette_driver import By
 
 from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.deck import Panel
 
 
 class Deck(UIBaseLib):
 
     def _create_panel_for_id(self, panel_id):
         """Creates an instance of :class:`Panel` for the specified panel id.
 
         :param panel_id: The ID of the panel to create an instance of.
@@ -128,28 +129,16 @@ class Deck(UIBaseLib):
     def selected_panel(self):
         """A :class:`Panel` instance of the currently selected panel.
 
         :returns: :class:`Panel` instance.
         """
         return self.panels[self.selected_index]
 
 
-class Panel(UIBaseLib):
-
-    def __eq__(self, other):
-        return self.element.get_attribute('id') == other.element.get_attribute('id')
-
-    def __ne__(self, other):
-        return self.element.get_attribute('id') != other.element.get_attribute('id')
-
-    def __str__(self):
-        return self.element.get_attribute('id')
-
-
 class ApplyBillboardPanel(Panel):
 
     @property
     def button(self):
         """The DOM element which represents the Apply Billboard button.
 
         :returns: Reference to the button element.
         """
new file mode 100644
--- /dev/null
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/deck.py
@@ -0,0 +1,17 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from firefox_puppeteer.ui_base_lib import UIBaseLib
+
+
+class Panel(UIBaseLib):
+
+    def __eq__(self, other):
+        return self.element.get_attribute('id') == other.element.get_attribute('id')
+
+    def __ne__(self, other):
+        return self.element.get_attribute('id') != other.element.get_attribute('id')
+
+    def __str__(self):
+        return self.element.get_attribute('id')
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/deck.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/deck.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from marionette_driver import By, Wait
 
 from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.deck import Panel
 
 
 class Deck(UIBaseLib):
 
     def _create_panel_for_id(self, panel_id):
         """Creates an instance of :class:`Panel` for the specified panel id.
 
         :param panel_id: The ID of the panel to create an instance of.
@@ -117,54 +118,45 @@ class Deck(UIBaseLib):
         :returns: :class:`Panel` instance of the selected panel.
         """
         panel.tab.click()
         Wait(self.marionette).until(lambda _: self.selected_panel == panel)
 
         return panel
 
 
-class Panel(UIBaseLib):
-
-    def __eq__(self, other):
-        return self.element.get_attribute('id') == other.element.get_attribute('id')
-
-    def __ne__(self, other):
-        return self.element.get_attribute('id') != other.element.get_attribute('id')
-
-    def __str__(self):
-        return self.element.get_attribute('id')
+class PageInfoPanel(Panel):
 
     @property
     def tab(self):
         """The DOM element which represents the corresponding tab element at the top.
 
         :returns: Reference to the tab element.
         """
         name = self.element.get_attribute('id').split('Panel')[0]
         return self.window.window_element.find_element(By.ID, name + 'Tab')
 
 
-class FeedPanel(Panel):
+class FeedPanel(PageInfoPanel):
     pass
 
 
-class GeneralPanel(Panel):
+class GeneralPanel(PageInfoPanel):
     pass
 
 
-class MediaPanel(Panel):
+class MediaPanel(PageInfoPanel):
     pass
 
 
-class PermissionsPanel(Panel):
+class PermissionsPanel(PageInfoPanel):
     pass
 
 
-class SecurityPanel(Panel):
+class SecurityPanel(PageInfoPanel):
 
     @property
     def domain(self):
         """The DOM element which represents the domain textbox.
 
         :returns: Reference to the textbox element.
         """
         return self.element.find_element(By.ID, 'security-identity-domain-value')
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/update_wizard/wizard.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from marionette_driver import By, Wait
 
 from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.deck import Panel
 
 
 class Wizard(UIBaseLib):
 
     def __init__(self, *args, **kwargs):
         UIBaseLib.__init__(self, *args, **kwargs)
 
         Wait(self.marionette).until(lambda _: self.selected_panel)
@@ -244,25 +245,16 @@ class Wizard(UIBaseLib):
     def selected_panel(self):
         """A :class:`Panel` instance of the currently selected panel.
 
         :returns: :class:`Panel` instance.
         """
         return self._create_panel_for_id(self.element.get_attribute('currentpageid'))
 
 
-class Panel(UIBaseLib):
-
-    def __eq__(self, other):
-        return self.element.get_attribute('id') == other.element.get_attribute('id')
-
-    def __ne__(self, other):
-        return self.element.get_attribute('id') != other.element.get_attribute('id')
-
-
 class CheckingPanel(Panel):
 
     @property
     def progress(self):
         """The DOM element which represents the progress meter.
 
         :returns: Reference to the progress element.
         """