Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: LayoutTests/media/avtracklists.html

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/media/avtracklists.html
diff --git a/LayoutTests/media/avtracklists.html b/LayoutTests/media/avtracklists.html
new file mode 100644
index 0000000000000000000000000000000000000000..ee3a501b94936f031e26367d54b596c32fa5f68b
--- /dev/null
+++ b/LayoutTests/media/avtracklists.html
@@ -0,0 +1,93 @@
+<!doctype html>
+<html>
+ <head>
+ <title>AudioTrackList &amp; VideoTrackList tests</title>
+ <script src="../resources/testharness.js"></script>
+ <script src="../resources/testharnessreport.js"></script>
+ <script src="media-file.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ function basic_tracklist_test(tagName, src, label)
+ {
+ function onTrackListEvent(actualEventList, e)
+ {
+ actualEventList.push(e.type);
+
+ if (e.type == "change")
+ return;
+
+ if (e.type == "addtrack") {
+ // Verify that the track property matches the first track in the list.
+ assert_equals(e.track, e.target[0]);
+ }
+ }
+
+ function setupTrackListHandlers(t, trackList, actualEventList)
+ {
+ trackList.addEventListener('addtrack', t.step_func(onTrackListEvent.bind(this, actualEventList)));
+ trackList.addEventListener('change', t.step_func(onTrackListEvent.bind(this, actualEventList)));
+ trackList.addEventListener('removetrack', t.step_func(onTrackListEvent.bind(this, actualEventList)));
+ }
+
+ async_test(function(t)
+ {
+ var e = document.createElement(tagName);
+ e.src = src;
+ e.autoplay = true;
+ var expectedEvents = ['addtrack', 'change'];
+ var actualAudioEvents = [];
+ var actualVideoEvents = [];
+ setupTrackListHandlers(t, e.audioTracks, actualAudioEvents, "audioTracks events");
+ setupTrackListHandlers(t, e.videoTracks, actualVideoEvents, "videoTracks events");
+
+ e.addEventListener('loadedmetadata', t.step_func(function()
+ {
+ assert_array_equals(actualAudioEvents, expectedEvents);
+
+ if (e.videoTracks.length > 0) {
+ assert_equals(label, "audio-video");
+ assert_array_equals(actualVideoEvents, expectedEvents);
+ } else {
+ assert_equals(label, "audio-only");
+ assert_equals(actualVideoEvents.length, 0);
+ }
+
+ t.done();
+ }));
+ }, tagName + " : " + label);
+ }
+
+ basic_tracklist_test('audio', findMediaFile('audio', 'content/test'), "audio-only");
+ basic_tracklist_test('audio', findMediaFile('video', 'content/test'), "audio-video");
+ basic_tracklist_test('video', findMediaFile('audio', 'content/test'), "audio-only");
+ basic_tracklist_test('video', findMediaFile('video', 'content/test'), "audio-video");
+
+ async_test(function(t)
+ {
+ var e = document.createElement('video');
+ e.src = findMediaFile('video', 'content/test');
+ e.autoplay = true;
philipj_slow 2014/02/24 09:46:00 Why autoplay? preload="none" seems appropriate to
acolwell GONE FROM CHROMIUM 2014/03/07 22:08:43 Done.
+ var expectedEvents = ['addtrack', 'change'];
+ var actualAudioEvents = [];
+ var actualVideoEvents = [];
+
+ e.addEventListener('loadedmetadata', t.step_func(function()
+ {
+ assert_equals(e.audioTracks.length, 1, "audioTracks.length");
+ assert_equals(e.videoTracks.length, 1, "videoTracks.length");
+
+ // Clear the source and verify that the track lists are cleared.
+ e.src = "";
+ e.addEventListener('error', t.step_func(function()
philipj_slow 2014/02/24 09:46:00 Per spec "Forget the media element's media-resourc
acolwell GONE FROM CHROMIUM 2014/03/07 22:08:43 Done.
+ {
+ assert_equals(e.audioTracks.length, 0, "audioTracks.length");
+ assert_equals(e.videoTracks.length, 0, "videoTracks.length");
+ t.done();
+ }));
+ }));
+ }, "Verify audioTracks & videoTracks are cleared.");
+ </script>
+ </body>
+</html>
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8TrackEventCustom.cpp » ('j') | Source/core/html/track/AudioTrackList.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698