Re-land: C++ readability review
[chromium-blink-merge.git] / cc / base / float_quad_unittest.cc
blob6d9ce02f86298a5a56a55c4e8b4e16e3b85f961a
1 // Copyright 2011 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.
5 #include "cc/base/math_util.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/geometry/quad_f.h"
8 #include "ui/gfx/geometry/rect_f.h"
9 #include "ui/gfx/transform.h"
11 namespace cc {
12 namespace {
14 // TODO(danakj) Move this test to ui/gfx/ when we don't need MathUtil::MapQuad.
15 TEST(FloatQuadTest, IsRectilinearTest) {
16 const int kNumRectilinear = 8;
17 gfx::Transform rectilinear_trans[kNumRectilinear];
18 rectilinear_trans[1].Rotate(90.f);
19 rectilinear_trans[2].Rotate(180.f);
20 rectilinear_trans[3].Rotate(270.f);
21 rectilinear_trans[4].SkewX(0.00000000001f);
22 rectilinear_trans[5].SkewY(0.00000000001f);
23 rectilinear_trans[6].Scale(0.00001f, 0.00001f);
24 rectilinear_trans[6].Rotate(180.f);
25 rectilinear_trans[7].Scale(100000.f, 100000.f);
26 rectilinear_trans[7].Rotate(180.f);
28 gfx::QuadF original(
29 gfx::RectF(0.01010101f, 0.01010101f, 100.01010101f, 100.01010101f));
31 for (int i = 0; i < kNumRectilinear; ++i) {
32 bool clipped = false;
33 gfx::QuadF quad =
34 MathUtil::MapQuad(rectilinear_trans[i], original, &clipped);
35 ASSERT_TRUE(!clipped) << "case " << i;
36 EXPECT_TRUE(quad.IsRectilinear()) << "case " << i;
39 const int kNumNonRectilinear = 10;
40 gfx::Transform non_rectilinear_trans[kNumNonRectilinear];
41 non_rectilinear_trans[0].Rotate(359.9999f);
42 non_rectilinear_trans[1].Rotate(0.0000001f);
43 non_rectilinear_trans[2].Rotate(89.9999f);
44 non_rectilinear_trans[3].Rotate(90.00001f);
45 non_rectilinear_trans[4].Rotate(179.9999f);
46 non_rectilinear_trans[5].Rotate(180.00001f);
47 non_rectilinear_trans[6].Rotate(269.9999f);
48 non_rectilinear_trans[7].Rotate(270.0001f);
49 non_rectilinear_trans[8].SkewX(0.00001f);
50 non_rectilinear_trans[9].SkewY(0.00001f);
52 for (int i = 0; i < kNumNonRectilinear; ++i) {
53 bool clipped = false;
54 gfx::QuadF quad =
55 MathUtil::MapQuad(non_rectilinear_trans[i], original, &clipped);
56 ASSERT_TRUE(!clipped) << "case " << i;
57 EXPECT_FALSE(quad.IsRectilinear()) << "case " << i;
61 } // namespace
62 } // namespace cc