Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMMatrixTest.cpp

Issue 2771683005: Revert of Move geometry interface files to geometry directory. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 V8TestingScope scope;
15 DOMMatrixInit init;
16
17 EXPECT_FALSE(init.hasA());
18 EXPECT_FALSE(init.hasB());
19 EXPECT_FALSE(init.hasC());
20 EXPECT_FALSE(init.hasD());
21 EXPECT_FALSE(init.hasE());
22 EXPECT_FALSE(init.hasF());
23 EXPECT_FALSE(init.hasM11());
24 EXPECT_FALSE(init.hasM12());
25 EXPECT_FALSE(init.hasM21());
26 EXPECT_FALSE(init.hasM22());
27 EXPECT_FALSE(init.hasM41());
28 EXPECT_FALSE(init.hasM42());
29
30 init.setA(1.0);
31 init.setB(2.0);
32 init.setC(3.0);
33 init.setD(4.0);
34 init.setE(5.0);
35 init.setF(6.0);
36
37 EXPECT_TRUE(init.hasA());
38 EXPECT_TRUE(init.hasB());
39 EXPECT_TRUE(init.hasC());
40 EXPECT_TRUE(init.hasD());
41 EXPECT_TRUE(init.hasE());
42 EXPECT_TRUE(init.hasF());
43 EXPECT_FALSE(init.hasM11());
44 EXPECT_FALSE(init.hasM12());
45 EXPECT_FALSE(init.hasM21());
46 EXPECT_FALSE(init.hasM22());
47 EXPECT_FALSE(init.hasM41());
48 EXPECT_FALSE(init.hasM42());
49
50 DOMMatrix::fromMatrix(init, scope.getExceptionState());
51
52 EXPECT_TRUE(init.hasA());
53 EXPECT_TRUE(init.hasB());
54 EXPECT_TRUE(init.hasC());
55 EXPECT_TRUE(init.hasD());
56 EXPECT_TRUE(init.hasE());
57 EXPECT_TRUE(init.hasF());
58 EXPECT_TRUE(init.hasM11());
59 EXPECT_TRUE(init.hasM12());
60 EXPECT_TRUE(init.hasM21());
61 EXPECT_TRUE(init.hasM22());
62 EXPECT_TRUE(init.hasM41());
63 EXPECT_TRUE(init.hasM42());
64 EXPECT_EQ(1.0, init.m11());
65 EXPECT_EQ(2.0, init.m12());
66 EXPECT_EQ(3.0, init.m21());
67 EXPECT_EQ(4.0, init.m22());
68 EXPECT_EQ(5.0, init.m41());
69 EXPECT_EQ(6.0, init.m42());
70 }
71
72 TEST(DOMMatrixTest, FixupWithFallback) {
73 V8TestingScope scope;
74 DOMMatrixInit init;
75
76 EXPECT_FALSE(init.hasA());
77 EXPECT_FALSE(init.hasB());
78 EXPECT_FALSE(init.hasC());
79 EXPECT_FALSE(init.hasD());
80 EXPECT_FALSE(init.hasE());
81 EXPECT_FALSE(init.hasF());
82 EXPECT_FALSE(init.hasM11());
83 EXPECT_FALSE(init.hasM12());
84 EXPECT_FALSE(init.hasM21());
85 EXPECT_FALSE(init.hasM22());
86 EXPECT_FALSE(init.hasM41());
87 EXPECT_FALSE(init.hasM42());
88
89 DOMMatrix::fromMatrix(init, scope.getExceptionState());
90
91 EXPECT_TRUE(init.hasM11());
92 EXPECT_TRUE(init.hasM12());
93 EXPECT_TRUE(init.hasM21());
94 EXPECT_TRUE(init.hasM22());
95 EXPECT_TRUE(init.hasM41());
96 EXPECT_TRUE(init.hasM42());
97 EXPECT_EQ(1.0, init.m11());
98 EXPECT_EQ(0.0, init.m12());
99 EXPECT_EQ(0.0, init.m21());
100 EXPECT_EQ(1.0, init.m22());
101 EXPECT_EQ(0.0, init.m41());
102 EXPECT_EQ(0.0, init.m42());
103 }
104
105 TEST(DOMMatrixTest, ThrowExceptionIfTwoValuesAreDifferent) {
106 V8TestingScope scope;
107 {
108 DOMMatrixInit init;
109 init.setA(1.0);
110 init.setM11(2.0);
111 DOMMatrix::fromMatrix(init, scope.getExceptionState());
112 EXPECT_TRUE(scope.getExceptionState().hadException());
113 }
114 {
115 DOMMatrixInit init;
116 init.setB(1.0);
117 init.setM12(2.0);
118 DOMMatrix::fromMatrix(init, scope.getExceptionState());
119 EXPECT_TRUE(scope.getExceptionState().hadException());
120 }
121 {
122 DOMMatrixInit init;
123 init.setC(1.0);
124 init.setM21(2.0);
125 DOMMatrix::fromMatrix(init, scope.getExceptionState());
126 EXPECT_TRUE(scope.getExceptionState().hadException());
127 }
128 {
129 DOMMatrixInit init;
130 init.setD(1.0);
131 init.setM22(2.0);
132 DOMMatrix::fromMatrix(init, scope.getExceptionState());
133 EXPECT_TRUE(scope.getExceptionState().hadException());
134 }
135 {
136 DOMMatrixInit init;
137 init.setE(1.0);
138 init.setM41(2.0);
139 DOMMatrix::fromMatrix(init, scope.getExceptionState());
140 EXPECT_TRUE(scope.getExceptionState().hadException());
141 }
142 {
143 DOMMatrixInit init;
144 init.setF(1.0);
145 init.setM42(2.0);
146 DOMMatrix::fromMatrix(init, scope.getExceptionState());
147 EXPECT_TRUE(scope.getExceptionState().hadException());
148 }
149 }
150
151 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl ('k') | third_party/WebKit/Source/core/dom/DOMPoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698