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

Unified Diff: cc/base/float_quad_unittest.cc

Issue 1531403002: Revert "Delete CC." (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « cc/base/completion_event.h ('k') | cc/base/math_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/float_quad_unittest.cc
diff --git a/cc/base/float_quad_unittest.cc b/cc/base/float_quad_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6d9ce02f86298a5a56a55c4e8b4e16e3b85f961a
--- /dev/null
+++ b/cc/base/float_quad_unittest.cc
@@ -0,0 +1,62 @@
+// Copyright 2011 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 "cc/base/math_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/quad_f.h"
+#include "ui/gfx/geometry/rect_f.h"
+#include "ui/gfx/transform.h"
+
+namespace cc {
+namespace {
+
+// TODO(danakj) Move this test to ui/gfx/ when we don't need MathUtil::MapQuad.
+TEST(FloatQuadTest, IsRectilinearTest) {
+ const int kNumRectilinear = 8;
+ gfx::Transform rectilinear_trans[kNumRectilinear];
+ rectilinear_trans[1].Rotate(90.f);
+ rectilinear_trans[2].Rotate(180.f);
+ rectilinear_trans[3].Rotate(270.f);
+ rectilinear_trans[4].SkewX(0.00000000001f);
+ rectilinear_trans[5].SkewY(0.00000000001f);
+ rectilinear_trans[6].Scale(0.00001f, 0.00001f);
+ rectilinear_trans[6].Rotate(180.f);
+ rectilinear_trans[7].Scale(100000.f, 100000.f);
+ rectilinear_trans[7].Rotate(180.f);
+
+ gfx::QuadF original(
+ gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
+
+ for (int i = 0; i < kNumRectilinear; ++i) {
+ bool clipped = false;
+ gfx::QuadF quad =
+ MathUtil::MapQuad(rectilinear_trans[i], original, &clipped);
+ ASSERT_TRUE(!clipped) << "case " << i;
+ EXPECT_TRUE(quad.IsRectilinear()) << "case " << i;
+ }
+
+ const int kNumNonRectilinear = 10;
+ gfx::Transform non_rectilinear_trans[kNumNonRectilinear];
+ non_rectilinear_trans[0].Rotate(359.9999f);
+ non_rectilinear_trans[1].Rotate(0.0000001f);
+ non_rectilinear_trans[2].Rotate(89.9999f);
+ non_rectilinear_trans[3].Rotate(90.00001f);
+ non_rectilinear_trans[4].Rotate(179.9999f);
+ non_rectilinear_trans[5].Rotate(180.00001f);
+ non_rectilinear_trans[6].Rotate(269.9999f);
+ non_rectilinear_trans[7].Rotate(270.0001f);
+ non_rectilinear_trans[8].SkewX(0.00001f);
+ non_rectilinear_trans[9].SkewY(0.00001f);
+
+ for (int i = 0; i < kNumNonRectilinear; ++i) {
+ bool clipped = false;
+ gfx::QuadF quad =
+ MathUtil::MapQuad(non_rectilinear_trans[i], original, &clipped);
+ ASSERT_TRUE(!clipped) << "case " << i;
+ EXPECT_FALSE(quad.IsRectilinear()) << "case " << i;
+ }
+}
+
+} // namespace
+} // namespace cc
« no previous file with comments | « cc/base/completion_event.h ('k') | cc/base/math_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698