OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> | 4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> |
5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
6 | 6 |
7 function cubemapFaces(gl) { | 7 function cubemapFaces(gl) { |
8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, | 8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, |
9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, | 9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, |
10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, | 10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 " missing from depth track getSettings()."); | 109 " missing from depth track getSettings()."); |
110 } | 110 } |
111 } | 111 } |
112 reportTestSuccess(); | 112 reportTestSuccess(); |
113 }, | 113 }, |
114 failedCallback); | 114 failedCallback); |
115 }, | 115 }, |
116 failedCallback); | 116 failedCallback); |
117 } | 117 } |
118 | 118 |
| 119 function testGetStreamByVideoKindConstraint(constraint, kind) { |
| 120 return new Promise(function(resolve, reject) { |
| 121 getStreamOfVideoKind(constraint).then(function(stream) { |
| 122 if (stream.getVideoTracks().length != 1) { |
| 123 return reject("Expected one " + kind + " track, got " + |
| 124 stream.getVideoTracks().length + |
| 125 " when using constraint " + JSON.stringify(constraint)); |
| 126 } |
| 127 var track = stream.getVideoTracks()[0]; |
| 128 if (track.getSettings().videoKind != kind) { |
| 129 return reject("Expected " + kind + " track, got " + |
| 130 track.getSettings().videoKind + |
| 131 " when using constraint " + JSON.stringify(constraint)); |
| 132 } |
| 133 return resolve(); |
| 134 }, |
| 135 failedCallback); |
| 136 }); |
| 137 } |
| 138 |
| 139 function getStreamsByVideoKind() { |
| 140 console.log('Calling getStreamsByVideoKind'); |
| 141 var cases = [{constraint: {exact: "depth"}, kind: "depth"}, |
| 142 {constraint: {exact: "color"}, kind: "color"}]; |
| 143 var tests = []; |
| 144 for (var i in cases) { |
| 145 var test_case = cases[i]; |
| 146 tests.push(testGetStreamByVideoKindConstraint(test_case.constraint, |
| 147 test_case.kind)); |
| 148 } |
| 149 Promise.all(tests).then(reportTestSuccess, reason => { |
| 150 failedCallback({name: reason}); |
| 151 }); |
| 152 } |
| 153 |
| 154 function getStreamsByVideoKindNoDepth() { |
| 155 console.log('Calling getStreamsByVideoKindNoDepth'); |
| 156 testGetStreamByVideoKindConstraint({exact: "color"}, "color") |
| 157 .then(function() { |
| 158 // Getting a depth stream should fail. |
| 159 getStreamOfVideoKind({exact: "depth"}).then(function(stream) { |
| 160 return failedCallback({name: "Expected to fail, got depth instead."}); |
| 161 }, function() { |
| 162 // Getting a random stream should fail. |
| 163 getStreamOfVideoKind({exact: "fisheye"}).then(function(stream) { |
| 164 return failedCallback( |
| 165 {name: "Expected to fail, got fisheye instead."}); |
| 166 }, reportTestSuccess); |
| 167 }); |
| 168 }, reason => { |
| 169 failedCallback({name: reason}); |
| 170 }); |
| 171 } |
| 172 |
119 function depthStreamToRGBAUint8Texture() { | 173 function depthStreamToRGBAUint8Texture() { |
120 console.log('Calling depthStreamToRGBAUint8Texture'); | 174 console.log('Calling depthStreamToRGBAUint8Texture'); |
121 getFake16bitStream().then(function(stream) { | 175 getFake16bitStream().then(function(stream) { |
122 detectVideoInLocalView1(stream, function() { | 176 detectVideoInLocalView1(stream, function() { |
123 testVideoToRGBA8Texture('local-view-1', function() { | 177 testVideoToRGBA8Texture('local-view-1', function() { |
124 stream.getVideoTracks()[0].stop(); | 178 stream.getVideoTracks()[0].stop(); |
125 waitForVideoToStop('local-view-1'); | 179 waitForVideoToStop('local-view-1'); |
126 }, failedCallback); | 180 }, failedCallback); |
127 }); | 181 }); |
128 }, | 182 }, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 <tr> | 470 <tr> |
417 <td><video id="local-view-1" width="96" height="96" autoplay | 471 <td><video id="local-view-1" width="96" height="96" autoplay |
418 style="display:none"></video></td> | 472 style="display:none"></video></td> |
419 <!-- The canvas is used to detect when video starts and stops. --> | 473 <!-- The canvas is used to detect when video starts and stops. --> |
420 <td><canvas id="local-view-1-canvas" width="96" height="96" | 474 <td><canvas id="local-view-1-canvas" width="96" height="96" |
421 style="display:none"></canvas></td> | 475 style="display:none"></canvas></td> |
422 </tr> | 476 </tr> |
423 </table> | 477 </table> |
424 </body> | 478 </body> |
425 </html> | 479 </html> |
OLD | NEW |