Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/mojo-helpers.js"></script> | |
| 5 <script src="resources/mock-imagecapture.js"></script> | |
| 6 <body> | |
| 7 <canvas id='canvas' width=10 height=10/> | |
| 8 </body> | |
| 9 <script> | |
| 10 | |
| 11 var canvas = document.getElementById('canvas'); | |
| 12 var context = canvas.getContext("2d"); | |
| 13 context.fillStyle = "red"; | |
| 14 context.fillRect(0, 0, 10, 10); | |
| 15 | |
| 16 // This test verifies that ImageCapture.setOptions() rejects if any passed | |
| 17 // option is unsupported or outside its allowed range. | |
| 18 var makePromiseTest = function(getOption) { | |
| 19 promise_test(function(t) { | |
| 20 var theMock = null; | |
| 21 var theCapturer = null; | |
| 22 return mockImageCaptureReady | |
| 23 .then(mock => { | |
| 24 theMock = mock; | |
| 25 theMock.capabilities().red_eye_reduction = 0; | |
| 26 | |
| 27 var stream = canvas.captureStream(); | |
| 28 return new ImageCapture(stream.getVideoTracks()[0]); | |
| 29 }, | |
| 30 error => { | |
| 31 assert_unreached("Error creating MockImageCapture: " + error); | |
| 32 }) | |
| 33 .then(capturer => { | |
| 34 theCapturer = capturer; | |
| 35 return capturer.getPhotoCapabilities(); | |
| 36 }) | |
| 37 .then(c => { | |
| 38 const options = getOption(theMock.capabilities()); | |
| 39 return promise_rejects(t, "NotSupportedError", | |
| 40 theCapturer.setOptions(options)); | |
| 41 }); | |
| 42 }); | |
| 43 }; | |
| 44 | |
| 45 const optionsGenerators = [ | |
| 46 (capabilities) => { return { redEyeReduction : true }; }, | |
|
Reilly Grant (use Gerrit)
2017/05/15 16:50:48
Does the following not work?
capabilities => { re
mcasas
2017/05/15 18:18:49
The latter works.
| |
| 47 (capabilities) => { return { imageHeight : capabilities.height.max + 1 }; }, | |
| 48 (capabilities) => { return { imageHeight : capabilities.height.min - 1 }; }, | |
| 49 (capabilities) => { return { imageWidth : capabilities.width.max + 1 }; }, | |
| 50 (capabilities) => { return { imageWidth : capabilities.width.min - 1 }; }, | |
| 51 (capabilities) => { return { fillLightMode : "off" }; }, | |
| 52 ]; | |
| 53 | |
| 54 for (key in optionsGenerators) { | |
| 55 generate_tests( | |
| 56 makePromiseTest, | |
| 57 [[ 'ImageCapture.setOptions(options) rejects with bad options, #' + key, | |
| 58 optionsGenerators[key] ]]); | |
| 59 } | |
| 60 | |
| 61 </script> | |
| OLD | NEW |