Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / cc / base / float_quad_unittest.cc
blob64c448c0d5a19a5939e1dc8b02676d0cd4d63865
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].Skew(0.00000000001f, 0.0f);
22 rectilinear_trans[5].Skew(0.0f, 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].Skew(0.00001f, 0.0f);
50 non_rectilinear_trans[9].Skew(0.0f, 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