Chromium Code Reviews| Index: LayoutTests/http/tests/media/media-source/mediasource-trackdefault.html |
| diff --git a/LayoutTests/http/tests/media/media-source/mediasource-trackdefault.html b/LayoutTests/http/tests/media/media-source/mediasource-trackdefault.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aeb7244aac416b87091ab4718b91f1ef7c2f1705 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/media/media-source/mediasource-trackdefault.html |
| @@ -0,0 +1,111 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <script src="/w3c/resources/testharness.js"></script> |
| + <script src="/w3c/resources/testharnessreport.js"></script> |
| + |
| + <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
| + </head> |
| + <body> |
| + <div id="log"></div> |
| + <script> |
| + function checkConstructionSucceeds(type, language, label, kinds, byteStreamTrackID) |
| + { |
| + var trackDefault = new TrackDefault(type, language, label, kinds, byteStreamTrackID); |
| + 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.
|
| + assert_equals(trackDefault.language, language, "language()"); |
| + assert_equals(trackDefault.label, label, "label()"); |
| + assert_equals(trackDefault.byteStreamTrackID, byteStreamTrackID, "byteStreamTrackID()"); |
| + assert_equals(trackDefault.kinds.length, kinds.length, "kinds().length"); |
| + 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.
|
| + assert_equals(trackDefault.kinds[i], kinds[i], "kinds() contents"); |
| + } |
| + } |
| + |
| + function checkConstructionFails(type, language, label, kinds, byteStreamTrackID) |
| + { |
| + 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.
|
| + assert_throws("InvalidAccessError", |
| + function() { trackDefault = new TrackDefault(type, language, label, kinds, byteStreamTrackID); }, |
| + "TrackDefault construction threw an exception"); |
| + } |
| + |
| + function trackDefaultConstructionTest(type, language, label, kinds, byteStreamTrackID, expectation, description) |
| + { |
| + test(function() |
| + { |
| + if (expectation) |
| + checkConstructionSucceeds(type, language, label, kinds, byteStreamTrackID); |
| + else |
| + checkConstructionFails(type, language, label, kinds, byteStreamTrackID); |
| + }, description + ": type '" + type + "', language '" + language + "', label '" + label + "', multiple kinds, byteStreamTrackID '" + byteStreamTrackID + "'"); |
| + |
| + // If all of |kinds| are expected to succeed, also test each kind individually. |
| + if (!expectation || kinds.length <= 1) |
| + return; |
| + for (var i = 0; i < kinds.length; ++i) { |
| + test(function() |
| + { |
| + checkConstructionSucceeds(type, language, label, new Array(kinds[i]), byteStreamTrackID); |
| + }, description + ": type '" + type + "', language '" + language + "', label '" + label + "', kind '" + kinds[i] + "', byteStreamTrackID '" + byteStreamTrackID + "'"); |
| + } |
| + } |
| + |
| + var VALID_AUDIO_TRACK_KINDS = [ |
| + "alternative", |
| + "descriptions", |
| + "main", |
| + "main-desc", |
| + "translation", |
| + "commentary", |
| + "", |
| + ]; |
| + |
| + var VALID_VIDEO_TRACK_KINDS = [ |
| + "alternative", |
| + "captions", |
| + "main", |
| + "sign", |
| + "subtitles", |
| + "commentary", |
| + "", |
| + ]; |
| + |
| + var VALID_TEXT_TRACK_KINDS = [ |
| + "subtitles", |
| + "captions", |
| + "descriptions", |
| + "chapters", |
| + "metadata", |
| + ]; |
| + |
| + trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_AUDIO_TRACK_KINDS, "1", true, "Test valid audio kinds"); |
| + |
| + trackDefaultConstructionTest("video", "en-US", "video label", VALID_VIDEO_TRACK_KINDS, "1", true, "Test valid video kinds"); |
| + |
| + trackDefaultConstructionTest("text", "en-US", "text label", VALID_TEXT_TRACK_KINDS, "1", true, "Test valid text kinds"); |
| + |
| + trackDefaultConstructionTest("audio", "en-US", "audio label", VALID_VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid audio kinds"); |
| + |
| + trackDefaultConstructionTest("video", "en-US", "video label", VALID_AUDIO_TRACK_KINDS, "1", false, "Test mixed valid and invalid video kinds"); |
| + |
| + trackDefaultConstructionTest("text", "en-US", "text label", VALID_VIDEO_TRACK_KINDS, "1", false, "Test mixed valid and invalid text kinds"); |
| + |
| + test(function() |
| + { |
| + var trackDefault = null; |
|
philipj_slow
2014/11/14 12:03:37
not needed
wolenetz
2014/11/17 21:51:07
Done.
|
| + assert_throws(new TypeError(), |
| + function() { trackDefault = new TrackDefault("invalid type", "en-US", "label", VALID_AUDIO_TRACK_KINDS, "1"); }, |
| + "TrackDefault construction threw an exception"); |
| + }, "Test invalid 'type' parameter type passed to TrackDefault constructor"); |
| + |
| + test(function() |
| + { |
| + var trackDefault = null; |
|
philipj_slow
2014/11/14 12:03:37
not needed
wolenetz
2014/11/17 21:51:07
Done.
|
| + assert_throws(new TypeError(), |
| + function() { trackDefault = new TrackDefault("audio", "en-US", "label", "this is not a valid sequence", "1"); }, |
| + "TrackDefault construction threw an exception"); |
| + }, "Test invalid 'kinds' parameter type passed to TrackDefault constructor"); |
| + </script> |
| + </body> |
| +</html> |