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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>AudioTrackList &amp; VideoTrackList tests</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="media-file.js"></script>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 function basic_tracklist_test(tagName, src, label)
13 {
14 function onTrackListEvent(actualEventList, e)
15 {
16 actualEventList.push(e.type);
17
18 if (e.type == "change")
19 return;
20
21 if (e.type == "addtrack") {
22 // Verify that the track property matches the first trac k in the list.
23 assert_equals(e.track, e.target[0]);
24 }
25 }
26
27 function setupTrackListHandlers(t, trackList, actualEventList)
28 {
29 trackList.addEventListener('addtrack', t.step_func(onTrackLi stEvent.bind(this, actualEventList)));
30 trackList.addEventListener('change', t.step_func(onTrackList Event.bind(this, actualEventList)));
31 trackList.addEventListener('removetrack', t.step_func(onTrac kListEvent.bind(this, actualEventList)));
32 }
33
34 async_test(function(t)
35 {
36 var e = document.createElement(tagName);
37 e.src = src;
38 e.autoplay = true;
39 var expectedEvents = ['addtrack', 'change'];
40 var actualAudioEvents = [];
41 var actualVideoEvents = [];
42 setupTrackListHandlers(t, e.audioTracks, actualAudioEvents, "audioTracks events");
43 setupTrackListHandlers(t, e.videoTracks, actualVideoEvents, "videoTracks events");
44
45 e.addEventListener('loadedmetadata', t.step_func(function()
46 {
47 assert_array_equals(actualAudioEvents, expectedEvents);
48
49 if (e.videoTracks.length > 0) {
50 assert_equals(label, "audio-video");
51 assert_array_equals(actualVideoEvents, expectedEvent s);
52 } else {
53 assert_equals(label, "audio-only");
54 assert_equals(actualVideoEvents.length, 0);
55 }
56
57 t.done();
58 }));
59 }, tagName + " : " + label);
60 }
61
62 basic_tracklist_test('audio', findMediaFile('audio', 'content/test') , "audio-only");
63 basic_tracklist_test('audio', findMediaFile('video', 'content/test') , "audio-video");
64 basic_tracklist_test('video', findMediaFile('audio', 'content/test') , "audio-only");
65 basic_tracklist_test('video', findMediaFile('video', 'content/test') , "audio-video");
66
67 async_test(function(t)
68 {
69 var e = document.createElement('video');
70 e.src = findMediaFile('video', 'content/test');
71 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.
72 var expectedEvents = ['addtrack', 'change'];
73 var actualAudioEvents = [];
74 var actualVideoEvents = [];
75
76 e.addEventListener('loadedmetadata', t.step_func(function()
77 {
78 assert_equals(e.audioTracks.length, 1, "audioTracks.length") ;
79 assert_equals(e.videoTracks.length, 1, "videoTracks.length") ;
80
81 // Clear the source and verify that the track lists are clea red.
82 e.src = "";
83 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.
84 {
85 assert_equals(e.audioTracks.length, 0, "audioTracks.leng th");
86 assert_equals(e.videoTracks.length, 0, "videoTracks.leng th");
87 t.done();
88 }));
89 }));
90 }, "Verify audioTracks & videoTracks are cleared.");
91 </script>
92 </body>
93 </html>
OLDNEW
« 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