Chromium Code Reviews| Index: content/test/data/media/image_capture_test.html |
| diff --git a/content/test/data/media/image_capture_test.html b/content/test/data/media/image_capture_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..163229482fdc05e410809ee56674d457889eaf55 |
| --- /dev/null |
| +++ b/content/test/data/media/image_capture_test.html |
| @@ -0,0 +1,66 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<!-- Image Capture Browser Test --> |
| +</head> |
| +<body> |
| + <video id='video' autoplay></video> |
| +<script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| +<script> |
| + |
| +// Runs an ImageCapture.getPhotoCapabilities(). |
| +function testCreateAndGetCapabilities() { |
| + var hasVideoInputDevice = false; |
| + navigator.mediaDevices.enumerateDevices() |
| + .then(devices => { |
| + devices.forEach(function(device) { |
| + if (device.kind === "videoinput") |
| + hasVideoInputDevice = true; |
| + }); |
| + |
| + if (!hasVideoInputDevice) |
| + return Promise.reject("no video devices"); |
| + }) |
| + .catch(err => { |
| + return failTest('Error enumerating devices: ' + err.toString()); |
| + }); |
| + |
| + |
| + navigator.mediaDevices.getUserMedia({"video" : true}) |
| + .then(stream => { |
| + document.getElementById('video').src = URL.createObjectURL(stream); |
| + assertEquals('video', stream.getVideoTracks()[0].kind); |
| + |
| + return new ImageCapture(stream.getVideoTracks()[0]); |
| + }) |
| + .then(capturer => { |
| + // getUserMedia() returns relatively fast, allowing for ImageCapture to |
| + // be constructed, but the underlying VideoCaptureDevice is still under |
| + // 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
|
| + setTimeout(function() { |
| + capturer.getPhotoCapabilities() |
| + .then(capabilities => { |
| + assertNotEquals(0, capabilities.imageHeight.min); |
| + assertNotEquals(0, capabilities.imageHeight.current); |
| + assertNotEquals(0, capabilities.imageHeight.max); |
| + assertNotEquals(0, capabilities.imageWidth.min); |
| + assertNotEquals(0, capabilities.imageWidth.current); |
| + assertNotEquals(0, capabilities.imageWidth.max); |
| + assertNotEquals(0, capabilities.zoom.min); |
| + assertNotEquals(0, capabilities.zoom.current); |
| + assertNotEquals(0, capabilities.zoom.max); |
| + reportTestSuccess(); |
| + }) |
| + .catch(err => { |
| + return failTest(err.toString()); |
| + }); |
| + }, 500); |
| + }) |
| + .catch(err => { |
| + return failTest(err.toString()); |
| + }); |
| +} |
| + |
| +</script> |
| +</body> |
| +</html> |