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

Side by Side Diff: LayoutTests/fast/mediastream/MediaStream-add-remove-tracks.html

Issue 397903003: Implement sequence<MediaStreamTrack> getTracks () This is to conform to the new spec- http://dev.w3… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months 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/fast/mediastream/MediaStream-add-remove-tracks-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
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Test adding and removing tracks."); 8 description("Test adding and removing tracks.");
9 9
10 var stream1; 10 var stream1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 function shouldNotFire() { 47 function shouldNotFire() {
48 testFailed("\"addtrack\" or \"removetrack\" events should not fire as a resu lt of local addTrack() or removeTrack() operations."); 48 testFailed("\"addtrack\" or \"removetrack\" events should not fire as a resu lt of local addTrack() or removeTrack() operations.");
49 } 49 }
50 50
51 function gotStream2(s) { 51 function gotStream2(s) {
52 stream2 = s; 52 stream2 = s;
53 53
54 shouldBe('stream1.getAudioTracks().length', '1'); 54 shouldBe('stream1.getAudioTracks().length', '1');
55 shouldBe('stream1.getVideoTracks().length', '1'); 55 shouldBe('stream1.getVideoTracks().length', '1');
56 shouldBe('stream1.getTracks().length', '2');
56 57
57 shouldBe('stream2.getAudioTracks().length', '1'); 58 shouldBe('stream2.getAudioTracks().length', '1');
58 shouldBe('stream2.getVideoTracks().length', '1'); 59 shouldBe('stream2.getVideoTracks().length', '1');
60 shouldBe('stream2.getTracks().length', '2');
59 61
60 stream1.onaddtrack = shouldNotFire; 62 stream1.onaddtrack = shouldNotFire;
61 stream1.onremovetrack = shouldNotFire; 63 stream1.onremovetrack = shouldNotFire;
62 64
63 // remove a track of each kind 65 // remove a track of each kind
64 audioTrack = stream1.getAudioTracks()[0]; 66 audioTrack = stream1.getAudioTracks()[0];
65 videoTrack = stream1.getVideoTracks()[0]; 67 videoTrack = stream1.getVideoTracks()[0];
66 68
67 tryRemoveTrack(stream1, audioTrack); 69 tryRemoveTrack(stream1, audioTrack);
68 // verify removed tracks 70 // verify removed tracks
69 shouldBe('stream1.getAudioTracks().length', '0'); 71 shouldBe('stream1.getAudioTracks().length', '0');
72 // verify that gettracks length is reduced by 1
73 shouldBe('stream1.getTracks().length', '1');
70 shouldBeNull('stream1.getTrackById(audioTrack.id)'); 74 shouldBeNull('stream1.getTrackById(audioTrack.id)');
71 // remove a non-existent (already removed) track (should not throw) 75 // remove a non-existent (already removed) track (should not throw)
72 tryRemoveTrack(stream1, audioTrack); 76 tryRemoveTrack(stream1, audioTrack);
73 // (re-)add tracks 77 // (re-)add tracks
74 tryAddTrack(stream1, audioTrack); 78 tryAddTrack(stream1, audioTrack);
75 shouldBeNonNull('stream1.getTrackById(audioTrack.id)'); 79 shouldBeNonNull('stream1.getTrackById(audioTrack.id)');
76 shouldBe('audioTrack', 'stream1.getAudioTracks()[0]'); 80 shouldBe('audioTrack', 'stream1.getAudioTracks()[0]');
77 81
78 tryRemoveTrack(stream1, videoTrack); 82 tryRemoveTrack(stream1, videoTrack);
79 shouldBe('stream1.getVideoTracks().length', '0'); 83 shouldBe('stream1.getVideoTracks().length', '0');
84 // verify that gettracks length is reduced by 1
85 shouldBe('stream1.getTracks().length', '1');
80 shouldBeNull('stream1.getTrackById(videoTrack.id)'); 86 shouldBeNull('stream1.getTrackById(videoTrack.id)');
81 tryRemoveTrack(stream1, videoTrack); 87 tryRemoveTrack(stream1, videoTrack);
82 tryAddTrack(stream1, videoTrack); 88 tryAddTrack(stream1, videoTrack);
83 89
84 // verify added tracks 90 // verify added tracks
85 shouldBe('stream1.getAudioTracks().length', '1'); 91 shouldBe('stream1.getAudioTracks().length', '1');
86 shouldBe('stream1.getVideoTracks().length', '1'); 92 shouldBe('stream1.getVideoTracks().length', '1');
93 shouldBe('stream1.getTracks().length', '2');
87 94
88 // verify that kind and label is preserved 95 // verify that kind and label is preserved
89 shouldBe('stream1.getAudioTracks()[0].kind', 'audioTrack.kind'); 96 shouldBe('stream1.getAudioTracks()[0].kind', 'audioTrack.kind');
90 shouldBe('stream1.getAudioTracks()[0].label', 'audioTrack.label'); 97 shouldBe('stream1.getAudioTracks()[0].label', 'audioTrack.label');
91 shouldBe('stream1.getVideoTracks()[0].kind', 'videoTrack.kind'); 98 shouldBe('stream1.getVideoTracks()[0].kind', 'videoTrack.kind');
92 shouldBe('stream1.getVideoTracks()[0].label', 'videoTrack.label'); 99 shouldBe('stream1.getVideoTracks()[0].label', 'videoTrack.label');
93 100
94 // try adding stream1's own tracks 101 // try adding stream1's own tracks
95 tryAddTrack(stream1, stream1.getAudioTracks()[0]); 102 tryAddTrack(stream1, stream1.getAudioTracks()[0]);
96 tryAddTrack(stream1, stream1.getVideoTracks()[0]); 103 tryAddTrack(stream1, stream1.getVideoTracks()[0]);
97 104
98 // verify that nothing has changed 105 // verify that nothing has changed
99 shouldBe('stream1.getAudioTracks().length', '1'); 106 shouldBe('stream1.getAudioTracks().length', '1');
100 shouldBe('stream1.getVideoTracks().length', '1'); 107 shouldBe('stream1.getVideoTracks().length', '1');
108 shouldBe('stream1.getTracks().length', '2');
101 109
102 // add new tracks (from stream2) 110 // add new tracks (from stream2)
103 tryAddTrack(stream1, stream2.getAudioTracks()[0]); 111 tryAddTrack(stream1, stream2.getAudioTracks()[0]);
104 tryAddTrack(stream1, stream2.getVideoTracks()[0]); 112 tryAddTrack(stream1, stream2.getVideoTracks()[0]);
105 113
106 // verify added tracks 114 // verify added tracks
107 shouldBe('stream1.getAudioTracks().length', '2'); 115 shouldBe('stream1.getAudioTracks().length', '2');
108 shouldBe('stream1.getVideoTracks().length', '2'); 116 shouldBe('stream1.getVideoTracks().length', '2');
117 shouldBe('stream1.getTracks().length', '4');
109 118
110 // when all tracks have been removed, stream.ended should return true. 119 // when all tracks have been removed, stream.ended should return true.
111 tryRemoveTrack(stream2, stream2.getAudioTracks()[0]); 120 tryRemoveTrack(stream2, stream2.getAudioTracks()[0]);
112 tryRemoveTrack(stream2, stream2.getVideoTracks()[0]); 121 tryRemoveTrack(stream2, stream2.getVideoTracks()[0]);
113 shouldBeTrue('stream2.ended'); 122 shouldBeTrue('stream2.ended');
114 123
115 stream1.stop(); 124 stream1.stop();
116 125
117 shouldThrow('stream1.addTrack(audioTrack)'); 126 shouldThrow('stream1.addTrack(audioTrack)');
118 shouldThrow('stream1.removeTrack(audioTrack)'); 127 shouldThrow('stream1.removeTrack(audioTrack)');
119 128
120 setTimeout(finishJSTest, 0); 129 setTimeout(finishJSTest, 0);
121 } 130 }
122 131
123 function gotStream1(s) { 132 function gotStream1(s) {
124 stream1 = s; 133 stream1 = s;
125 getUserMedia({audio:true, video:true}, gotStream2); 134 getUserMedia({audio:true, video:true}, gotStream2);
126 } 135 }
127 136
128 getUserMedia({audio:true, video:true}, gotStream1); 137 getUserMedia({audio:true, video:true}, gotStream1);
129 138
130 window.jsTestIsAsync = true; 139 window.jsTestIsAsync = true;
131 window.successfullyParsed = true; 140 window.successfullyParsed = true;
132 </script> 141 </script>
133 </body> 142 </body>
134 </html> 143 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/mediastream/MediaStream-add-remove-tracks-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698