From 073a22b657722868df4069d680646b7481ff9802 Mon Sep 17 00:00:00 2001 From: "shadi@chromium.org" Date: Sat, 12 Jul 2014 04:47:40 +0000 Subject: Have media content and chrome browser tests load data from media/test/data With media files copied over to media/test/data, this CL makes media related content browser tests and chrome browser tests load test data from one location. The location is common with media unit tests data forder; managed in one place in media/base/test_data_util.h BUG=379314 Review URL: https://codereview.chromium.org/357413002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282795 0039d316-1c4b-4281-b951-d872f2087c98 --- media/test/data/blackwhite.html | 231 +++++++++++++++++++ media/test/data/eme_player.html | 108 +++++++++ media/test/data/eme_player_js/app_loader.js | 24 ++ media/test/data/eme_player_js/clearkey_player.js | 33 +++ media/test/data/eme_player_js/eme_app.js | 81 +++++++ .../test/data/eme_player_js/file_io_test_player.js | 34 +++ media/test/data/eme_player_js/fps_observer.js | 67 ++++++ media/test/data/eme_player_js/globals.js | 80 +++++++ .../test/data/eme_player_js/media_source_utils.js | 70 ++++++ media/test/data/eme_player_js/player_utils.js | 186 ++++++++++++++++ .../data/eme_player_js/prefixed_clearkey_player.js | 27 +++ .../data/eme_player_js/prefixed_widevine_player.js | 32 +++ media/test/data/eme_player_js/test_config.js | 65 ++++++ media/test/data/eme_player_js/utils.js | 245 +++++++++++++++++++++ media/test/data/eme_player_js/widevine_player.js | 38 ++++ media/test/data/encrypted_frame_size_change.html | 50 +++++ media/test/data/media_source_player.html | 38 ++++ media/test/data/mse_config_change.html | 134 +++++++++++ media/test/data/player.html | 77 +++++++ media/test/data/test_key_system_instantiation.html | 21 ++ 20 files changed, 1641 insertions(+) create mode 100644 media/test/data/blackwhite.html create mode 100644 media/test/data/eme_player.html create mode 100644 media/test/data/eme_player_js/app_loader.js create mode 100644 media/test/data/eme_player_js/clearkey_player.js create mode 100644 media/test/data/eme_player_js/eme_app.js create mode 100644 media/test/data/eme_player_js/file_io_test_player.js create mode 100644 media/test/data/eme_player_js/fps_observer.js create mode 100644 media/test/data/eme_player_js/globals.js create mode 100644 media/test/data/eme_player_js/media_source_utils.js create mode 100644 media/test/data/eme_player_js/player_utils.js create mode 100644 media/test/data/eme_player_js/prefixed_clearkey_player.js create mode 100644 media/test/data/eme_player_js/prefixed_widevine_player.js create mode 100644 media/test/data/eme_player_js/test_config.js create mode 100644 media/test/data/eme_player_js/utils.js create mode 100644 media/test/data/eme_player_js/widevine_player.js create mode 100644 media/test/data/encrypted_frame_size_change.html create mode 100644 media/test/data/media_source_player.html create mode 100644 media/test/data/mse_config_change.html create mode 100644 media/test/data/player.html create mode 100644 media/test/data/test_key_system_instantiation.html (limited to 'media/test') diff --git a/media/test/data/blackwhite.html b/media/test/data/blackwhite.html new file mode 100644 index 0000000..6b9d049 --- /dev/null +++ b/media/test/data/blackwhite.html @@ -0,0 +1,231 @@ + + + + + + +
+ + + + + + + + + + + + + +

+ + + + diff --git a/media/test/data/eme_player.html b/media/test/data/eme_player.html new file mode 100644 index 0000000..65c120f --- /dev/null +++ b/media/test/data/eme_player.html @@ -0,0 +1,108 @@ + + + + EME playback test application + + + Clearkey works only with content encrypted using bear key.

+
ImageAbsolute DiffDifferent Pixels
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +

