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

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-trackdefault.html

Issue 691313002: MSE: Implement TrackDefault object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comment, fix layout test Created 6 years, 1 month 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/media-source/mediasource-trackdefault-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
6
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
12 function checkConstructionSucceeds(type, language, label, kinds, byt eStreamTrackID)
13 {
14 var trackDefault = new TrackDefault(type, language, label, kinds , byteStreamTrackID);
15 assert_equals(trackDefault.type, type, "type()");
16 assert_equals(trackDefault.language, language, "language()");
17 assert_equals(trackDefault.label, label, "label()");
18 assert_equals(trackDefault.byteStreamTrackID, byteStreamTrackID, "byteStreamTrackID()");
19 assert_equals(trackDefault.kinds.length, kinds.length, "kinds(). length");
20 for (var i = 0; i < kinds.length; ++i) {
21 assert_equals(trackDefault.kinds[i], kinds[i], "kinds() cont ents");
22 }
23 }
24
25 function checkConstructionFails(type, language, label, kinds, byteSt reamTrackID)
26 {
27 var trackDefault = null;
28 assert_throws("InvalidAccessError",
29 function() { trackDefault = new TrackDefault(type, language, label, kinds, byteStreamTrackID); },
30 "TrackDefault construction threw an exception");
31 }
32
33 function trackDefaultConstructionTest(type, language, label, kinds, byteStreamTrackID, expectation, description)
34 {
35 if (kinds.length > 1) {
wolenetz 2014/11/03 21:33:36 Hmm. This logic looks bad if kinds.length == 1 and
wolenetz 2014/11/03 21:39:51 Done.
36 test(function()
37 {
38 if (expectation)
39 checkConstructionSucceeds(type, language, label, kin ds, byteStreamTrackID);
40 else
41 checkConstructionFails(type, language, label, kinds, byteStreamTrackID);
42 }, description + ": type '" + type + "', language '" + langu age + "', label '" + label + "', multiple kinds, byteStreamTrackID '" + byteStre amTrackID + "'");
43 }
44
45 // If all of |kinds| are expected to succeed, also test each kin d individually.
46 if (!expectation)
47 return;
48 for (var i = 0; i < kinds.length; ++i) {
49 test(function()
50 {
51 if (expectation) {
52 checkConstructionSucceeds(type, language, label, new Array(kinds[i]), byteStreamTrackID);
53 } else {
54 checkConstructionFails(type, language, label, new Ar ray(kinds[i]), byteStreamTrackID);
55 }
56 }, description + ": type '" + type + "', language '" + langu age + "', label '" + label + "', kind '" + kinds[i] + "', byteStreamTrackID '" + byteStreamTrackID + "'");
57 }
58 }
59
60 var VALID_AUDIO_TRACK_KINDS = [
61 "alternative",
62 "descriptions",
63 "main",
64 "main-desc",
65 "translation",
66 "commentary",
67 "",
68 ];
69
70 var VALID_VIDEO_TRACK_KINDS = [
71 "alternative",
72 "captions",
73 "main",
74 "sign",
75 "subtitles",
76 "commentary",
77 "",
78 ];
79
80 var VALID_TEXT_TRACK_KINDS = [
81 "subtitles",
82 "captions",
83 "descriptions",
84 "chapters",
85 "metadata",
86 ];
87
88 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_ AUDIO_TRACK_KINDS, "1", true, "Test valid audio kinds");
89
90 trackDefaultConstructionTest("video", "en-US", "video label", VALID_ VIDEO_TRACK_KINDS, "1", true, "Test valid video kinds");
91
92 trackDefaultConstructionTest("text", "en-US", "text label", VALID_TE XT_TRACK_KINDS, "1", true, "Test valid text kinds");
93
94 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_ VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid audio kinds");
95
96 trackDefaultConstructionTest("video", "en-US", "video label", VALID_ AUDIO_TRACK_KINDS, "1", false, "Test mixed valid and invalid video kinds");
97
98 trackDefaultConstructionTest("text", "en-US", "text label", VALID_VI DEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid text kinds");
99 </script>
100 </body>
101 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/media/media-source/mediasource-trackdefault-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698