| 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 fillLightModeNames = ["off", "auto", "flash"]; | |
| 12 | |
| 13 // This test verifies that ImageCapture can call setOptions()s, with a mock Mojo | |
| 14 // interface implementation. | |
| 15 async_test(function(t) { | |
| 16 var canvas = document.getElementById('canvas'); | |
| 17 var context = canvas.getContext("2d"); | |
| 18 context.fillStyle = "red"; | |
| 19 context.fillRect(0, 0, 10, 10); | |
| 20 var stream = canvas.captureStream(); | |
| 21 | |
| 22 var theMock = null; | |
| 23 const optionsDict = { imageWidth : 1080, | |
| 24 imageHeight : 100, | |
| 25 redEyeReduction : true, | |
| 26 fillLightMode : "flash" | |
| 27 }; | |
| 28 mockImageCaptureReady | |
| 29 .then(mock => { | |
| 30 theMock = mock; | |
| 31 return new ImageCapture(stream.getVideoTracks()[0]); | |
| 32 }, | |
| 33 error => { | |
| 34 assert_unreached("Error creating MockImageCapture: " + error); | |
| 35 }) | |
| 36 .then(capturer => { | |
| 37 return capturer.setOptions(optionsDict); | |
| 38 }) | |
| 39 .then(function() { | |
| 40 assert_equals(true, theMock.options().has_width, 'has_width'); | |
| 41 assert_equals(optionsDict.imageWidth, theMock.options().width, 'width'); | |
| 42 assert_equals(true, theMock.options().has_height, 'has_height'); | |
| 43 assert_equals(optionsDict.imageHeight, theMock.options().height, | |
| 44 'height'); | |
| 45 | |
| 46 // Depending on how mojo boolean packing in integers is arranged, this can | |
| 47 // be a number instead of a boolean, compare directly. | |
| 48 // TODO(mcasas): Revert to assert_equals() when yzshen@ has sorted it out. | |
| 49 assert_true( | |
| 50 optionsDict.redEyeReduction == theMock.options().red_eye_reduction, | |
| 51 'red_eye_reduction'); | |
| 52 | |
| 53 assert_equals(true, theMock.options().has_fill_light_mode, | |
| 54 'has_fill_light_mode'); | |
| 55 assert_equals(optionsDict.fillLightMode, | |
| 56 fillLightModeNames[theMock.options().fill_light_mode], | |
| 57 'fillLightMode'); | |
| 58 | |
| 59 t.done(); | |
| 60 }) | |
| 61 .catch(error => { | |
| 62 assert_unreached("Error during setOptions(): " + error.message); | |
| 63 }); | |
| 64 }, 'exercises ImageCapture.setOptions(options)'); | |
| 65 | |
| 66 </script> | |
| OLD | NEW |