+ Decoded fps: +
+ Dropped fps: +
+ Total dropped frames: +

+ + + + + +
+ + +
+
+ + + + diff --git a/media/test/data/eme_player_js/app_loader.js b/media/test/data/eme_player_js/app_loader.js new file mode 100644 index 0000000..f4a3e74 --- /dev/null +++ b/media/test/data/eme_player_js/app_loader.js @@ -0,0 +1,24 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Adds a Javascript source tag to the document. +function addScriptTag(src) { + document.write( + ''); +} + +// Load all the dependencies for the app. +addScriptTag('globals.js'); +addScriptTag('utils.js'); +addScriptTag('test_config.js'); +addScriptTag('fps_observer.js'); +addScriptTag('media_source_utils.js'); +addScriptTag('player_utils.js'); +addScriptTag('prefixed_clearkey_player.js'); +addScriptTag('clearkey_player.js'); +addScriptTag('widevine_player.js'); +addScriptTag('prefixed_widevine_player.js'); +addScriptTag('file_io_test_player.js'); +addScriptTag('eme_app.js'); diff --git a/media/test/data/eme_player_js/clearkey_player.js b/media/test/data/eme_player_js/clearkey_player.js new file mode 100644 index 0000000..6de8408 --- /dev/null +++ b/media/test/data/eme_player_js/clearkey_player.js @@ -0,0 +1,33 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ClearKeyPlayer responsible for playing media using Clear Key key system and +// the unprefixed version of EME. +function ClearKeyPlayer(video, testConfig) { + this.video = video; + this.testConfig = testConfig; +} + +ClearKeyPlayer.prototype.init = function() { + PlayerUtils.initEMEPlayer(this); +}; + +ClearKeyPlayer.prototype.registerEventListeners = function() { + PlayerUtils.registerEMEEventListeners(this); +}; + +ClearKeyPlayer.prototype.onMessage = function(message) { + Utils.timeLog('MediaKeySession onMessage', message); + var initData = + Utils.getInitDataFromMessage(message, this.testConfig.mediaType); + var key = Utils.getDefaultKey(this.testConfig.forceInvalidResponse); + var jwkSet = Utils.createJWKData(initData, key); + if (PROMISES_SUPPORTED) { + message.target.update(jwkSet).catch(function(error) { + Utils.failTest(error, KEY_ERROR); + }); + } else { + message.target.update(jwkSet); + } +}; diff --git a/media/test/data/eme_player_js/eme_app.js b/media/test/data/eme_player_js/eme_app.js new file mode 100644 index 0000000..4c2ec0d --- /dev/null +++ b/media/test/data/eme_player_js/eme_app.js @@ -0,0 +1,81 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// EMEApp is responsible for starting playback on the eme_player.html page. +// It selects the suitable player based on key system and other test options. +function EMEApp(testConfig) { + this.video_ = null; + this.testConfig_ = testConfig; + this.updateDocument(testConfig); +} + +EMEApp.prototype.createPlayer = function() { + // Load document test configuration. + this.updateTestConfig(); + if (this.video_) { + Utils.timeLog('Delete old video tag.'); + this.video_.pause(); + this.video_.remove(); + delete(this.video_); + } + + this.video_ = document.createElement('video'); + this.video_.controls = true; + this.video_.preload = true; + this.video_.width = 848; + this.video_.height = 480; + var videoSpan = document.getElementById(VIDEO_ELEMENT_ID); + if (videoSpan) + videoSpan.appendChild(this.video_); + else + document.body.appendChild(this.video_); + + var videoPlayer = PlayerUtils.createPlayer(this.video_, this.testConfig_); + if (!videoPlayer) { + Utils.timeLog('Cannot create a media player.'); + return; + } + Utils.timeLog('Using ' + videoPlayer.constructor.name); + if (this.testConfig_.runFPS) + FPSObserver.observe(this.video_); + + videoPlayer.init(); + return videoPlayer; +}; + +EMEApp.prototype.updateDocument = function(testConfig) { + // Update document lists with test configuration values. + Utils.addOptions(KEYSYSTEM_ELEMENT_ID, KEY_SYSTEMS); + Utils.addOptions(MEDIA_TYPE_ELEMENT_ID, MEDIA_TYPES); + Utils.addOptions(USE_PREFIXED_EME_ID, EME_VERSIONS_OPTIONS, + EME_DISABLED_OPTIONS); + document.getElementById(MEDIA_FILE_ELEMENT_ID).value = + testConfig.mediaFile || DEFAULT_MEDIA_FILE; + document.getElementById(LICENSE_SERVER_ELEMENT_ID).value = + testConfig.licenseServerURL || DEFAULT_LICENSE_SERVER; + if (testConfig.keySystem) + Utils.ensureOptionInList(KEYSYSTEM_ELEMENT_ID, testConfig.keySystem); + if (testConfig.mediaType) + Utils.ensureOptionInList(MEDIA_TYPE_ELEMENT_ID, testConfig.mediaType); + document.getElementById(USE_MSE_ELEMENT_ID).value = testConfig.useMSE; + if (testConfig.usePrefixedEME) + document.getElementById(USE_PREFIXED_EME_ID).value = EME_PREFIXED_VERSION; +}; + +EMEApp.prototype.updateTestConfig = function() { + // Reload test configuration from document. + this.testConfig_.mediaFile = + document.getElementById(MEDIA_FILE_ELEMENT_ID).value; + this.testConfig_.keySystem = + document.getElementById(KEYSYSTEM_ELEMENT_ID).value; + this.testConfig_.mediaType = + document.getElementById(MEDIA_TYPE_ELEMENT_ID).value; + this.testConfig_.useMSE = + document.getElementById(USE_MSE_ELEMENT_ID).value == 'true'; + this.testConfig_.usePrefixedEME = ( + document.getElementById(USE_PREFIXED_EME_ID).value == + EME_PREFIXED_VERSION); + this.testConfig_.licenseServerURL = + document.getElementById(LICENSE_SERVER_ELEMENT_ID).value; +}; diff --git a/media/test/data/eme_player_js/file_io_test_player.js b/media/test/data/eme_player_js/file_io_test_player.js new file mode 100644 index 0000000..d259801 --- /dev/null +++ b/media/test/data/eme_player_js/file_io_test_player.js @@ -0,0 +1,34 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// File IO test player is used to test File IO CDM functionality. +function FileIOTestPlayer(video, testConfig) { + this.video = video; + this.testConfig = testConfig; +} + +FileIOTestPlayer.prototype.init = function() { + PlayerUtils.initPrefixedEMEPlayer(this); +}; + +FileIOTestPlayer.prototype.registerEventListeners = function() { + PlayerUtils.registerPrefixedEMEEventListeners(this); +}; + +FileIOTestPlayer.prototype.onWebkitKeyMessage = function(message) { + // The test result is either '0' or '1' appended to the header. + if (Utils.hasPrefix(message.message, FILE_IO_TEST_RESULT_HEADER)) { + if (message.message.length != FILE_IO_TEST_RESULT_HEADER.length + 1) { + Utils.failTest('Unexpected FileIOTest CDM message' + message.message); + return; + } + var result_index = FILE_IO_TEST_RESULT_HEADER.length; + var success = String.fromCharCode(message.message[result_index]) == 1; + Utils.timeLog('CDM file IO test: ' + (success ? 'Success' : 'Fail')); + if (success) + Utils.setResultInTitle(FILE_IO_TEST_SUCCESS); + else + Utils.failTest('File IO CDM message fail status.'); + } +}; diff --git a/media/test/data/eme_player_js/fps_observer.js b/media/test/data/eme_player_js/fps_observer.js new file mode 100644 index 0000000..8226df8 --- /dev/null +++ b/media/test/data/eme_player_js/fps_observer.js @@ -0,0 +1,67 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// FPSObserver observes a