diff options
author | imasaki@chromium.org <imasaki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 20:06:21 +0000 |
---|---|---|
committer | imasaki@chromium.org <imasaki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-30 20:06:21 +0000 |
commit | c370ae830e6f0b23a0c3cc794033465fbd855d1b (patch) | |
tree | 5e177516801496e314e24712451eb248b3d8f9a1 | |
parent | 2e844ef8e1b3e318074cd67ee9daa3300602211e (diff) | |
download | chromium_src-c370ae830e6f0b23a0c3cc794033465fbd855d1b.zip chromium_src-c370ae830e6f0b23a0c3cc794033465fbd855d1b.tar.gz chromium_src-c370ae830e6f0b23a0c3cc794033465fbd855d1b.tar.bz2 |
Add functionality to add several simultenous video play in media performance test.
Also add code for preparation of jerky (display FPS) test.
Review URL: http://codereview.chromium.org/7218062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91185 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/media/html/media_jerky.html | 20 | ||||
-rw-r--r-- | chrome/test/data/media/html/player.js | 89 | ||||
-rwxr-xr-x | chrome/test/functional/media/media_jerky.py | 46 | ||||
-rwxr-xr-x | chrome/test/functional/media/media_test_base.py | 4 | ||||
-rw-r--r-- | chrome/test/functional/media/media_test_env_names.py | 6 | ||||
-rwxr-xr-x | chrome/test/functional/media/media_test_runner.py | 8 |
6 files changed, 149 insertions, 24 deletions
diff --git a/chrome/test/data/media/html/media_jerky.html b/chrome/test/data/media/html/media_jerky.html new file mode 100644 index 0000000..6fbc1de --- /dev/null +++ b/chrome/test/data/media/html/media_jerky.html @@ -0,0 +1,20 @@ +<!-- +This HTML file contains a div for a player which is used for playback testing +(chrome/test/functional/media_playbackbacktime.py). +The query string should contain the following information: + tag (optional): HTML video/audio tag (default is video). + media (required): media file name. + t (optional): if specified, disables the media cache. + jerky (optional): if specified, show the predefined pattern for jerky test. + + Example: "media_playback.html?tag=video&media=foo.webm&t=t&jerky=True" +--> +<html> +<body onload='setPattern();'> +<div id='player_container'></div> +<script type='text/javascript' src='player.js'></script> +<script> + setTimeout(playMedia, 1000); +</script> +</body> +</html> diff --git a/chrome/test/data/media/html/player.js b/chrome/test/data/media/html/player.js index 642c6c7..906d23d 100644 --- a/chrome/test/data/media/html/player.js +++ b/chrome/test/data/media/html/player.js @@ -7,8 +7,9 @@ // * Parses query strings and sets the HTML tag. // * Installs event handlers to change the HTML title. -var player = null; + function InstallEventHandler(event, action) { + var player = document.getElementById('player'); player.addEventListener(event, function(e) { eval(action); }, false); @@ -68,38 +69,46 @@ function translateCommand(command, arg) { } } -if (queryString('actions')) { - // Action query string is a list of actions. An action consists of a - // time, action, action_argument triple (delimited by '|'). - // For example, '1000|seek|4000' means 'At second 1, seek to second 4.' - // Or '1000|pause|0|2000|play|0' means 'At second 1, pause the video. - // At second 2, play the video.' - var original_actions = queryString('actions').split('|'); - if ((original_actions.length % 3) != 0) { - // The action list is a list of triples. Otherwise, it fails. - document.title = 'FAIL'; - ok = false; - } - for (i = 0; i < original_actions.length / 3; i++) { - setTimeout(translateCommand(original_actions[3 * i + 1], - original_actions[3 * i + 2]), - parseInt(original_actions[3 * i])); - } -} - var container = document.getElementById('player_container'); -container.innerHTML = '<' + tag + ' controls id="player"></' + tag + '>'; -player = document.getElementById('player'); +container.innerHTML = '<div id="main" width="0%" height="0%" ' + + 'style="display: inline-block;"></div>' + + '<div id="extra"></div>'; +// Create new player. +var newElement = document.createElement(tag); +newElement.setAttribute('id', 'player'); +newElement.setAttribute('src', queryString('media')); +// Hide the video at the beginning for jerky test, in which +// we have to set predefined image before playing video. +if (queryString('jerky')) { + newElement.setAttribute('style', 'opacity: 0;'); +} +var main = document.getElementById('main'); +main.appendChild(newElement); // Install event handlers. +var player = document.getElementById('player'); InstallEventHandler('error', 'document.title = "ERROR = " + player.error.code'); InstallEventHandler('playing', 'document.title = "PLAYING"'); InstallEventHandler('ended', 'document.title = "END"'); -player.src = media_url; +if (queryString('num_extra')) { + // Process query string for extra players. + // Exra players use the exact same media file as the main player. + for (var i = 0; i < queryString('num_extra'); i++) { + var extra = document.getElementById('extra'); + var extraElement = document.createElement(tag); + extraElement.setAttribute('id', 'player' + i); + extraElement.setAttribute('src', media_url); + extraElement.setAttribute('autoplay', 'true'); + extra.appendChild(extraElement); + } +} if (queryString('track')) { + // Process query string for track (caption). + // Set the track file name. + // TODO(imasaki@chromium.org): add query parameters hardcoded here. var track_file = queryString('track'); var trackElement = document.createElement('track'); trackElement.setAttribute('id', 'track'); @@ -110,3 +119,37 @@ if (queryString('track')) { trackElement.setAttribute('default', 'true'); player.appendChild(trackElement); } + +if (queryString('actions')) { + // Action query string is a list of actions. An action consists of a + // time, action, action_argument triple (delimited by '|'). + // For example, '1000|seek|4000' means 'At second 1, seek to second 4.' + // Or '1000|pause|0|2000|play|0' means 'At second 1, pause the video. + // At second 2, play the video.' + var original_actions = queryString('actions').split('|'); + if ((original_actions.length % 3) != 0) { + // The action list is a list of triples. Otherwise, it fails. + document.title = 'FAIL Action length=' + original_actions.length + + ' is not multiple of 3'; + ok = false; + } + for (var i = 0; i < original_actions.length / 3; i++) { + setTimeout(translateCommand(original_actions[3 * i + 1], + original_actions[3 * i + 2]), + parseInt(original_actions[3 * i])); + } +} + +// Used for playing the video in the media_jerky.py test. +function playMedia() { + var player = document.getElementById('player'); + player.style.opacity = '1'; + player.play(); +} + +// Called in the body onload event in media_jerky.html. +function setPattern() { + var main = document.getElementById('main'); + main.style.backgroundColor = '#50dead'; +} + diff --git a/chrome/test/functional/media/media_jerky.py b/chrome/test/functional/media/media_jerky.py new file mode 100755 index 0000000..897de6f --- /dev/null +++ b/chrome/test/functional/media/media_jerky.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# Copyright (c) 2011 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. + +"""Simple test for HTML5 media tag to measure playback time. + +This PyAuto powered script plays media (video or audio) files using the HTML5 +tag embedded in an HTML file (specified in the GetPlayerHTMLFileName() method) +for a test that uses a jerky tool that is being developed. The tool will measure +display Frame-per-second (FPS) (instead of decode FPS, which is measured in +media_fps.py). The tool requires predefined pattern to show before video plays +to determine the area to be measured (it is done in +data/media/html/media_jerky.html). + +The parameters needed to run this test are passed in the form of environment +variables (such as the number of runs). Media_perf_runner.py is used for +generating these variables (PyAuto does not support direct parameters). +""" +import os +import time + +from media_test_base import MediaTestBase +from media_test_env_names import MediaTestEnvNames +import pyauto_media + + +class MediaPlaybackTimeTest(MediaTestBase): + """Test class to record playback time.""" + + def testHTML5MediaTag(self): + """Test the HTML5 media tag.""" + MediaTestBase.ExecuteTest(self) + + def PreAllRunsProcess(self): + """A method to be executed before all runs.""" + os.environ[MediaTestEnvNames.JERKY_TEST_ENV_NAME] = 'True' + MediaTestBase.PreAllRunsProcess(self) + + def GetPlayerHTMLFileName(self): + """A method to get the player HTML file name.""" + return 'media_jerky.html' + + +if __name__ == '__main__': + pyauto_media.Main() diff --git a/chrome/test/functional/media/media_test_base.py b/chrome/test/functional/media/media_test_base.py index 1420736..db13e74 100755 --- a/chrome/test/functional/media/media_test_base.py +++ b/chrome/test/functional/media/media_test_base.py @@ -87,6 +87,10 @@ class MediaTestBase(pyauto.PyUITest): track_file = os.getenv(MediaTestEnvNames.TRACK_FILE_ENV_NAME) if track_file: query_dictionary['track'] = track_file + query_dictionary['num_extra'] = ( + os.getenv(MediaTestEnvNames.N_EXTRA_PLAYERS_ENV_NAME, 0)) + if os.getenv(MediaTestEnvNames.JERKY_TEST_ENV_NAME): + query_dictionary['jerky'] = 'True' query_str = '&'.join( [k + '=' + str(v) for (k, v) in query_dictionary.items()]) if player_html_url_nickname == self.DEFAULT_PLAYER_HTML_URL_NICKNAME: diff --git a/chrome/test/functional/media/media_test_env_names.py b/chrome/test/functional/media/media_test_env_names.py index 56454a2..8401c26 100644 --- a/chrome/test/functional/media/media_test_env_names.py +++ b/chrome/test/functional/media/media_test_env_names.py @@ -63,3 +63,9 @@ class MediaTestEnvNames: # Define track(caption) file. TRACK_FILE_ENV_NAME = 'TRACK_FILE' + + # Define the number of additional players shown for stress testing. + N_EXTRA_PLAYERS_ENV_NAME = 'N_EXTRA_PLAYERS' + + # Define this if this is jerky test. + JERKY_TEST_ENV_NAME = 'JERKY_TEST' diff --git a/chrome/test/functional/media/media_test_runner.py b/chrome/test/functional/media/media_test_runner.py index 4b6e26b..543347d 100755 --- a/chrome/test/functional/media/media_test_runner.py +++ b/chrome/test/functional/media/media_test_runner.py @@ -133,7 +133,10 @@ def main(): ' and put into reference_build_dir).')) parser.add_option('-y', '--track-file_dir', dest='track_file_dir', help=('A directory that contains vtt format files.')) - + parser.add_option('-d', '--num-extra-players', + dest='number_of_extra_players', + help=('The number of extra players for ' + 'stress testing using the same media file.')) options, args = parser.parse_args() if args: parser.print_help() @@ -243,6 +246,9 @@ def main(): options.reference_build_dir) if track_file: envs[MediaTestEnvNames.TRACK_FILE_ENV_NAME] = track_file + if options.number_of_extra_players: + envs[MediaTestEnvNames.N_EXTRA_PLAYERS_ENV_NAME] = ( + options.number_of_extra_players) envs.update(parent_envs) if options.suite is None and options.test_prog_name is not None: # Suite is not used - run test program directly. |