Bug 1313312 - Refactor puppeteer module for UI base lib classes.
MozReview-Commit-ID: Kd1VHzCnT2X
--- a/testing/puppeteer/firefox/firefox_puppeteer/__init__.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/__init__.py
@@ -1,14 +1,12 @@
# 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.marionette import HTMLElement
-
from decorators import use_class_as_property
__version__ = '52.0.0'
class Puppeteer(object):
"""The puppeteer class is used to expose libraries to test cases.
@@ -85,28 +83,8 @@ class Puppeteer(object):
@use_class_as_property('ui.windows.Windows')
def windows(self):
"""
Provides shortcuts to the top-level windows.
See the :class:`~ui.window.Windows` reference.
"""
-
-
-class DOMElement(HTMLElement):
- """
- Class that inherits from HTMLElement and provides a way for subclasses to
- expose new api's.
- """
-
- def __new__(cls, element):
- instance = object.__new__(cls)
- instance.__dict__ = element.__dict__.copy()
- setattr(instance, 'inner', element)
-
- return instance
-
- def __init__(self, element):
- pass
-
- def get_marionette(self):
- return self.marionette
--- 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,15 @@
# 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.base 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.
rename from testing/puppeteer/firefox/firefox_puppeteer/ui_base_lib.py
rename to testing/puppeteer/firefox/firefox_puppeteer/ui/base.py
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui_base_lib.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/base.py
@@ -30,8 +30,28 @@ class UIBaseLib(BaseLib):
@property
def window(self):
"""Returns the reference to the chrome window.
:returns: :class:`BaseWindow` instance of the chrome window.
"""
return self._window
+
+
+class DOMElement(HTMLElement):
+ """
+ Class that inherits from HTMLElement and provides a way for subclasses to
+ expose new api's.
+ """
+
+ def __new__(cls, element):
+ instance = object.__new__(cls)
+ instance.__dict__ = element.__dict__.copy()
+ setattr(instance, 'inner', element)
+
+ return instance
+
+ def __init__(self, element):
+ pass
+
+ def get_marionette(self):
+ return self.marionette
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/notifications.py
@@ -1,17 +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 abc import ABCMeta
from marionette_driver import By
-from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.base import UIBaseLib
class BaseNotification(UIBaseLib):
"""Abstract base class for any kind of notification."""
__metaclass__ = ABCMeta
@property
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -5,19 +5,18 @@
from marionette_driver import (
By, Wait
)
from marionette_driver.errors import NoSuchElementException
import firefox_puppeteer.errors as errors
-from firefox_puppeteer import DOMElement
from firefox_puppeteer.api.security import Security
-from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.base import UIBaseLib, DOMElement
class TabBar(UIBaseLib):
"""Wraps the tabs toolbar DOM element inside a browser window."""
# Properties for visual elements of the tabs toolbar #
@property
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -1,15 +1,15 @@
# 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, keys, Wait
-from firefox_puppeteer.ui_base_lib import UIBaseLib
+from firefox_puppeteer.ui.base import UIBaseLib
class NavBar(UIBaseLib):
"""Provides access to the DOM elements contained in the
navigation bar as well as the location bar."""
def __init__(self, *args, **kwargs):
UIBaseLib.__init__(self, *args, **kwargs)
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/deck.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/deck.py
@@ -1,13 +1,13 @@
# 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
+from firefox_puppeteer.ui.base import UIBaseLib
class Panel(UIBaseLib):
def __eq__(self, other):
return self.element.get_attribute('id') == other.element.get_attribute('id')
def __ne__(self, other):
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/menu.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/menu.py
@@ -1,17 +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 marionette_driver import By
from marionette_driver.errors import NoSuchElementException
-from firefox_puppeteer import DOMElement
from firefox_puppeteer.base import BaseLib
+from firefox_puppeteer.ui.base import DOMElement
class MenuBar(BaseLib):
"""Wraps the menubar DOM element inside a browser window."""
@property
def menus(self):
"""A list of :class:`MenuElement` instances corresponding to
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/deck.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/pageinfo/deck.py
@@ -1,15 +1,15 @@
# 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.base 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.
--- 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,15 @@
# 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.base import UIBaseLib
from firefox_puppeteer.ui.deck import Panel
class Wizard(UIBaseLib):
def __init__(self, *args, **kwargs):
UIBaseLib.__init__(self, *args, **kwargs)