summaryrefslogtreecommitdiffstats
path: root/testing/firefox-ui/harness/firefox_ui_harness/runners
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/firefox-ui/harness/firefox_ui_harness/runners
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/firefox-ui/harness/firefox_ui_harness/runners')
-rw-r--r--testing/firefox-ui/harness/firefox_ui_harness/runners/__init__.py6
-rw-r--r--testing/firefox-ui/harness/firefox_ui_harness/runners/base.py45
-rw-r--r--testing/firefox-ui/harness/firefox_ui_harness/runners/update.py101
3 files changed, 152 insertions, 0 deletions
diff --git a/testing/firefox-ui/harness/firefox_ui_harness/runners/__init__.py b/testing/firefox-ui/harness/firefox_ui_harness/runners/__init__.py
new file mode 100644
index 000000000..9022a45b8
--- /dev/null
+++ b/testing/firefox-ui/harness/firefox_ui_harness/runners/__init__.py
@@ -0,0 +1,6 @@
+# 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_ui_harness.runners.base import FirefoxUITestRunner
+from firefox_ui_harness.runners.update import UpdateTestRunner
diff --git a/testing/firefox-ui/harness/firefox_ui_harness/runners/base.py b/testing/firefox-ui/harness/firefox_ui_harness/runners/base.py
new file mode 100644
index 000000000..66c2a5308
--- /dev/null
+++ b/testing/firefox-ui/harness/firefox_ui_harness/runners/base.py
@@ -0,0 +1,45 @@
+# 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/.
+
+import os
+import shutil
+import tempfile
+
+import mozfile
+import mozinfo
+
+from marionette_harness import BaseMarionetteTestRunner, MarionetteTestCase
+
+
+class FirefoxUITestRunner(BaseMarionetteTestRunner):
+
+ def __init__(self, **kwargs):
+ super(FirefoxUITestRunner, self).__init__(**kwargs)
+
+ # select the appropriate GeckoInstance
+ self.app = 'fxdesktop'
+
+ self.test_handlers = [MarionetteTestCase]
+
+ def duplicate_application(self, application_folder):
+ """Creates a copy of the specified binary."""
+
+ if self.workspace:
+ target_folder = os.path.join(self.workspace_path, 'application.copy')
+ else:
+ target_folder = tempfile.mkdtemp('.application.copy')
+
+ self.logger.info('Creating a copy of the application at "%s".' % target_folder)
+ mozfile.remove(target_folder)
+ shutil.copytree(application_folder, target_folder)
+
+ return target_folder
+
+ def get_application_folder(self, binary):
+ """Returns the directory of the application."""
+ if mozinfo.isMac:
+ end_index = binary.find('.app') + 4
+ return binary[:end_index]
+ else:
+ return os.path.dirname(binary)
diff --git a/testing/firefox-ui/harness/firefox_ui_harness/runners/update.py b/testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
new file mode 100644
index 000000000..fe4936f68
--- /dev/null
+++ b/testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
@@ -0,0 +1,101 @@
+# 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/.
+
+import sys
+
+import mozfile
+import mozinstall
+
+from firefox_ui_harness.runners import FirefoxUITestRunner
+from firefox_ui_harness.testcases import UpdateTestCase
+
+
+DEFAULT_PREFS = {
+ # Bug 1355026: Re-enable when support for the new simplified UI update is available
+ 'app.update.doorhanger': False,
+ 'app.update.log': True,
+ 'startup.homepage_override_url': 'about:blank',
+}
+
+
+class UpdateTestRunner(FirefoxUITestRunner):
+
+ def __init__(self, **kwargs):
+ super(UpdateTestRunner, self).__init__(**kwargs)
+
+ self.original_bin = self.bin
+
+ self.prefs.update(DEFAULT_PREFS)
+
+ # In case of overriding the update URL, set the appropriate preference
+ override_url = kwargs.pop('update_override_url', None)
+ if override_url:
+ self.prefs.update({'app.update.url.override': override_url})
+
+ self.run_direct_update = not kwargs.pop('update_fallback_only', False)
+ self.run_fallback_update = not kwargs.pop('update_direct_only', False)
+
+ self.test_handlers = [UpdateTestCase]
+
+ def run_tests(self, tests):
+ # Used to store the last occurred exception because we execute
+ # run_tests() multiple times
+ self.exc_info = None
+
+ failed = 0
+ source_folder = self.get_application_folder(self.original_bin)
+
+ results = {}
+
+ def _run_tests(tags):
+ application_folder = None
+
+ try:
+ # Backup current tags
+ test_tags = self.test_tags
+
+ application_folder = self.duplicate_application(source_folder)
+ self.bin = mozinstall.get_binary(application_folder, 'Firefox')
+
+ self.test_tags = tags
+ super(UpdateTestRunner, self).run_tests(tests)
+
+ except Exception:
+ self.exc_info = sys.exc_info()
+ self.logger.error('Failure during execution of the update test.',
+ exc_info=self.exc_info)
+
+ finally:
+ self.test_tags = test_tags
+
+ self.logger.info('Removing copy of the application at "%s"' % application_folder)
+ try:
+ mozfile.remove(application_folder)
+ except IOError as e:
+ self.logger.error('Cannot remove copy of application: "%s"' % str(e))
+
+ # Run direct update tests if wanted
+ if self.run_direct_update:
+ _run_tests(tags=['direct'])
+ failed += self.failed
+ results['Direct'] = False if self.failed else True
+
+ # Run fallback update tests if wanted
+ if self.run_fallback_update:
+ _run_tests(tags=['fallback'])
+ failed += self.failed
+ results['Fallback'] = False if self.failed else True
+
+ self.logger.info("Summary of update tests:")
+ for test_type, result in results.iteritems():
+ self.logger.info("\t%s update test ran and %s" %
+ (test_type, 'PASSED' if result else 'FAILED'))
+
+ # Combine failed tests for all run_test() executions
+ self.failed = failed
+
+ # If exceptions happened, re-throw the last one
+ if self.exc_info:
+ ex_type, exception, tb = self.exc_info
+ raise ex_type, exception, tb