Chromium Code Reviews| OLD | NEW |
|---|---|
| (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()"); | |
|
philipj_slow
2014/11/14 12:03:37
Remove the parenthesis, as these are attributes in
wolenetz
2014/11/17 21:51:07
Done.
| |
| 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) { | |
|
philipj_slow
2014/11/14 12:03:37
Check if assert_array_equals works here. It would
wolenetz
2014/11/17 21:51:07
Done.
| |
| 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; | |
|
philipj_slow
2014/11/14 12:03:37
This doesn't need to be outside the inner function
wolenetz
2014/11/17 21:51:07
Done.
| |
| 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 test(function() | |
| 36 { | |
| 37 if (expectation) | |
| 38 checkConstructionSucceeds(type, language, label, kinds, byteStreamTrackID); | |
| 39 else | |
| 40 checkConstructionFails(type, language, label, kinds, byt eStreamTrackID); | |
| 41 }, description + ": type '" + type + "', language '" + language + "', label '" + label + "', multiple kinds, byteStreamTrackID '" + byteStreamTr ackID + "'"); | |
| 42 | |
| 43 // If all of |kinds| are expected to succeed, also test each kin d individually. | |
| 44 if (!expectation || kinds.length <= 1) | |
| 45 return; | |
| 46 for (var i = 0; i < kinds.length; ++i) { | |
| 47 test(function() | |
| 48 { | |
| 49 checkConstructionSucceeds(type, language, label, new Arr ay(kinds[i]), byteStreamTrackID); | |
| 50 }, description + ": type '" + type + "', language '" + langu age + "', label '" + label + "', kind '" + kinds[i] + "', byteStreamTrackID '" + byteStreamTrackID + "'"); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 var VALID_AUDIO_TRACK_KINDS = [ | |
| 55 "alternative", | |
| 56 "descriptions", | |
| 57 "main", | |
| 58 "main-desc", | |
| 59 "translation", | |
| 60 "commentary", | |
| 61 "", | |
| 62 ]; | |
| 63 | |
| 64 var VALID_VIDEO_TRACK_KINDS = [ | |
| 65 "alternative", | |
| 66 "captions", | |
| 67 "main", | |
| 68 "sign", | |
| 69 "subtitles", | |
| 70 "commentary", | |
| 71 "", | |
| 72 ]; | |
| 73 | |
| 74 var VALID_TEXT_TRACK_KINDS = [ | |
| 75 "subtitles", | |
| 76 "captions", | |
| 77 "descriptions", | |
| 78 "chapters", | |
| 79 "metadata", | |
| 80 ]; | |
| 81 | |
| 82 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_ AUDIO_TRACK_KINDS, "1", true, "Test valid audio kinds"); | |
| 83 | |
| 84 trackDefaultConstructionTest("video", "en-US", "video label", VALID_ VIDEO_TRACK_KINDS, "1", true, "Test valid video kinds"); | |
| 85 | |
| 86 trackDefaultConstructionTest("text", "en-US", "text label", VALID_TE XT_TRACK_KINDS, "1", true, "Test valid text kinds"); | |
| 87 | |
| 88 trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_ VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid audio kinds"); | |
| 89 | |
| 90 trackDefaultConstructionTest("video", "en-US", "video label", VALID_ AUDIO_TRACK_KINDS, "1", false, "Test mixed valid and invalid video kinds"); | |
| 91 | |
| 92 trackDefaultConstructionTest("text", "en-US", "text label", VALID_VI DEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid text kinds"); | |
| 93 | |
| 94 test(function() | |
| 95 { | |
| 96 var trackDefault = null; | |
|
philipj_slow
2014/11/14 12:03:37
not needed
wolenetz
2014/11/17 21:51:07
Done.
| |
| 97 assert_throws(new TypeError(), | |
| 98 function() { trackDefault = new TrackDefault("invalid type", "en-US", "label", VALID_AUDIO_TRACK_KINDS, "1"); }, | |
| 99 "TrackDefault construction threw an exception"); | |
| 100 }, "Test invalid 'type' parameter type passed to TrackDefault constr uctor"); | |
| 101 | |
| 102 test(function() | |
| 103 { | |
| 104 var trackDefault = null; | |
|
philipj_slow
2014/11/14 12:03:37
not needed
wolenetz
2014/11/17 21:51:07
Done.
| |
| 105 assert_throws(new TypeError(), | |
| 106 function() { trackDefault = new TrackDefault("audio", "en-US ", "label", "this is not a valid sequence", "1"); }, | |
| 107 "TrackDefault construction threw an exception"); | |
| 108 }, "Test invalid 'kinds' parameter type passed to TrackDefault const ructor"); | |
| 109 </script> | |
| 110 </body> | |
| 111 </html> | |
| OLD | NEW |