Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html |
| diff --git a/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html b/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..86bfea5893fe9e457161158e1770e7eef08fdab1 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html |
| @@ -0,0 +1,71 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../resources/mojo-helpers.js"></script> |
| +<script src="resources/mock-imagecapture.js"></script> |
| +<body> |
| +<canvas id='canvas' width=10 height=10/> |
| +</body> |
| +<script> |
| + |
| +const fillLightModeNames = ["off", "auto", "flash"]; |
| + |
| +// This test verifies that ImageCapture can call takePhoto with a PhotoSettings |
| +// argument, with a mock Mojo interface implementation. |
| + |
| +async_test(function(t) { |
|
Reilly Grant (use Gerrit)
2017/05/05 17:18:00
nit: why not a promise_test?
mcasas
2017/05/05 18:43:08
It could perfectly be one, I think I wanted to cat
|
| + var canvas = document.getElementById('canvas'); |
| + var context = canvas.getContext("2d"); |
| + context.fillStyle = "red"; |
| + context.fillRect(0, 0, 10, 10); |
| + var stream = canvas.captureStream(); |
| + |
| + var theMock = null; |
| + const optionsDict = { imageWidth : 1080, |
| + imageHeight : 100, |
| + redEyeReduction : true, |
| + fillLightMode : "flash" |
| + }; |
| + mockImageCaptureReady |
| + .then(mock => { |
| + theMock = mock; |
| + return new ImageCapture(stream.getVideoTracks()[0]); |
| + }, |
| + error => { |
| + assert_unreached("Error creating MockImageCapture: " + error); |
| + }) |
| + .then(capturer => { |
| + return capturer.takePhoto(optionsDict); |
| + }) |
| + .then(blob => { |
| + // JS Blob is almost-opaque, can only check |type| and |size|. |
| + assert_equals(blob.type, 'image/cat'); |
| + assert_equals(blob.size, 2); |
| + |
| + assert_equals(true, theMock.options().has_width, 'has_width'); |
| + assert_equals(optionsDict.imageWidth, theMock.options().width, 'width'); |
| + assert_equals(true, theMock.options().has_height, 'has_height'); |
| + assert_equals(optionsDict.imageHeight, theMock.options().height, |
| + 'height'); |
| + |
| + // Depending on how mojo boolean packing in integers is arranged, this can |
| + // be a number instead of a boolean, compare directly. |
| + // TODO(mcasas): Revert to assert_equals() when yzshen@ has sorted it out. |
| + assert_true( |
| + optionsDict.redEyeReduction == theMock.options().red_eye_reduction, |
| + 'red_eye_reduction'); |
| + |
| + assert_equals(true, theMock.options().has_fill_light_mode, |
| + 'has_fill_light_mode'); |
| + assert_equals(optionsDict.fillLightMode, |
| + fillLightModeNames[theMock.options().fill_light_mode], |
| + 'fillLightMode'); |
| + |
| + t.done(); |
| + }) |
| + .catch(error => { |
| + assert_unreached("Error during takePhoto(): " + error.message); |
| + }); |
| +}, 'exercises ImageCapture.takePhoto(PhotoSettings dictionary)'); |
| + |
| +</script> |