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

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html

Issue 702583002: MSE: Implement TrackDefaultList object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@WIP_blink_trackdefaults_and_add_tracks_to_init_segment_processing
Patch Set: Rebased and addressed comments from PS2 Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html b/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html
new file mode 100644
index 0000000000000000000000000000000000000000..aa8d2123a2035fbf293bde849320a761d4f4c3f3
--- /dev/null
+++ b/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
sof 2014/12/12 09:37:00 Does this rely on being a network test?
wolenetz 2014/12/12 19:18:31 You're right to point this out. No, the TrackDefau
sof 2014/12/12 19:26:34 That sounds quite reasonable, it wasn't clear to m
wolenetz 2014/12/12 21:48:05 Acknowledged.
+<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>
+
+ test(function()
+ {
+ var originalTrackDefaults = [
+ // Same everything, but different byteStreamTrackID, should be allowed by the constructor.
+ new TrackDefault("audio", "en-US", "label", ["main"], ""),
+ new TrackDefault("audio", "en-US", "label", ["main"], "1"),
+ new TrackDefault("audio", "en-US", "label", ["main"], "2"),
+ new TrackDefault("audio", "en-US", "label", [""], "3"),
+
+ // Same everything, but different type, should be allowed by the constructor.
+ new TrackDefault("video", "en-US", "label", ["main"], ""),
+ new TrackDefault("video", "en-US", "label", ["main"], "1"),
+ new TrackDefault("video", "en-US", "label", ["main"], "2"),
+ new TrackDefault("video", "en-US", "label", [""], "3")
+ ];
+
+ // Get a new array containing the same objects as |originalTrackDefaults|.
+ var trackDefaults = originalTrackDefaults.slice();
+
+ var trackDefaultList = new TrackDefaultList(trackDefaults);
+ assert_array_equals(trackDefaultList, originalTrackDefaults, "construction and read-back succeeded");
+ assert_equals(trackDefaultList[trackDefaultList.length], undefined, "out of range indexed property getter result is undefined");
+ assert_equals(trackDefaultList[trackDefaultList.length + 1], undefined, "out of range indexed property getter result is undefined");
+
+ // Introduce same-type, same-empty-string-byteStreamTrackId conflict in trackDefaults[0 vs 4].
+ trackDefaults[4] = new TrackDefault("audio", "en-US", "label", ["main"], "");
+ assert_equals(trackDefaults[0].type, trackDefaults[4].type, "same-type conflict setup");
+ assert_equals(trackDefaults[0].byteStreamTrackID, trackDefaults[4].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
+ assert_throws("InvalidAccessError",
+ function() { new TrackDefaultList(trackDefaults); },
+ "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");
+
+ // Introduce same-type, same-non-empty-string-byteStreamTrackId conflict in trackDefaults[4 vs 5].
+ trackDefaults[4] = new TrackDefault("video", "en-US", "label", ["main"], "1");
+ assert_equals(trackDefaults[4].type, trackDefaults[5].type, "same-type conflict setup");
+ assert_equals(trackDefaults[4].byteStreamTrackID, trackDefaults[5].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
+ assert_throws("InvalidAccessError",
+ function() { new TrackDefaultList(trackDefaults); },
+ "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");
+
+ assert_array_equals(trackDefaultList, originalTrackDefaults, "read-back of original trackDefaultList unchanged");
+
+ // To demonstrate that the last read-back comparison, above, is sufficient,
philipj_slow 2014/12/12 20:25:21 This all seems a bit roundabout, why not just chec
wolenetz 2014/12/12 21:48:05 Done.
+ // confirm that assert_array_equals fails for a rough approximation of a deep copy.
+ // Shallow copy the array, then update the first item in the copy to simulate
+ // that it was a deep copy.
+ // This block, especially the last assertion in it, must remain the last piece of this
+ // test, because the last assertion is expected to fail.
+ trackDefaults = originalTrackDefaults.slice();
+ assert_array_equals(new TrackDefaultList(trackDefaults), new TrackDefaultList(originalTrackDefaults), "Shallow copies are equal");
+ trackDefaults[0] = new TrackDefault(originalTrackDefaults[0].type,
+ originalTrackDefaults[0].language,
+ originalTrackDefaults[0].label,
+ originalTrackDefaults[0].kinds,
+ originalTrackDefaults[0].byteStreamTrackID);
+ assert_not_equals(trackDefaults[0], originalTrackDefaults[0], "objects are different");
+ assert_equals(trackDefaults[0].type, "audio", "type matches");
+ assert_equals(trackDefaults[0].language, "en-US", "language matches");
+ assert_equals(trackDefaults[0].label, "label", "label matches");
+ assert_array_equals(trackDefaults[0].kinds, ["main"], "kinds array matches");
+ assert_equals(trackDefaults[0].byteStreamTrackID, "", "byteStreamTrackID matches");
+ assert_array_equals(
+ new TrackDefaultList(trackDefaults),
+ new TrackDefaultList(originalTrackDefaults),
+ "EXPECTED TO FAIL: Simulated deep copy is not equal.");
philipj_slow 2014/12/12 20:25:21 This line should be updated, right?
wolenetz 2014/12/12 21:48:05 This line *was* expected to demonstrate failure of
+
+ }, "Test track default list construction, length, and indexed property getter");
+
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698