summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/data/media/html/media_event.html3
-rw-r--r--chrome/test/functional/PYAUTO_TESTS2
-rwxr-xr-xchrome/test/functional/media/media_event_test_base.py12
-rw-r--r--chrome/test/functional/media/media_event_track.py44
-rwxr-xr-xchrome/test/functional/media/media_test_base.py2
-rwxr-xr-xchrome/test/functional/media/media_test_runner.py50
6 files changed, 83 insertions, 30 deletions
diff --git a/chrome/test/data/media/html/media_event.html b/chrome/test/data/media/html/media_event.html
index 3c0cb57..7e993d8 100644
--- a/chrome/test/data/media/html/media_event.html
+++ b/chrome/test/data/media/html/media_event.html
@@ -22,7 +22,8 @@ var events = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied',
'ended', 'error', 'load', 'loadeddata', 'loadedmetadata',
'loadstart', 'pause', 'play', 'playing', 'progress',
'ratechange', 'seeked', 'seeking', 'stalled', 'suspend',
- 'timeupdate', 'volumechange', 'waiting']
+ 'timeupdate', 'volumechange', 'waiting',
+ 'cuechange', 'enter', 'exit', 'change'];
var startTime = 0
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS
index e8230c6..b41e089 100644
--- a/chrome/test/functional/PYAUTO_TESTS
+++ b/chrome/test/functional/PYAUTO_TESTS
@@ -362,7 +362,7 @@
'AV_FUNC': {
'linux': [
'media.media_event_simple_test',
- 'media.media_track',
+ 'media.media_event_track',
],
},
}
diff --git a/chrome/test/functional/media/media_event_test_base.py b/chrome/test/functional/media/media_event_test_base.py
index a9f4e6a..663df30 100755
--- a/chrome/test/functional/media/media_event_test_base.py
+++ b/chrome/test/functional/media/media_event_test_base.py
@@ -18,9 +18,11 @@ class MediaEventTestBase(MediaTestBase):
# This is a list of events to test during media playback.
EVENT_LIST = ['abort', 'canplay', 'canplaythrough', 'durationchange',
'emptied', 'ended', 'error', 'load', 'loadeddata',
- 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing',
+ 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing',
'progress', 'ratechange', 'seeked', 'seeking', 'stalled',
- 'suspend', 'timeupdate', 'volumechange', 'waiting']
+ 'suspend', 'timeupdate', 'volumechange', 'waiting',
+ # Track related events.
+ 'cuechange', 'enter', 'exit', 'change']
# These are event types that are not 1 at the end of video playback.
# There are two types of events listed here:
# 0: event occurrence is 0.
@@ -37,7 +39,11 @@ class MediaEventTestBase(MediaTestBase):
'seeking': 0,
'seeked': 0,
'volumechange': 0,
- 'timeupdate': None}
+ 'timeupdate': None,
+ 'cuechange': 0,
+ 'enter': 0,
+ 'exit': 0,
+ 'change': 0}
def _GetEventLog(self):
"""Get the event log from the DOM tree that is produced by player.html.
diff --git a/chrome/test/functional/media/media_event_track.py b/chrome/test/functional/media/media_event_track.py
new file mode 100644
index 0000000..b355efe
--- /dev/null
+++ b/chrome/test/functional/media/media_event_track.py
@@ -0,0 +1,44 @@
+#!/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 event test for the HTML5 media tag.
+
+This PyAuto powered script plays media (video or audio) files using the HTML5
+tag embedded in an HTML file (specified in the GetPlayerHTMLFileName() method)
+and asserts proper event occurrence relating to track (caption). 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 pyauto_media
+from media_event_test_base import MediaEventTestBase
+from media_test_env_names import MediaTestEnvNames
+
+
+class MediaEventTrackSimpleTest(MediaEventTestBase):
+ """Tests for simple media events."""
+
+ def testHTML5MediaTag(self):
+ """Test the HTML5 media tag."""
+ track_filename = os.getenv(MediaTestEnvNames.TRACK_FILE_ENV_NAME, '')
+ # Override the default test when track is used.
+ # There are two types of events listed here:
+ # 0: event occurrence is 0.
+ # None: event occurrence is more than 1.
+ # TODO(imasaki@chromium.org): uncomment below when we enable events.
+ if track_filename:
+ # self.event_expected_values['cuechange'] = None
+ # self.event_expected_values['enter'] = None
+ # self.event_expected_values['exit'] = None
+ # self.event_expected_values['change'] = None
+ pass
+ MediaEventTestBase.ExecuteTest(self)
+
+
+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 59f6cbe..e18f682 100755
--- a/chrome/test/functional/media/media_test_base.py
+++ b/chrome/test/functional/media/media_test_base.py
@@ -13,6 +13,7 @@ media_test_runner.py is used for generating these variables
"""
import csv
+import logging
import os
import time
@@ -145,6 +146,7 @@ class MediaTestBase(pyauto.PyUITest):
url = self.url
if self._test_scenarios:
url += '&actions=' + self.test_scenarios[run_counter]
+ logging.debug('Navigate to %s', url)
self.NavigateToURL(url)
self.WaitUntil(lambda: _VideoEnded(),
self.TIMEOUT)
diff --git a/chrome/test/functional/media/media_test_runner.py b/chrome/test/functional/media/media_test_runner.py
index be26025..4b6e26b 100755
--- a/chrome/test/functional/media/media_test_runner.py
+++ b/chrome/test/functional/media/media_test_runner.py
@@ -19,6 +19,7 @@ in matrix form),
import copy
import csv
+import glob
import logging
import os
from optparse import OptionParser
@@ -130,6 +131,8 @@ def main():
help=('Track file in vtt format (binary should be'
' downloaded from http://www.annacavender.com/track/'
' 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.'))
options, args = parser.parse_args()
if args:
@@ -142,9 +145,9 @@ def main():
# The media file should have the following format:
# tag(video|audio)|filename|nickname|video_title.
if len(opts) != 4:
- logging.error('--media_file option argument does not have correct format.'
- 'The correct format is tag(video|audio)|filename|nickname'
- '|video_title')
+ logging.error('--media_file option argument does not have correct'
+ 'format. The correct format is tag(video|audio)'
+ '|filename|nickname|video_title')
sys.exit(1)
test_data_list.append(opts)
elif options.input_matrix_filename is None:
@@ -176,33 +179,31 @@ def main():
reference_build_list = [False, True]
else:
reference_build_list = [False]
- if options.track_file or options.track:
+ track_files = ['']
+ if any([options.track_file, options.track, options.track_file_dir]):
# TODO(imasaki@chromium.org): change here after track functionality is
# available on Chrome. Currently, track patch is still under development.
# So, I need to download the binary from
# http://www.annacavender.com/track/ and use it for testing.
# I temporarily use reference build mechanism.
reference_build_list = [True]
+ if options.track_file_dir:
+ track_files_orig = (
+ glob.glob(os.path.join(options.track_file_dir, '*.vtt')))
+ track_files = []
+ for tf in track_files_orig:
+ # The location should be relative path from HTML files.
+ # So it needs to remove data and media from the path.
+ track_files.append(tf.replace(os.path.join('data', 'media'), ''))
+ if not track_files:
+ logging.warning('No track files in %s', options.track_file_dir)
+ if options.track_file:
+ track_files = [options.track_file]
# This is a loop for iterating through all videos defined above (list
# or matrix). Each video has associated tag and nickname for display
# purpose.
for tag, filename, nickname, title in test_data_list:
- # This inner loop iterates twice. The first iteration of the loop
- # disables the media cache, and the second iteration enables the media
- # cache. Other parameters remain the same on both loop iterations.
- # There are two ways to disable the media cache: setting Chrome option
- # to --media-cache-size=1 or adding t parameter in query parameter of
- # URL in which player.js (data/media/html/player.js) disables the
- # media cache).
- #
- # The default name for track vtt file is the name of the video title
- # in the case --track-file is not set. The track file should be in
- # the same directory as video files. For example, bear_en.vtt.
- if options.track and not options.track_file:
- # TODO(imasaki@chromium.org): add more languages.
- lang = 'en'
- options.track_file = os.path.join(os.path.dirname(filename),
- title + '_' + lang + '.vtt')
+ for track_file in track_files:
for reference_build in reference_build_list:
parent_envs = copy.deepcopy(os.environ)
if options.input_matrix_filename is None:
@@ -240,9 +241,8 @@ def main():
if options.reference_build_dir:
envs[MediaTestEnvNames.REFERENCE_BUILD_DIR_ENV_NAME] = (
options.reference_build_dir)
- if options.track_file:
- envs[MediaTestEnvNames.TRACK_FILE_ENV_NAME] = (
- options.track_file)
+ if track_file:
+ envs[MediaTestEnvNames.TRACK_FILE_ENV_NAME] = track_file
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.
@@ -273,8 +273,8 @@ def main():
proc = Popen(cmd, env=envs, shell=True)
proc.communicate()
- if options.one_video:
- break
+ if options.one_video:
+ break
if __name__ == '__main__':