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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!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.
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
13 test(function()
14 {
15 var originalTrackDefaults = [
16 // Same everything, but different byteStreamTrackID, should be allowed by the constructor.
17 new TrackDefault("audio", "en-US", "label", ["main"], ""),
18 new TrackDefault("audio", "en-US", "label", ["main"], "1"),
19 new TrackDefault("audio", "en-US", "label", ["main"], "2"),
20 new TrackDefault("audio", "en-US", "label", [""], "3"),
21
22 // Same everything, but different type, should be allowed by the constructor.
23 new TrackDefault("video", "en-US", "label", ["main"], ""),
24 new TrackDefault("video", "en-US", "label", ["main"], "1"),
25 new TrackDefault("video", "en-US", "label", ["main"], "2"),
26 new TrackDefault("video", "en-US", "label", [""], "3")
27 ];
28
29 // Get a new array containing the same objects as |originalTrack Defaults|.
30 var trackDefaults = originalTrackDefaults.slice();
31
32 var trackDefaultList = new TrackDefaultList(trackDefaults);
33 assert_array_equals(trackDefaultList, originalTrackDefaults, "co nstruction and read-back succeeded");
34 assert_equals(trackDefaultList[trackDefaultList.length], undefin ed, "out of range indexed property getter result is undefined");
35 assert_equals(trackDefaultList[trackDefaultList.length + 1], und efined, "out of range indexed property getter result is undefined");
36
37 // Introduce same-type, same-empty-string-byteStreamTrackId conf lict in trackDefaults[0 vs 4].
38 trackDefaults[4] = new TrackDefault("audio", "en-US", "label", [ "main"], "");
39 assert_equals(trackDefaults[0].type, trackDefaults[4].type, "sam e-type conflict setup");
40 assert_equals(trackDefaults[0].byteStreamTrackID, trackDefaults[ 4].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
41 assert_throws("InvalidAccessError",
42 function() { new TrackDefaultList(trackDefaults); },
43 "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");
44
45 // Introduce same-type, same-non-empty-string-byteStreamTrackId conflict in trackDefaults[4 vs 5].
46 trackDefaults[4] = new TrackDefault("video", "en-US", "label", [ "main"], "1");
47 assert_equals(trackDefaults[4].type, trackDefaults[5].type, "sam e-type conflict setup");
48 assert_equals(trackDefaults[4].byteStreamTrackID, trackDefaults[ 5].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
49 assert_throws("InvalidAccessError",
50 function() { new TrackDefaultList(trackDefaults); },
51 "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");
52
53 assert_array_equals(trackDefaultList, originalTrackDefaults, "re ad-back of original trackDefaultList unchanged");
54
55 // 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.
56 // confirm that assert_array_equals fails for a rough approximat ion of a deep copy.
57 // Shallow copy the array, then update the first item in the cop y to simulate
58 // that it was a deep copy.
59 // This block, especially the last assertion in it, must remain the last piece of this
60 // test, because the last assertion is expected to fail.
61 trackDefaults = originalTrackDefaults.slice();
62 assert_array_equals(new TrackDefaultList(trackDefaults), new Tra ckDefaultList(originalTrackDefaults), "Shallow copies are equal");
63 trackDefaults[0] = new TrackDefault(originalTrackDefaults[0].typ e,
64 originalTrackDefaults[0].lan guage,
65 originalTrackDefaults[0].lab el,
66 originalTrackDefaults[0].kin ds,
67 originalTrackDefaults[0].byt eStreamTrackID);
68 assert_not_equals(trackDefaults[0], originalTrackDefaults[0], "o bjects are different");
69 assert_equals(trackDefaults[0].type, "audio", "type matches");
70 assert_equals(trackDefaults[0].language, "en-US", "language matc hes");
71 assert_equals(trackDefaults[0].label, "label", "label matches");
72 assert_array_equals(trackDefaults[0].kinds, ["main"], "kinds arr ay matches");
73 assert_equals(trackDefaults[0].byteStreamTrackID, "", "byteStrea mTrackID matches");
74 assert_array_equals(
75 new TrackDefaultList(trackDefaults),
76 new TrackDefaultList(originalTrackDefaults),
77 "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
78
79 }, "Test track default list construction, length, and indexed proper ty getter");
80
81 </script>
82 </body>
83 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698