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

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: Rebase Created 6 years, 9 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;
philipj_slow 2014/03/09 09:04:14 This early return can be removed.
acolwell GONE FROM CHROMIUM 2014/03/18 22:02:15 Done.
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.preload = "none";
39
40 var expectedEvents = ['addtrack', 'change'];
41 var actualAudioEvents = [];
42 var actualVideoEvents = [];
43 setupTrackListHandlers(t, e.audioTracks, actualAudioEvents, "audioTracks events");
44 setupTrackListHandlers(t, e.videoTracks, actualVideoEvents, "videoTracks events");
45
46 e.load();
47
48 e.addEventListener('loadedmetadata', t.step_func(function()
49 {
50 assert_array_equals(actualAudioEvents, expectedEvents);
51
52 if (e.videoTracks.length > 0) {
53 assert_equals(label, "audio-video");
54 assert_array_equals(actualVideoEvents, expectedEvent s);
55 } else {
56 assert_equals(label, "audio-only");
57 assert_equals(actualVideoEvents.length, 0);
58 }
59
60 t.done();
61 }));
62 }, tagName + " : " + label);
63 }
64
65 basic_tracklist_test('audio', findMediaFile('audio', 'content/test') , "audio-only");
66 basic_tracklist_test('audio', findMediaFile('video', 'content/test') , "audio-video");
67 basic_tracklist_test('video', findMediaFile('audio', 'content/test') , "audio-only");
68 basic_tracklist_test('video', findMediaFile('video', 'content/test') , "audio-video");
69
70 async_test(function(t)
71 {
72 var e = document.createElement('video');
73 e.src = findMediaFile('video', 'content/test');
74 e.preload = "none";
75 var expectedEvents = ['addtrack', 'change'];
76 var actualAudioEvents = [];
77 var actualVideoEvents = [];
78
79 e.load();
80
81 e.addEventListener('loadedmetadata', t.step_func(function()
82 {
83 assert_equals(e.audioTracks.length, 1, "audioTracks.length") ;
philipj_slow 2014/03/09 09:04:14 Verify that e.audioTracks[0] is an AudioTrack and
acolwell GONE FROM CHROMIUM 2014/03/18 22:02:15 I didn't want to verify the attributes yet because
philipj_slow 2014/03/20 16:17:39 Makes sense. Verifying instanceof AudioTrack would
84 assert_equals(e.videoTracks.length, 1, "videoTracks.length") ;
85
86 // Clear the source and verify that the track lists are clea red.
87 e.src = "";
philipj_slow 2014/03/20 16:17:39 I didn't notice this before. Setting the src attri
88 e.load();
89
90 assert_equals(e.audioTracks.length, 0, "audioTracks.length") ;
91 assert_equals(e.videoTracks.length, 0, "videoTracks.length") ;
92 t.done();
93 }));
94 }, "Verify audioTracks & videoTracks are cleared.");
95 </script>
96 </body>
97 </html>
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8TrackEventCustom.cpp » ('j') | Source/core/html/HTMLMediaElement.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698