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

Unified 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: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/DOMMatrixTest.cpp
diff --git a/third_party/WebKit/Source/core/dom/DOMMatrixTest.cpp b/third_party/WebKit/Source/core/dom/DOMMatrixTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d8d87b1efda15581669bd152852e347238f0b757
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/DOMMatrixTest.cpp
@@ -0,0 +1,154 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/DOMMatrix.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8BindingForTesting.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(DOMMatrixTest, Fixup)
+{
+ V8TestingScope scope;
+ DOMMatrixInit init;
+
+ EXPECT_EQ(false, init.hasA());
+ EXPECT_EQ(false, init.hasB());
+ EXPECT_EQ(false, init.hasC());
+ EXPECT_EQ(false, init.hasD());
+ EXPECT_EQ(false, init.hasE());
+ EXPECT_EQ(false, init.hasF());
+ EXPECT_EQ(false, init.hasM11());
+ EXPECT_EQ(false, init.hasM12());
+ EXPECT_EQ(false, init.hasM21());
+ EXPECT_EQ(false, init.hasM22());
+ EXPECT_EQ(false, init.hasM41());
+ EXPECT_EQ(false, init.hasM42());
+
+ init.setA(1.0);
+ init.setB(2.0);
+ init.setC(3.0);
+ init.setD(4.0);
+ init.setE(5.0);
+ init.setF(6.0);
+
+ EXPECT_EQ(true, init.hasA());
+ EXPECT_EQ(true, init.hasB());
+ EXPECT_EQ(true, init.hasC());
+ EXPECT_EQ(true, init.hasD());
+ EXPECT_EQ(true, init.hasE());
+ EXPECT_EQ(true, init.hasF());
+ EXPECT_EQ(false, init.hasM11());
+ EXPECT_EQ(false, init.hasM12());
+ EXPECT_EQ(false, init.hasM21());
+ EXPECT_EQ(false, init.hasM22());
+ EXPECT_EQ(false, init.hasM41());
+ EXPECT_EQ(false, init.hasM42());
+
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+
+ EXPECT_EQ(true, init.hasA());
+ EXPECT_EQ(true, init.hasB());
+ EXPECT_EQ(true, init.hasC());
+ EXPECT_EQ(true, init.hasD());
+ EXPECT_EQ(true, init.hasE());
+ EXPECT_EQ(true, init.hasF());
+ EXPECT_EQ(true, init.hasM11());
+ EXPECT_EQ(true, init.hasM12());
+ EXPECT_EQ(true, init.hasM21());
+ EXPECT_EQ(true, init.hasM22());
+ EXPECT_EQ(true, init.hasM41());
+ EXPECT_EQ(true, init.hasM42());
+ EXPECT_EQ(1.0, init.m11());
+ EXPECT_EQ(2.0, init.m12());
+ EXPECT_EQ(3.0, init.m21());
+ EXPECT_EQ(4.0, init.m22());
+ EXPECT_EQ(5.0, init.m41());
+ EXPECT_EQ(6.0, init.m42());
+}
+
+TEST(DOMMatrixTest, FixupWithFallback)
+{
+ V8TestingScope scope;
+ DOMMatrixInit init;
+
+ EXPECT_EQ(false, init.hasA());
+ EXPECT_EQ(false, init.hasB());
+ EXPECT_EQ(false, init.hasC());
+ EXPECT_EQ(false, init.hasD());
+ EXPECT_EQ(false, init.hasE());
+ EXPECT_EQ(false, init.hasF());
+ EXPECT_EQ(false, init.hasM11());
+ EXPECT_EQ(false, init.hasM12());
+ EXPECT_EQ(false, init.hasM21());
+ EXPECT_EQ(false, init.hasM22());
+ EXPECT_EQ(false, init.hasM41());
+ EXPECT_EQ(false, init.hasM42());
+
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+
+ EXPECT_EQ(true, init.hasM11());
+ EXPECT_EQ(true, init.hasM12());
+ EXPECT_EQ(true, init.hasM21());
+ EXPECT_EQ(true, init.hasM22());
+ EXPECT_EQ(true, init.hasM41());
+ EXPECT_EQ(true, init.hasM42());
+ EXPECT_EQ(1.0, init.m11());
+ EXPECT_EQ(0.0, init.m12());
+ EXPECT_EQ(0.0, init.m21());
+ EXPECT_EQ(1.0, init.m22());
+ EXPECT_EQ(0.0, init.m41());
+ EXPECT_EQ(0.0, init.m42());
+}
+
+TEST(DOMMatrixTest, ThrowExceptionIfTwoValuesAreDifferent)
+{
+ V8TestingScope scope;
+ {
+ DOMMatrixInit init;
+ init.setA(1.0);
+ init.setM11(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+ {
+ DOMMatrixInit init;
+ init.setB(1.0);
+ init.setM12(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+ {
+ DOMMatrixInit init;
+ init.setC(1.0);
+ init.setM21(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+ {
+ DOMMatrixInit init;
+ init.setD(1.0);
+ init.setM22(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+ {
+ DOMMatrixInit init;
+ init.setE(1.0);
+ init.setM41(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+ {
+ DOMMatrixInit init;
+ init.setF(1.0);
+ init.setM42(2.0);
+ DOMMatrix::fromMatrix(init, scope.getExceptionState());
+ EXPECT_EQ(true, scope.getExceptionState().hadException());
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698