Bug 1240991 - Don't have a custom __init__ in FirefoxMediaHarness because bug 1227918 is fixed. r?maja_zf draft
authorSyd Polk <spolk@mozilla.com>
Thu, 21 Jan 2016 16:20:07 -0600
changeset 324102 7bbbab7058df27c1c98ca035785936aae6d6d3e6
parent 324101 1fb1653d38dabd0990d8bc3ef54d4378fde0290a
child 513325 7e1b2511a113f1856f86d60d147dd45b20e0bb67
push id9844
push userspolk@mozilla.com
push dateThu, 21 Jan 2016 22:33:49 +0000
reviewersmaja_zf
bugs1240991, 1227918
milestone46.0a1
Bug 1240991 - Don't have a custom __init__ in FirefoxMediaHarness because bug 1227918 is fixed. r?maja_zf
dom/media/test/external/external_media_harness/runtests.py
dom/media/test/external/harness/runtests.py
dom/media/test/external/requirements.txt
dom/media/test/external/setup.py
new file mode 100644
--- /dev/null
+++ b/dom/media/test/external/external_media_harness/runtests.py
@@ -0,0 +1,97 @@
+# 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 manifestparser import read_ini
+import os
+import sys
+
+from marionette import BaseMarionetteTestRunner, BaseMarionetteArguments
+from marionette.runner import BrowserMobProxyArguments
+from marionette.runtests import MarionetteHarness, cli as mn_cli
+import mozlog
+
+import external_media_tests
+from testcase import MediaTestCase
+from external_media_tests.media_utils.video_puppeteer import debug_script
+
+
+class MediaTestArgumentsBase(object):
+    name = 'Firefox Media Tests'
+    args = [
+        [['--urls'], {
+            'help': 'ini file of urls to make available to all tests',
+            'default': os.path.join(external_media_tests.urls, 'default.ini'),
+        }],
+    ]
+
+    def verify_usage_handler(self, args):
+        if args.urls:
+           if not os.path.isfile(args.urls):
+               raise ValueError('--urls must provide a path to an ini file')
+           else:
+               path = os.path.abspath(args.urls)
+               args.video_urls = MediaTestArgumentsBase.get_urls(path)
+
+    def parse_args_handler(self, args):
+        if not args.tests:
+           args.tests = [external_media_tests.manifest]
+
+
+    @staticmethod
+    def get_urls(manifest):
+        with open(manifest, 'r'):
+            return [line[0] for line in read_ini(manifest)]
+
+
+class MediaTestArguments(BaseMarionetteArguments):
+    def __init__(self, **kwargs):
+        BaseMarionetteArguments.__init__(self, **kwargs)
+        self.register_argument_container(MediaTestArgumentsBase())
+        self.register_argument_container(BrowserMobProxyArguments())
+
+
+class MediaTestRunner(BaseMarionetteTestRunner):
+    def __init__(self, **kwargs):
+        BaseMarionetteTestRunner.__init__(self, **kwargs)
+        if not self.server_root:
+            self.server_root = external_media_tests.resources
+        # pick up prefs from marionette_driver.geckoinstance.DesktopInstance
+        self.app = 'fxdesktop'
+        self.test_handlers = [MediaTestCase]
+
+        # Used in HTML report (--log-html)
+        def gather_media_debug(test, status):
+            rv = {}
+            marionette = test._marionette_weakref()
+
+            if marionette.session is not None:
+                try:
+                    with marionette.using_context(marionette.CONTEXT_CHROME):
+                        debug_lines = marionette.execute_script(debug_script)
+                        if debug_lines:
+                            name = 'mozMediaSourceObject.mozDebugReaderData'
+                            rv[name] = '\n'.join(debug_lines)
+                        else:
+                            logger = mozlog.get_default_logger()
+                            logger.info('No data available about '
+                                        'mozMediaSourceObject')
+                except:
+                    logger = mozlog.get_default_logger()
+                    logger.warning('Failed to gather test failure media debug',
+                                   exc_info=True)
+            return rv
+
+        self.result_callbacks.append(gather_media_debug)
+
+
+class FirefoxMediaHarness(MarionetteHarness):
+    def parse_args(self, *args, **kwargs):
+        return MarionetteHarness.parse_args(self, {'mach': sys.stdout})
+
+
+def cli():
+    mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness)
+
+if __name__ == '__main__':
+    cli()
--- a/dom/media/test/external/harness/runtests.py
+++ b/dom/media/test/external/harness/runtests.py
@@ -81,27 +81,16 @@ class MediaTestRunner(BaseMarionetteTest
                     logger.warning('Failed to gather test failure media debug',
                                    exc_info=True)
             return rv
 
         self.result_callbacks.append(gather_media_debug)
 
 
 class FirefoxMediaHarness(MarionetteHarness):
-    def __init__(self,
-             runner_class=MediaTestRunner,
-             parser_class=MediaTestArguments):
-        # workaround until next marionette-client release - Bug 1227918
-        try:
-            MarionetteHarness.__init__(self, runner_class, parser_class)
-        except Exception:
-            logger = mozlog.commandline.setup_logging('Media-test harness', {})
-            logger.error('Failure setting up harness', exc_info=True)
-            raise
-
     def parse_args(self, *args, **kwargs):
         return MarionetteHarness.parse_args(self, {'mach': sys.stdout})
 
 
 def cli():
     mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness)
 
 if __name__ == '__main__':
--- a/dom/media/test/external/requirements.txt
+++ b/dom/media/test/external/requirements.txt
@@ -1,22 +1,24 @@
-browsermob-proxy==0.6.0
+browsermob-proxy==0.7.1
 manifestparser==1.1
 mozcrash==0.16
-mozdevice==0.46
+mozdevice==0.48
 mozfile==1.2
 mozhttpd==0.7
-mozinfo==0.8
+mozinfo==0.9
 # optional - mozharness install step
 mozInstall==1.12
-mozlog==3.0
+mozlog==3.1
 moznetwork==0.27
 mozprocess==0.22
-mozprofile==0.27
-mozrunner==6.9
+mozprofile==0.28
+mozrunner==6.11
 moztest==0.7
 mozversion==1.4
-marionette-client == 2.0.0
-marionette-driver == 1.1.1
+wptserve==1.3.0
+marionette-client == 2.1.0
+marionette-driver == 1.2.0
+marionette-transport == 1.1.0
 firefox-puppeteer==3.1.0
 
 # Install the firefox media tests package
 ./
--- a/dom/media/test/external/setup.py
+++ b/dom/media/test/external/setup.py
@@ -2,19 +2,19 @@
 # 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 setuptools import setup, find_packages
 
 PACKAGE_VERSION = '1.0'
 
 deps = [
-    'marionette-client == 2.0.0',
-    'marionette-driver == 1.1.1',
-    'mozlog == 3.0',
+    'marionette-client == 2.1.0',
+    'marionette-driver == 1.2.0',
+    'mozlog == 3.1',
     'manifestparser == 1.1',
     'firefox-puppeteer >= 3.1.0, <4.0.0',
 ]
 
 setup(name='external-media-tests',
       version=PACKAGE_VERSION,
       description=('A collection of Mozilla Firefox media playback tests run '
                    'with Marionette'),