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 MediaStreamTrack.applyConstraints() rejects if any | |
| 17 // passed constraint is unsupported or outside its allowed range. | |
| 18 var makePromiseTest = function(getConstraint) { | |
| 19 promise_test(function(t) { | |
| 20 var theMock = null; | |
| 21 var videoTrack = null; | |
| 22 return mockImageCaptureReady | |
| 23 .then(mock => { | |
| 24 theMock = mock; | |
| 25 theMock.capabilities().supports_torch = false; | |
| 26 | |
| 27 var stream = canvas.captureStream(); | |
| 28 videoTrack = stream.getVideoTracks()[0]; | |
| 29 | |
| 30 // |videoTrack|'s capabilities gathering, just like the actual capture, | |
| 31 // is a process kicked off right after creation, we introduce a small | |
| 32 // delay to allow for those to be collected, since they are needed to | |
| 33 // understand which constraints are supported in applyConstraints(). | |
| 34 // TODO(mcasas): this shouldn't be needed, https://crbug.com/711524. | |
| 35 return new Promise(resolve => setTimeout(resolve, 100)); | |
| 36 }, | |
| 37 error => { | |
| 38 assert_unreached("Error creating MockImageCapture: " + error); | |
| 39 }) | |
| 40 .then(function() { | |
| 41 const constraints = { | |
| 42 advanced : [ getConstraint(theMock.capabilities()) ] | |
| 43 }; | |
| 44 return promise_rejects(t, "NotSupportedError", | |
| 45 videoTrack.applyConstraints(constraints)); | |
| 46 }); | |
| 47 }); | |
| 48 }; | |
| 49 | |
| 50 const constraintGenerators = [ | |
| 51 capabilities => ({ whiteBalanceMode : "manual" }), | |
|
Reilly Grant (use Gerrit)
2017/05/15 18:27:48
no spaces before the colon
mcasas
2017/05/15 19:57:08
Done.
| |
| 52 capabilities => ({ exposureMode : "manual" }), | |
| 53 capabilities => ({ focusMode : "continuous" }), | |
| 54 capabilities => ({ | |
| 55 exposureCompensation : capabilities.exposure_compensation.max + 1 | |
| 56 }), | |
| 57 capabilities => ({ | |
| 58 exposureCompensation : capabilities.exposure_compensation.min - 1 | |
| 59 }), | |
| 60 capabilities => ({ | |
| 61 colorTemperature : capabilities.color_temperature.max + 1 | |
| 62 }), | |
| 63 capabilities => ({ | |
| 64 colorTemperature : capabilities.color_temperature.min - 1 | |
| 65 }), | |
| 66 capabilities => ({ iso : capabilities.iso.max + 1 }), | |
| 67 capabilities => ({ iso : capabilities.iso.min - 1 }), | |
| 68 capabilities => ({ brightness : capabilities.brightness.max + 1 }), | |
| 69 capabilities => ({ brightness : capabilities.brightness.min - 1 }), | |
| 70 capabilities => ({ contrast : capabilities.contrast.max + 1 }), | |
| 71 capabilities => ({ contrast : capabilities.contrast.min - 1 }), | |
| 72 capabilities => ({ saturation : capabilities.saturation.max + 1 }), | |
| 73 capabilities => ({ saturation : capabilities.saturation.min - 1 }), | |
| 74 capabilities => ({ sharpness : capabilities.sharpness.max + 1 }), | |
| 75 capabilities => ({ sharpness : capabilities.sharpness.min - 1 }), | |
| 76 capabilities => ({ zoom : capabilities.zoom.max + 1 }), | |
| 77 capabilities => ({ zoom : capabilities.zoom.min - 1 }), | |
| 78 capabilities => ({ torch : true }), | |
| 79 ]; | |
| 80 | |
| 81 for (key in constraintGenerators) { | |
| 82 generate_tests( | |
| 83 makePromiseTest, [[ | |
| 84 'MediaStreamTrack.applyConstraints(constraints) rejects with bad' + | |
| 85 ' constraints, #' + key, | |
| 86 constraintGenerators[key] | |
| 87 ]]); | |
| 88 } | |
| 89 | |
| 90 </script> | |
| OLD | NEW |