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

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

Issue 2283363003: GeometryInterface: Add DOMMatrixInit and fromMatrix(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
15 V8TestingScope scope;
16 DOMMatrixInit init;
17
18 EXPECT_FALSE(init.hasA());
zino 2016/09/14 12:39:43 I fixed the test. (https://github.com/google/googl
19 EXPECT_FALSE(init.hasB());
20 EXPECT_FALSE(init.hasC());
21 EXPECT_FALSE(init.hasD());
22 EXPECT_FALSE(init.hasE());
23 EXPECT_FALSE(init.hasF());
24 EXPECT_FALSE(init.hasM11());
25 EXPECT_FALSE(init.hasM12());
26 EXPECT_FALSE(init.hasM21());
27 EXPECT_FALSE(init.hasM22());
28 EXPECT_FALSE(init.hasM41());
29 EXPECT_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_TRUE(init.hasA());
39 EXPECT_TRUE(init.hasB());
40 EXPECT_TRUE(init.hasC());
41 EXPECT_TRUE(init.hasD());
42 EXPECT_TRUE(init.hasE());
43 EXPECT_TRUE(init.hasF());
44 EXPECT_FALSE(init.hasM11());
45 EXPECT_FALSE(init.hasM12());
46 EXPECT_FALSE(init.hasM21());
47 EXPECT_FALSE(init.hasM22());
48 EXPECT_FALSE(init.hasM41());
49 EXPECT_FALSE(init.hasM42());
50
51 DOMMatrix::fromMatrix(init, scope.getExceptionState());
52
53 EXPECT_TRUE(init.hasA());
54 EXPECT_TRUE(init.hasB());
55 EXPECT_TRUE(init.hasC());
56 EXPECT_TRUE(init.hasD());
57 EXPECT_TRUE(init.hasE());
58 EXPECT_TRUE(init.hasF());
59 EXPECT_TRUE(init.hasM11());
60 EXPECT_TRUE(init.hasM12());
61 EXPECT_TRUE(init.hasM21());
62 EXPECT_TRUE(init.hasM22());
63 EXPECT_TRUE(init.hasM41());
64 EXPECT_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_FALSE(init.hasA());
79 EXPECT_FALSE(init.hasB());
80 EXPECT_FALSE(init.hasC());
81 EXPECT_FALSE(init.hasD());
82 EXPECT_FALSE(init.hasE());
83 EXPECT_FALSE(init.hasF());
84 EXPECT_FALSE(init.hasM11());
85 EXPECT_FALSE(init.hasM12());
86 EXPECT_FALSE(init.hasM21());
87 EXPECT_FALSE(init.hasM22());
88 EXPECT_FALSE(init.hasM41());
89 EXPECT_FALSE(init.hasM42());
90
91 DOMMatrix::fromMatrix(init, scope.getExceptionState());
92
93 EXPECT_TRUE(init.hasM11());
94 EXPECT_TRUE(init.hasM12());
95 EXPECT_TRUE(init.hasM21());
96 EXPECT_TRUE(init.hasM22());
97 EXPECT_TRUE(init.hasM41());
98 EXPECT_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_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_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_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_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_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_TRUE(scope.getExceptionState().hadException());
151 }
152 }
153
154 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698