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 const meteringModeNames = ["none", "manual", "single-shot", "continuous"]; |
| 12 const fillLightModeNames = ["none", "off", "auto", "flash", "torch"]; |
| 13 |
| 14 // This test verifies that we can all MediaStreamTrack.applyConstraints(), with |
| 15 // a mock Mojo service implementation. |
| 16 |
| 17 async_test(function(t) { |
| 18 var canvas = document.getElementById('canvas'); |
| 19 var context = canvas.getContext("2d"); |
| 20 context.fillStyle = "red"; |
| 21 context.fillRect(0, 0, 10, 10); |
| 22 |
| 23 const constraints = { advanced : [{ whiteBalanceMode : "manual", |
| 24 exposureMode : "continuous", |
| 25 focusMode : "single-shot", |
| 26 |
| 27 exposureCompensation : 133.77, |
| 28 colorTemperature : 6000, |
| 29 iso : 120.0, |
| 30 |
| 31 brightness : 3, |
| 32 contrast : 4, |
| 33 saturation : 5, |
| 34 sharpness : 6, |
| 35 |
| 36 zoom : 3.141592 |
| 37 // TODO: torch https://crbug.com/700607. |
| 38 }]}; |
| 39 |
| 40 var theMock = null; |
| 41 mockImageCaptureReady |
| 42 .then(mock => { |
| 43 theMock = mock; |
| 44 var stream = canvas.captureStream(); |
| 45 var videoTrack = stream.getVideoTracks()[0]; |
| 46 |
| 47 return videoTrack.applyConstraints(constraints); |
| 48 }) |
| 49 .catch(error => { |
| 50 assert_unreached("Error creating MockImageCapture: " + error.message); |
| 51 }) |
| 52 .then(function() { |
| 53 assert_equals(constraints.advanced[0].whiteBalanceMode, |
| 54 meteringModeNames[theMock.options().white_balance_mode], |
| 55 'whiteBalanceMode'); |
| 56 assert_equals(constraints.advanced[0].exposureMode, |
| 57 meteringModeNames[theMock.options().exposure_mode], |
| 58 'exposureMode'); |
| 59 assert_equals(constraints.advanced[0].focusMode, |
| 60 meteringModeNames[theMock.options().focus_mode], |
| 61 'focusMode'); |
| 62 |
| 63 assert_equals(constraints.advanced[0].exposureCompensation, |
| 64 theMock.options().exposure_compensation, |
| 65 'exposure_compensation'); |
| 66 assert_equals(constraints.advanced[0].colorTemperature, |
| 67 theMock.options().color_temperature, 'color_temperature'); |
| 68 assert_equals(constraints.advanced[0].iso, theMock.options().iso, 'iso'); |
| 69 |
| 70 assert_equals(constraints.advanced[0].brightness, |
| 71 theMock.options().brightness, 'brightness value'); |
| 72 assert_equals(constraints.advanced[0].contrast, |
| 73 theMock.options().contrast, 'constrast value'); |
| 74 assert_equals(constraints.advanced[0].saturation, |
| 75 theMock.options().saturation, 'saturation value'); |
| 76 assert_equals(constraints.advanced[0].sharpness, |
| 77 theMock.options().sharpness, 'sharpness value'); |
| 78 |
| 79 t.done(); |
| 80 }) |
| 81 .catch(error => { |
| 82 assert_unreached("applyConstraints(): " + error.message); |
| 83 }) |
| 84 |
| 85 }, 'exercises MediaStreamTrack.applyConstraints(constraints)'); |
| 86 |
| 87 </script> |
OLD | NEW |