OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/dom/DOMMatrix.h" |
| 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/V8BindingForTesting.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 TEST(DOMMatrixTest, Fixup) |
| 14 { |
| 15 V8TestingScope scope; |
| 16 DOMMatrixInit init; |
| 17 |
| 18 EXPECT_EQ(false, init.hasA()); |
| 19 EXPECT_EQ(false, init.hasB()); |
| 20 EXPECT_EQ(false, init.hasC()); |
| 21 EXPECT_EQ(false, init.hasD()); |
| 22 EXPECT_EQ(false, init.hasE()); |
| 23 EXPECT_EQ(false, init.hasF()); |
| 24 EXPECT_EQ(false, init.hasM11()); |
| 25 EXPECT_EQ(false, init.hasM12()); |
| 26 EXPECT_EQ(false, init.hasM21()); |
| 27 EXPECT_EQ(false, init.hasM22()); |
| 28 EXPECT_EQ(false, init.hasM41()); |
| 29 EXPECT_EQ(false, init.hasM42()); |
| 30 |
| 31 init.setA(1.0); |
| 32 init.setB(2.0); |
| 33 init.setC(3.0); |
| 34 init.setD(4.0); |
| 35 init.setE(5.0); |
| 36 init.setF(6.0); |
| 37 |
| 38 EXPECT_EQ(true, init.hasA()); |
| 39 EXPECT_EQ(true, init.hasB()); |
| 40 EXPECT_EQ(true, init.hasC()); |
| 41 EXPECT_EQ(true, init.hasD()); |
| 42 EXPECT_EQ(true, init.hasE()); |
| 43 EXPECT_EQ(true, init.hasF()); |
| 44 EXPECT_EQ(false, init.hasM11()); |
| 45 EXPECT_EQ(false, init.hasM12()); |
| 46 EXPECT_EQ(false, init.hasM21()); |
| 47 EXPECT_EQ(false, init.hasM22()); |
| 48 EXPECT_EQ(false, init.hasM41()); |
| 49 EXPECT_EQ(false, init.hasM42()); |
| 50 |
| 51 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 52 |
| 53 EXPECT_EQ(true, init.hasA()); |
| 54 EXPECT_EQ(true, init.hasB()); |
| 55 EXPECT_EQ(true, init.hasC()); |
| 56 EXPECT_EQ(true, init.hasD()); |
| 57 EXPECT_EQ(true, init.hasE()); |
| 58 EXPECT_EQ(true, init.hasF()); |
| 59 EXPECT_EQ(true, init.hasM11()); |
| 60 EXPECT_EQ(true, init.hasM12()); |
| 61 EXPECT_EQ(true, init.hasM21()); |
| 62 EXPECT_EQ(true, init.hasM22()); |
| 63 EXPECT_EQ(true, init.hasM41()); |
| 64 EXPECT_EQ(true, init.hasM42()); |
| 65 EXPECT_EQ(1.0, init.m11()); |
| 66 EXPECT_EQ(2.0, init.m12()); |
| 67 EXPECT_EQ(3.0, init.m21()); |
| 68 EXPECT_EQ(4.0, init.m22()); |
| 69 EXPECT_EQ(5.0, init.m41()); |
| 70 EXPECT_EQ(6.0, init.m42()); |
| 71 } |
| 72 |
| 73 TEST(DOMMatrixTest, FixupWithFallback) |
| 74 { |
| 75 V8TestingScope scope; |
| 76 DOMMatrixInit init; |
| 77 |
| 78 EXPECT_EQ(false, init.hasA()); |
| 79 EXPECT_EQ(false, init.hasB()); |
| 80 EXPECT_EQ(false, init.hasC()); |
| 81 EXPECT_EQ(false, init.hasD()); |
| 82 EXPECT_EQ(false, init.hasE()); |
| 83 EXPECT_EQ(false, init.hasF()); |
| 84 EXPECT_EQ(false, init.hasM11()); |
| 85 EXPECT_EQ(false, init.hasM12()); |
| 86 EXPECT_EQ(false, init.hasM21()); |
| 87 EXPECT_EQ(false, init.hasM22()); |
| 88 EXPECT_EQ(false, init.hasM41()); |
| 89 EXPECT_EQ(false, init.hasM42()); |
| 90 |
| 91 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 92 |
| 93 EXPECT_EQ(true, init.hasM11()); |
| 94 EXPECT_EQ(true, init.hasM12()); |
| 95 EXPECT_EQ(true, init.hasM21()); |
| 96 EXPECT_EQ(true, init.hasM22()); |
| 97 EXPECT_EQ(true, init.hasM41()); |
| 98 EXPECT_EQ(true, init.hasM42()); |
| 99 EXPECT_EQ(1.0, init.m11()); |
| 100 EXPECT_EQ(0.0, init.m12()); |
| 101 EXPECT_EQ(0.0, init.m21()); |
| 102 EXPECT_EQ(1.0, init.m22()); |
| 103 EXPECT_EQ(0.0, init.m41()); |
| 104 EXPECT_EQ(0.0, init.m42()); |
| 105 } |
| 106 |
| 107 TEST(DOMMatrixTest, ThrowExceptionIfTwoValuesAreDifferent) |
| 108 { |
| 109 V8TestingScope scope; |
| 110 { |
| 111 DOMMatrixInit init; |
| 112 init.setA(1.0); |
| 113 init.setM11(2.0); |
| 114 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 115 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 116 } |
| 117 { |
| 118 DOMMatrixInit init; |
| 119 init.setB(1.0); |
| 120 init.setM12(2.0); |
| 121 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 122 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 123 } |
| 124 { |
| 125 DOMMatrixInit init; |
| 126 init.setC(1.0); |
| 127 init.setM21(2.0); |
| 128 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 129 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 130 } |
| 131 { |
| 132 DOMMatrixInit init; |
| 133 init.setD(1.0); |
| 134 init.setM22(2.0); |
| 135 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 136 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 137 } |
| 138 { |
| 139 DOMMatrixInit init; |
| 140 init.setE(1.0); |
| 141 init.setM41(2.0); |
| 142 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 143 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 144 } |
| 145 { |
| 146 DOMMatrixInit init; |
| 147 init.setF(1.0); |
| 148 init.setM42(2.0); |
| 149 DOMMatrix::fromMatrix(init, scope.getExceptionState()); |
| 150 EXPECT_EQ(true, scope.getExceptionState().hadException()); |
| 151 } |
| 152 } |
| 153 |
| 154 } // namespace blink |
OLD | NEW |