Bug 1259249 Make sure that EME system is setup before running tests. r?SingingTree, r?maja_zf
MozReview-Commit-ID: 6I4uVo5Gld7
--- a/dom/media/test/external/external_media_harness/testcase.py
+++ b/dom/media/test/external/external_media_harness/testcase.py
@@ -1,12 +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/.
+import re
import os
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 BaseFirefoxTestCase
@@ -131,17 +132,18 @@ class NetworkBandwidthTestCase(MediaTest
video = VP(self.marionette, url,
stall_wait_time=60,
set_duration=60)
self.run_playback(video)
class VideoPlaybackTestsMixin(object):
- """ Test MSE playback in HTML5 video element.
+ """
+ Test MSE playback in HTML5 video element.
These tests should pass on any site where a single video element plays
upon loading and is uninterrupted (by ads, for example).
This tests both starting videos and performing partial playback at one
minute each, and is the test that should be run frequently in automation.
"""
@@ -171,8 +173,133 @@ class VideoPlaybackTestsMixin(object):
Test to make sure that playback of 60 seconds works for each video.
"""
with self.marionette.using_context('content'):
for url in self.video_urls:
video = VP(self.marionette, url,
stall_wait_time=10,
set_duration=60)
self.run_playback(video)
+
+
+class NetworkBandwidthTestsMixin(object):
+
+ """
+ Test video urls with various bandwidth settings.
+ """
+
+ def test_playback_limiting_bandwidth_250(self):
+ self.proxy.limits({'downstream_kbps': 250})
+ self.run_videos()
+
+ def test_playback_limiting_bandwidth_500(self):
+ self.proxy.limits({'downstream_kbps': 500})
+ self.run_videos()
+
+ def test_playback_limiting_bandwidth_1000(self):
+ self.proxy.limits({'downstream_kbps': 1000})
+ self.run_videos()
+
+
+reset_adobe_gmp_script = """
+navigator.requestMediaKeySystemAccess('com.adobe.primetime',
+[{initDataType: 'cenc'}]).then(
+ function(access) {
+ marionetteScriptFinished('success');
+ },
+ function(ex) {
+ marionetteScriptFinished(ex);
+ }
+);
+"""
+
+
+class EMESetupMixin(object):
+
+ """
+ An object that needs to use the Adobe GMP system must inherit from this
+ class, and then call check_eme_system() to insure that everything is
+ setup correctly.
+ """
+
+ version_needs_reset = True
+
+ def check_eme_system(self):
+ """
+ Download the most current version of the Adobe GMP Plugin. Verify
+ that all MSE and EME prefs are set correctly. Raises if things
+ are not OK.
+ """
+ self.set_eme_prefs()
+ self.reset_GMP_version()
+ assert(self.check_eme_prefs())
+
+ def set_eme_prefs(self):
+ with self.marionette.using_context('chrome'):
+ # https://bugzilla.mozilla.org/show_bug.cgi?id=1187471#c28
+ # 2015-09-28 cpearce says this is no longer necessary, but in case
+ # we are working with older firefoxes...
+ self.prefs.set_pref('media.gmp.trial-create.enabled', False)
+
+ def reset_GMP_version(self):
+ if EMESetupMixin.version_needs_reset:
+ with self.marionette.using_context('chrome'):
+ if self.prefs.get_pref('media.gm-eme-adobe.version'):
+ self.prefs.set_pref('media.gm-eme-adobe.version', None)
+ result = self.marionette.execute_async_script(
+ reset_adobe_gmp_script,
+ script_timeout=60000)
+ if not result == 'success':
+ raise VideoException(
+ 'ERROR: Resetting Adobe GMP failed % s' % result)
+
+ EMESetupMixin.version_needs_reset = False
+
+ def check_and_log_boolean_pref(self, pref_name, expected_value):
+ with self.marionette.using_context('chrome'):
+ pref_value = self.prefs.get_pref(pref_name)
+
+ if pref_value is None:
+ self.logger.info('Pref %s has no value.' % pref_name)
+ return False
+ else:
+ self.logger.info('Pref %s = %s' % (pref_name, pref_value))
+ if pref_value != expected_value:
+ self.logger.info('Pref %s has unexpected value.'
+ % pref_name)
+ return False
+
+ return True
+
+ def check_and_log_integer_pref(self, pref_name, minimum_value=0):
+ with self.marionette.using_context('chrome'):
+ pref_value = self.prefs.get_pref(pref_name)
+
+ if pref_value is None:
+ self.logger.info('Pref %s has no value.' % pref_name)
+ return False
+ else:
+ self.logger.info('Pref %s = %s' % (pref_name, pref_value))
+
+ match = re.search('^\d+$', pref_value)
+ if not match:
+ self.logger.info('Pref %s is not an integer' % pref_name)
+ return False
+
+ return pref_value >= minimum_value
+
+ def check_eme_prefs(self):
+ with self.marionette.using_context('chrome'):
+ prefs_ok = self.check_and_log_boolean_pref(
+ 'media.mediasource.enabled', True)
+ prefs_ok = self.check_and_log_boolean_pref(
+ 'media.eme.enabled', True) and prefs_ok
+ prefs_ok = self.check_and_log_boolean_pref(
+ 'media.mediasource.mp4.enabled', True) and prefs_ok
+ prefs_ok = self.check_and_log_boolean_pref(
+ 'media.gmp-eme-adobe.enabled', True) and prefs_ok
+ prefs_ok = self.check_and_log_integer_pref(
+ 'media.gmp-eme-adobe.version', 1) and prefs_ok
+
+ return prefs_ok
+
+
+
--- a/dom/media/test/external/external_media_tests/playback/netflix_limiting_bandwidth.ini
+++ b/dom/media/test/external/external_media_tests/playback/netflix_limiting_bandwidth.ini
@@ -1,1 +1,1 @@
-[test_playback_limiting_bandwidth.py]
+[test_eme_playback_limiting_bandwidth.py]
--- a/dom/media/test/external/external_media_tests/playback/test_eme_playback.py
+++ b/dom/media/test/external/external_media_tests/playback/test_eme_playback.py
@@ -1,100 +1,14 @@
# 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 re
-
-from external_media_harness.testcase import MediaTestCase, VideoPlaybackTestsMixin
-from external_media_tests.media_utils.video_puppeteer import VideoException
+from external_media_harness.testcase import MediaTestCase, VideoPlaybackTestsMixin, EMESetupMixin
-reset_adobe_gmp_script = """
-navigator.requestMediaKeySystemAccess('com.adobe.primetime',
-[{initDataType: 'cenc'}]).then(
- function(access) {
- marionetteScriptFinished('success');
- },
- function(ex) {
- marionetteScriptFinished(ex);
- }
-);
-"""
-class TestEMEPlayback(MediaTestCase, VideoPlaybackTestsMixin):
-
- # Class variable. We only need to reset the adobe GMP version once, not
- # every time we instantiate the class.
- version_needs_reset = True
+class TestEMEPlayback(MediaTestCase, VideoPlaybackTestsMixin, EMESetupMixin):
def setUp(self):
super(TestEMEPlayback, self).setUp()
- self.set_eme_prefs()
- self.reset_GMP_version()
- assert(self.check_eme_prefs())
-
- def set_eme_prefs(self):
- with self.marionette.using_context('chrome'):
-
- # https://bugzilla.mozilla.org/show_bug.cgi?id=1187471#c28
- # 2015-09-28 cpearce says this is no longer necessary, but in case
- # we are working with older firefoxes...
- self.prefs.set_pref('media.gmp.trial-create.enabled', False)
-
- def reset_GMP_version(self):
- if TestEMEPlayback.version_needs_reset:
- with self.marionette.using_context('chrome'):
- if self.prefs.get_pref('media.gm-eme-adobe.version'):
- self.prefs.set_pref('media.gm-eme-adobe.version', None)
- result = self.marionette.execute_async_script(reset_adobe_gmp_script,
- script_timeout=60000)
- if not result == 'success':
- raise VideoException('ERROR: Resetting Adobe GMP failed % s' % result)
-
- TestEMEPlayback.version_needs_reset = False
-
- def check_and_log_boolean_pref(self, pref_name, expected_value):
- with self.marionette.using_context('chrome'):
- pref_value = self.prefs.get_pref(pref_name)
+ self.check_eme_system()
- if pref_value is None:
- self.logger.info('Pref %s has no value.' % pref_name)
- return False
- else:
- self.logger.info('Pref %s = %s' % (pref_name, pref_value))
- if pref_value != expected_value:
- self.logger.info('Pref %s has unexpected value.'
- % pref_name)
- return False
-
- return True
-
- def check_and_log_integer_pref(self, pref_name, minimum_value=0):
- with self.marionette.using_context('chrome'):
- pref_value = self.prefs.get_pref(pref_name)
-
- if pref_value is None:
- self.logger.info('Pref %s has no value.' % pref_name)
- return False
- else:
- self.logger.info('Pref %s = %s' % (pref_name, pref_value))
-
- match = re.search('^\d+$', pref_value)
- if not match:
- self.logger.info('Pref %s is not an integer' % pref_name)
- return False
-
- return pref_value >= minimum_value
-
- def check_eme_prefs(self):
- with self.marionette.using_context('chrome'):
- prefs_ok = self.check_and_log_boolean_pref(
- 'media.mediasource.enabled', True)
- prefs_ok = self.check_and_log_boolean_pref(
- 'media.eme.enabled', True) and prefs_ok
- prefs_ok = self.check_and_log_boolean_pref(
- 'media.mediasource.mp4.enabled', True) and prefs_ok
- prefs_ok = self.check_and_log_boolean_pref(
- 'media.gmp-eme-adobe.enabled', True) and prefs_ok
- prefs_ok = self.check_and_log_integer_pref(
- 'media.gmp-eme-adobe.version', 1) and prefs_ok
-
- return prefs_ok
+ # Tests are implemented in VideoPlaybackTestsMixin
new file mode 100644
--- /dev/null
+++ b/dom/media/test/external/external_media_tests/playback/test_eme_playback_limiting_bandwidth.py
@@ -0,0 +1,23 @@
+# 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 import BrowserMobProxyTestCaseMixin
+
+from external_media_harness.testcase import (
+ EMESetupMixin,
+ NetworkBandwidthTestCase,
+ NetworkBandwidthTestsMixin,
+)
+
+class TestEMEPlaybackLimitingBandwidth(NetworkBandwidthTestCase,
+ BrowserMobProxyTestCaseMixin,
+ NetworkBandwidthTestsMixin,
+ EMESetupMixin):
+
+
+ def setUp(self):
+ super(TestEMEPlaybackLimitingBandwidth, self).setUp()
+ self.check_eme_system()
+
+ # Tests in NetworkBandwidthTestsMixin
--- a/dom/media/test/external/external_media_tests/playback/test_playback_limiting_bandwidth.py
+++ b/dom/media/test/external/external_media_tests/playback/test_playback_limiting_bandwidth.py
@@ -1,23 +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 import BrowserMobProxyTestCaseMixin
-from external_media_harness.testcase import NetworkBandwidthTestCase
+from external_media_harness.testcase import (
+ NetworkBandwidthTestCase, NetworkBandwidthTestsMixin
+)
class TestPlaybackLimitingBandwidth(NetworkBandwidthTestCase,
+ NetworkBandwidthTestsMixin,
BrowserMobProxyTestCaseMixin):
- def test_playback_limiting_bandwidth_250(self):
- self.proxy.limits({'downstream_kbps': 250})
- self.run_videos()
-
- def test_playback_limiting_bandwidth_500(self):
- self.proxy.limits({'downstream_kbps': 500})
- self.run_videos()
-
- def test_playback_limiting_bandwidth_1000(self):
- self.proxy.limits({'downstream_kbps': 1000})
- self.run_videos()
+ # Tests are in NetworkBandwidthTestsMixin
+ pass