Bug 1238733 - Remove dependency on Marionette harness in firefox-puppeteer; r=whimboo

BaseFirefoxTestCase inherits from unittest.TestCase and takes
advantage of super() to serve as a cooperative base class
for children of MarionetteTestCase.

This includes moving UpdateTestCase back into firefox-ui-harness

Also update external-media-tests and Firefox UI and Update tests to
use BaseFirefoxTestCase


MozReview-Commit-ID: 4gsKztEOFrt

--HG--
rename : testing/puppeteer/firefox/firefox_puppeteer/testcases/update.py => testing/firefox-ui/harness/firefox_ui_harness/testcases.py
extra : rebase_source : e3383f9633f26061af9521a719cae57db87ccf10
This commit is contained in:
Maja Frydrychowicz 2016-03-22 12:21:30 -04:00
Родитель 0e87b6fb88
Коммит b985b77b7b
44 изменённых файлов: 85 добавлений и 67 удалений

Просмотреть файл

@ -4,18 +4,18 @@
import os
from marionette import BrowserMobProxyTestCaseMixin
from marionette import BrowserMobProxyTestCaseMixin, MarionetteTestCase
from marionette_driver import Wait
from marionette_driver.errors import TimeoutException
from marionette.marionette_test import SkipTest
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_puppeteer.testcases import BaseFirefoxTestCase
from external_media_tests.utils import (timestamp_now, verbose_until)
from external_media_tests.media_utils.video_puppeteer import (playback_done, playback_started,
VideoException, VideoPuppeteer as VP)
class MediaTestCase(FirefoxTestCase):
class MediaTestCase(BaseFirefoxTestCase, MarionetteTestCase):
"""
Necessary methods for MSE playback
@ -25,7 +25,7 @@ class MediaTestCase(FirefoxTestCase):
def __init__(self, *args, **kwargs):
self.video_urls = kwargs.pop('video_urls', False)
FirefoxTestCase.__init__(self, *args, **kwargs)
super(MediaTestCase, self).__init__(*args, **kwargs)
def save_screenshot(self):
"""
@ -107,17 +107,17 @@ class NetworkBandwidthTestCase(MediaTestCase):
"""
def __init__(self, *args, **kwargs):
MediaTestCase.__init__(self, *args, **kwargs)
super(NetworkBandwidthTestCase, self).__init__(*args, **kwargs)
BrowserMobProxyTestCaseMixin.__init__(self, *args, **kwargs)
self.proxy = None
def setUp(self):
MediaTestCase.setUp(self)
super(NetworkBandwidthTestCase, self).setUp()
BrowserMobProxyTestCaseMixin.setUp(self)
self.proxy = self.create_browsermob_proxy()
def tearDown(self):
MediaTestCase.tearDown(self)
super(NetworkBandwidthTestCase, self).tearDown()
BrowserMobProxyTestCaseMixin.tearDown(self)
self.proxy = None

Просмотреть файл

@ -10,7 +10,7 @@ import mozfile
import mozinfo
from marionette import BaseMarionetteTestRunner
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class FirefoxUITestRunner(BaseMarionetteTestRunner):

Просмотреть файл

@ -7,8 +7,8 @@ import sys
import mozfile
import mozinstall
from firefox_puppeteer.testcases import UpdateTestCase
from firefox_ui_harness.runners import FirefoxUITestRunner
from firefox_ui_harness.testcases import UpdateTestCase
DEFAULT_PREFS = {

Просмотреть файл

@ -5,14 +5,20 @@
import pprint
from datetime import datetime
from marionette import MarionetteTestCase
from marionette_driver import Wait
from firefox_puppeteer.api.prefs import Preferences
from firefox_puppeteer.api.software_update import SoftwareUpdate
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_puppeteer.testcases import BaseFirefoxTestCase
from firefox_puppeteer.ui.update_wizard import UpdateWizardDialog
class FirefoxTestCase(BaseFirefoxTestCase, MarionetteTestCase):
""" Integrate MarionetteTestCase with BaseFirefoxTestCase by reordering MRO """
pass
class UpdateTestCase(FirefoxTestCase):
TIMEOUT_UPDATE_APPLY = 300
@ -29,7 +35,7 @@ class UpdateTestCase(FirefoxTestCase):
PREF_APP_UPDATE_ALTWINDOWTYPE = 'app.update.altwindowtype'
def __init__(self, *args, **kwargs):
FirefoxTestCase.__init__(self, *args, **kwargs)
super(UpdateTestCase, self).__init__(*args, **kwargs)
self.target_buildid = kwargs.pop('update_target_buildid')
self.target_version = kwargs.pop('update_target_version')
@ -43,7 +49,7 @@ class UpdateTestCase(FirefoxTestCase):
self.updates = []
def setUp(self, is_fallback=False):
FirefoxTestCase.setUp(self)
super(UpdateTestCase, self).setUp()
self.software_update = SoftwareUpdate(lambda: self.marionette)
self.download_duration = None
@ -110,7 +116,7 @@ class UpdateTestCase(FirefoxTestCase):
self.logger.info('Update test results: \n{}'.format(output))
finally:
FirefoxTestCase.tearDown(self)
super(UpdateTestCase, self).tearDown()
self.restore_config_files()

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestBrowserWindowShortcuts(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestAccessLocationBar(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestEscapeAutocomplete(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestFaviconInAutocomplete(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import By, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestStarInAutocomplete(FirefoxTestCase):

Просмотреть файл

@ -5,7 +5,7 @@
from marionette_driver import By, Wait
from marionette.marionette_test import skip_if_e10s
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
from firefox_puppeteer.ui.browser.window import BrowserWindow

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestDVCertificate(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import By
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestEnablePrivilege(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestEVCertificate(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestMixedContentPage(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import By, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestMixedScriptContentBlocking(FirefoxTestCase):

Просмотреть файл

@ -6,7 +6,7 @@ from urlparse import urlparse
from marionette_driver import expected, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestNoCertificate(FirefoxTestCase):

Просмотреть файл

@ -6,7 +6,7 @@ import time
from marionette_driver import By, expected, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSafeBrowsingNotificationBar(FirefoxTestCase):

Просмотреть файл

@ -6,7 +6,7 @@ import time
from marionette_driver import By, expected, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSafeBrowsingWarningPages(FirefoxTestCase):

Просмотреть файл

@ -7,7 +7,7 @@ import time
from marionette_driver import By, Wait
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSecurityNotification(FirefoxTestCase):

Просмотреть файл

@ -7,7 +7,7 @@ import time
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSSLDisabledErrorPage(FirefoxTestCase):

Просмотреть файл

@ -5,7 +5,7 @@
from marionette_driver import Wait
from marionette.marionette_test import skip_if_e10s
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSSLStatusAfterRestart(FirefoxTestCase):

Просмотреть файл

@ -7,7 +7,7 @@ from marionette_driver import By, expected, Wait
from marionette_driver.errors import NoAlertPresentException
from marionette_driver.marionette import Alert
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSubmitUnencryptedInfoWarning(FirefoxTestCase):

Просмотреть файл

@ -7,7 +7,7 @@ import time
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestUnknownIssuer(FirefoxTestCase):

Просмотреть файл

@ -7,7 +7,7 @@ import time
from marionette_driver import By, Wait
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestUntrustedConnectionErrorPage(FirefoxTestCase):

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestAboutWindow(FirefoxTestCase):

Просмотреть файл

@ -5,7 +5,7 @@
import mozversion
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestAppInfo(FirefoxTestCase):

Просмотреть файл

@ -6,7 +6,7 @@ from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.api.l10n import L10n
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestL10n(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver.errors import NoSuchElementException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestMenuBar(FirefoxTestCase):

Просмотреть файл

@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette_driver import By
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestPageInfoWindow(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver import By, Wait
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestPlaces(FirefoxTestCase):

Просмотреть файл

@ -4,7 +4,7 @@
from marionette_driver.errors import MarionetteException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class testPreferences(FirefoxTestCase):

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
from firefox_puppeteer.errors import NoCertificateError

Просмотреть файл

@ -4,7 +4,7 @@
import os
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
from firefox_puppeteer.api.software_update import SoftwareUpdate

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
from firefox_puppeteer.errors import NoCertificateError

Просмотреть файл

@ -5,7 +5,7 @@
from marionette_driver import expected, By, Wait
from marionette_driver.errors import NoSuchElementException
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestNavBar(FirefoxTestCase):

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
from firefox_puppeteer.ui.update_wizard import UpdateWizardDialog

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import FirefoxTestCase
from firefox_ui_harness.testcases import FirefoxTestCase
class TestSanitize(FirefoxTestCase):

Просмотреть файл

@ -7,8 +7,8 @@ from marionette_driver.errors import NoSuchWindowException, TimeoutException
import firefox_puppeteer.errors as errors
from firefox_puppeteer.testcases import FirefoxTestCase
from firefox_puppeteer.ui.windows import BaseWindow
from firefox_ui_harness.testcases import FirefoxTestCase
class TestWindows(FirefoxTestCase):

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import UpdateTestCase
from firefox_ui_harness.testcases import UpdateTestCase
class TestDirectUpdate(UpdateTestCase):

Просмотреть файл

@ -2,7 +2,7 @@
# 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.testcases import UpdateTestCase
from firefox_ui_harness.testcases import UpdateTestCase
class TestFallbackUpdate(UpdateTestCase):

Просмотреть файл

@ -15,8 +15,11 @@ __version__ = '3.2.0'
class Puppeteer(object):
"""The puppeteer class is used to expose libraries to test cases.
example:
`class MyTestCase(MarionetteTestCase, Puppeteer)`
Each library can be referenced by its puppeteer name as a member of a
FirefoxTestCase instance. For example, from within a test method, the
the TestCase instance. For example, from within a test method, the
"current_window" member of the "Browser" class can be accessed via
"self.browser.current_window".
"""
@ -27,9 +30,6 @@ class Puppeteer(object):
def get_marionette(self):
return self.marionette
def set_marionette(self, marionette):
self.marionette = marionette
@use_class_as_property('api.appinfo.AppInfo')
def appinfo(self):
"""

