| OLD | NEW |
| 1 B<!DOCTYPE html> | 1 B<!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <!-- Image Capture Browser Test --> | 4 <!-- Image Capture Browser Test --> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 7 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| 8 <script> | 8 <script> |
| 9 const HEIGHT = 180; |
| 10 const WIDTH = 320; |
| 9 | 11 |
| 10 // Runs an ImageCapture.getPhotoCapabilities(). | 12 // Runs an ImageCapture.getPhotoCapabilities(). |
| 11 function testCreateAndGetCapabilities() { | 13 function testCreateAndGetCapabilities() { |
| 12 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } }; | 14 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } }; |
| 13 navigator.mediaDevices.getUserMedia({"video" : constraints}) | 15 navigator.mediaDevices.getUserMedia({"video" : constraints}) |
| 14 .then(stream => { | 16 .then(stream => { |
| 15 assertEquals('video', stream.getVideoTracks()[0].kind); | 17 assertEquals('video', stream.getVideoTracks()[0].kind); |
| 16 return new ImageCapture(stream.getVideoTracks()[0]); | 18 return new ImageCapture(stream.getVideoTracks()[0]); |
| 17 }) | 19 }) |
| 18 .then(capturer => { | 20 .then(capturer => { |
| 19 return capturer.getPhotoCapabilities(); | 21 return capturer.getPhotoCapabilities(); |
| 20 }) | 22 }) |
| 21 .then(capabilities => { | 23 .then(capabilities => { |
| 22 assertNotEquals(0, capabilities.imageHeight.min); | 24 assertNotEquals(0, capabilities.imageHeight.min); |
| 23 assertNotEquals(0, capabilities.imageHeight.current); | 25 assertNotEquals(0, capabilities.imageHeight.current); |
| 24 assertNotEquals(0, capabilities.imageHeight.max); | 26 assertNotEquals(0, capabilities.imageHeight.max); |
| 25 assertNotEquals(0, capabilities.imageWidth.min); | 27 assertNotEquals(0, capabilities.imageWidth.min); |
| 26 assertNotEquals(0, capabilities.imageWidth.current); | 28 assertNotEquals(0, capabilities.imageWidth.current); |
| 27 assertNotEquals(0, capabilities.imageWidth.max); | 29 assertNotEquals(0, capabilities.imageWidth.max); |
| 28 assertNotEquals(0, capabilities.zoom.min); | 30 assertNotEquals(0, capabilities.zoom.min); |
| 29 assertNotEquals(0, capabilities.zoom.current); | 31 assertNotEquals(0, capabilities.zoom.current); |
| 30 assertNotEquals(0, capabilities.zoom.max); | 32 assertNotEquals(0, capabilities.zoom.max); |
| 31 | 33 |
| 32 reportTestSuccess(); | 34 reportTestSuccess(); |
| 33 }) | 35 }) |
| 34 .catch(err => { | 36 .catch(err => { |
| 35 return failTest(err.toString()); | 37 return failTest(err.toString()); |
| 36 }); | 38 }); |
| 37 } | 39 } |
| 38 | 40 |
| 39 // Runs an ImageCapture.takePhoto(). | 41 // Runs an ImageCapture.takePhoto(). |
| 40 function testCreateAndTakePhoto() { | 42 function testCreateAndTakePhoto() { |
| 41 const constraints = { mandatory: { maxHeight: 180, maxWidth: 320 } }; | 43 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } }; |
| 42 navigator.mediaDevices.getUserMedia({"video" : constraints}) | 44 navigator.mediaDevices.getUserMedia({"video" : constraints}) |
| 43 .then(stream => { | 45 .then(stream => { |
| 44 assertEquals('video', stream.getVideoTracks()[0].kind); | 46 assertEquals('video', stream.getVideoTracks()[0].kind); |
| 45 return new ImageCapture(stream.getVideoTracks()[0]); | 47 return new ImageCapture(stream.getVideoTracks()[0]); |
| 46 }) | 48 }) |
| 47 .then(capturer => { | 49 .then(capturer => { |
| 48 return capturer.takePhoto(); | 50 return capturer.takePhoto(); |
| 49 }) | 51 }) |
| 50 .then(blob => { | 52 .then(blob => { |
| 51 assertTrue(blob.type != undefined); | 53 assertTrue(blob.type != undefined); |
| 52 assertNotEquals(0, blob.size); | 54 assertNotEquals(0, blob.size); |
| 53 | 55 |
| 54 reportTestSuccess(); | 56 reportTestSuccess(); |
| 55 }) | 57 }) |
| 56 .catch(err => { | 58 .catch(err => { |
| 57 return failTest(err.toString()); | 59 return failTest(err.toString()); |
| 58 }); | 60 }); |
| 59 } | 61 } |
| 60 | 62 |
| 63 // Runs an ImageCapture.grabFrame(). |
| 64 function testCreateAndGrabFrame() { |
| 65 const constraints = { mandatory: { maxHeight: HEIGHT, maxWidth: WIDTH } }; |
| 66 navigator.mediaDevices.getUserMedia({"video" : constraints}) |
| 67 .then(stream => { |
| 68 assertEquals('video', stream.getVideoTracks()[0].kind); |
| 69 return new ImageCapture(stream.getVideoTracks()[0]); |
| 70 }) |
| 71 .then(capturer => { |
| 72 return capturer.grabFrame(); |
| 73 }) |
| 74 .then(imageBitmap => { |
| 75 assertEquals(WIDTH, imageBitmap.width); |
| 76 assertEquals(HEIGHT, imageBitmap.height); |
| 77 |
| 78 reportTestSuccess(); |
| 79 }) |
| 80 .catch(err => { |
| 81 return failTest(err.toString()); |
| 82 }); |
| 83 } |
| 84 |
| 61 </script> | 85 </script> |
| 62 </body> | 86 </body> |
| 63 </html> | 87 </html> |
| OLD | NEW |