Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <!-- Image Capture Browser Test --> | |
| 5 </head> | |
| 6 <body> | |
| 7 <video id='video' autoplay></video> | |
| 8 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | |
| 9 <script> | |
| 10 | |
| 11 // Runs an ImageCapture.getPhotoCapabilities(). | |
| 12 function testCreateAndGetCapabilities() { | |
| 13 var hasVideoInputDevice = false; | |
| 14 navigator.mediaDevices.enumerateDevices() | |
| 15 .then(devices => { | |
| 16 devices.forEach(function(device) { | |
| 17 if (device.kind === "videoinput") | |
| 18 hasVideoInputDevice = true; | |
| 19 }); | |
| 20 | |
| 21 if (!hasVideoInputDevice) | |
| 22 return Promise.reject("no video devices"); | |
| 23 }) | |
| 24 .catch(err => { | |
| 25 return failTest('Error enumerating devices: ' + err.toString()); | |
| 26 }); | |
| 27 | |
| 28 | |
| 29 navigator.mediaDevices.getUserMedia({"video" : true}) | |
| 30 .then(stream => { | |
| 31 document.getElementById('video').src = URL.createObjectURL(stream); | |
| 32 assertEquals('video', stream.getVideoTracks()[0].kind); | |
| 33 | |
| 34 return new ImageCapture(stream.getVideoTracks()[0]); | |
| 35 }) | |
| 36 .then(capturer => { | |
| 37 // getUserMedia() returns relatively fast, allowing for ImageCapture to | |
| 38 // be constructed, but the underlying VideoCaptureDevice is still under | |
| 39 // construction in its own thread. Need to wait yikes! | |
|
phoglund_chromium
2016/07/28 14:07:49
This _will_ be flaky.
I recommend you write this
mcasas
2016/07/29 00:00:50
Actually, I've have a deeper thought: a user would
| |
| 40 setTimeout(function() { | |
| 41 capturer.getPhotoCapabilities() | |
| 42 .then(capabilities => { | |
| 43 assertNotEquals(0, capabilities.imageHeight.min); | |
| 44 assertNotEquals(0, capabilities.imageHeight.current); | |
| 45 assertNotEquals(0, capabilities.imageHeight.max); | |
| 46 assertNotEquals(0, capabilities.imageWidth.min); | |
| 47 assertNotEquals(0, capabilities.imageWidth.current); | |
| 48 assertNotEquals(0, capabilities.imageWidth.max); | |
| 49 assertNotEquals(0, capabilities.zoom.min); | |
| 50 assertNotEquals(0, capabilities.zoom.current); | |
| 51 assertNotEquals(0, capabilities.zoom.max); | |
| 52 reportTestSuccess(); | |
| 53 }) | |
| 54 .catch(err => { | |
| 55 return failTest(err.toString()); | |
| 56 }); | |
| 57 }, 500); | |
| 58 }) | |
| 59 .catch(err => { | |
| 60 return failTest(err.toString()); | |
| 61 }); | |
| 62 } | |
| 63 | |
| 64 </script> | |
| 65 </body> | |
| 66 </html> | |
| OLD | NEW |