Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/metadata/image_orientation_unittest.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/metadata/image_orientation_unittest.js b/ui/file_manager/file_manager/foreground/js/metadata/image_orientation_unittest.js |
| index a3d94969af51bd4ecc5cc24161e1a13f7ef2ce98..da7bf85a08ec479ef866024652c47cc9e1d3c12b 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/metadata/image_orientation_unittest.js |
| +++ b/ui/file_manager/file_manager/foreground/js/metadata/image_orientation_unittest.js |
| @@ -41,3 +41,46 @@ function testCancelImageOrientation() { |
| var destinationImageData = destinationContext.getImageData(0, 0, 1, 2); |
| assertArrayEquals([255, 0, 0, 100, 0, 0, 0, 100], destinationImageData.data); |
| } |
| + |
| +function assertImageOrientationEquals(expected, actual) { |
| + assertEquals(expected.a, actual.a); |
| + assertEquals(expected.b, actual.b); |
| + assertEquals(expected.c, actual.c); |
| + assertEquals(expected.d, actual.d); |
| +} |
| + |
| +function testFromRotationAndScale() { |
| + var rotate90 = {scaleX: 1, scaleY: 1, rotate90: 1}; |
| + var flipX = {scaleX: -1, scaleY: 1, rotate90: 0 }; |
| + var flipY = {scaleX: 1, scaleY: -1, rotate90: 0 }; |
| + var flipBoth = {scaleX: -1, scaleY: -1, rotate90: 0}; |
| + var rotate180 = {scaleX: 1, scaleY: 1, rotate90: 2}; |
| + var rotateAndFlipX = {scaleX: -1, scaleY: 1, rotate90: 1}; |
|
yamaguchi
2017/02/16 14:01:18
In CSS transformations, this means
"rotate 90[deg]
|
| + var rotateAndFlipY = {scaleX: 1, scaleY: -1, rotate90: 1}; |
| + var rotate1080 = {scaleX: 1, scaleY: 1, rotate90: 12}; |
| + var flipBothAndRotate180 = {scaleX: -1, scaleY: -1, rotate90: 2}; |
| + /* |
| + The image coordinate system is aligned to the screen. (Y+ pointing down) |
| + O----> e_x ^ |
| + | rotate 90 CCW | e'_x = (0, -1) = (a, c) |
| + | =====> | |
| + V e_y O----> e'_y = (1, 0) = (b, d) |
| + */ |
| + assertImageOrientationEquals(new ImageOrientation(0, 1, -1, 0), |
| + ImageOrientation.fromRotationAndScale(rotate90)); |
| + assertImageOrientationEquals(new ImageOrientation(-1, 0, 0, 1), |
| + ImageOrientation.fromRotationAndScale(flipX)); |
| + assertImageOrientationEquals(new ImageOrientation(1, 0, 0, -1), |
| + ImageOrientation.fromRotationAndScale(flipY)); |
| + assertImageOrientationEquals(new ImageOrientation(-1, 0, 0, -1), |
| + ImageOrientation.fromRotationAndScale(flipBoth)); |
| + assertImageOrientationEquals(new ImageOrientation(-1, 0, 0, -1), |
| + ImageOrientation.fromRotationAndScale(rotate180)); |
| + assertImageOrientationEquals(new ImageOrientation(0, 1, 1, 0), |
| + ImageOrientation.fromRotationAndScale(rotateAndFlipX)); |
| + assertImageOrientationEquals(new ImageOrientation(0, -1, -1, 0), |
| + ImageOrientation.fromRotationAndScale(rotateAndFlipY)); |
| + assertTrue(ImageOrientation.fromRotationAndScale(flipBothAndRotate180) |
| + .isIdentity()); |
| + assertTrue(ImageOrientation.fromRotationAndScale(rotate1080).isIdentity()); |
| +} |