Просмотреть файл

@ -2,5 +2,4 @@
# 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.testcases.base import FirefoxTestCase
from firefox_puppeteer.testcases.update import UpdateTestCase
from firefox_puppeteer.testcases.base import BaseFirefoxTestCase

Просмотреть файл

@ -2,20 +2,37 @@
# 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 import MarionetteTestCase
import unittest
from firefox_puppeteer import Puppeteer
from firefox_puppeteer.ui.browser.window import BrowserWindow
class FirefoxTestCase(MarionetteTestCase, Puppeteer):
"""Base testcase class for Firefox Desktop tests.
class BaseFirefoxTestCase(unittest.TestCase, Puppeteer):
"""Base TestCase class for Firefox Desktop tests.
This is designed to enhance MarionetteTestCase by inserting the Puppeteer
mixin class (so Firefox specific API modules are exposed to test scope) and
providing common set-up and tear-down code for Firefox tests.
Child classes are expected to also subclass MarionetteTestCase such that
MarionetteTestCase is inserted into the MRO after FirefoxTestCase but before
unittest.TestCase.
example:
`class AwesomeTestCase(FirefoxTestCase, MarionetteTestCase)`
The key role of MarionetteTestCase is to set self.marionette appropriately
in `__init__`. Any TestCase class that satisfies this requirement is
compatible with this class.
If you're extending the inheritance tree further to make specialized
TestCases, favour the use of super() as opposed to explicit calls to a
parent class.
It enhances the Marionette testcase by inserting the Puppeteer mixin class,
so Firefox specific API modules are exposed to test scope.
"""
def __init__(self, *args, **kwargs):
MarionetteTestCase.__init__(self, *args, **kwargs)
super(BaseFirefoxTestCase, self).__init__(*args, **kwargs)
def _check_and_fix_leaked_handles(self):
handle_count = len(self.marionette.window_handles)
@ -63,8 +80,7 @@ class FirefoxTestCase(MarionetteTestCase, Puppeteer):
self.browser = self.windows.switch_to(lambda win: type(win) is BrowserWindow)
def setUp(self, *args, **kwargs):
MarionetteTestCase.setUp(self, *args, **kwargs)
Puppeteer.set_marionette(self, self.marionette)
super(BaseFirefoxTestCase, self).setUp(*args, **kwargs)
self._start_handle_count = len(self.marionette.window_handles)
self.marionette.set_context('chrome')
@ -86,4 +102,4 @@ class FirefoxTestCase(MarionetteTestCase, Puppeteer):
# in a state that is more inconsistent than necessary.
self._check_and_fix_leaked_handles()
finally:
MarionetteTestCase.tearDown(self, *args, **kwargs)
super(BaseFirefoxTestCase, self).tearDown(*args, **kwargs)

Просмотреть файл

@ -1,5 +1,2 @@
# The following line can be removed once testcases are no longer part of the puppeteer module.
marionette-client >= 2.2.0
marionette-driver >= 1.3.0
mozinfo >= 0.8