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

Side by Side Diff: cc/resources/layer_quad_unittest.cc

Issue 1533773002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2e
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « cc/resources/layer_quad.cc ('k') | cc/resources/platform_color.h » ('j') | 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 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.
4
5 #include "cc/resources/layer_quad.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/geometry/quad_f.h"
9
10 namespace cc {
11 namespace {
12
13 TEST(LayerQuadTest, QuadFConversion) {
14 gfx::PointF p1(-0.5f, -0.5f);
15 gfx::PointF p2(0.5f, -0.5f);
16 gfx::PointF p3(0.5f, 0.5f);
17 gfx::PointF p4(-0.5f, 0.5f);
18
19 gfx::QuadF quad_cw(p1, p2, p3, p4);
20 LayerQuad layer_quad_cw(quad_cw);
21 EXPECT_EQ(layer_quad_cw.ToQuadF(), quad_cw);
22
23 gfx::QuadF quad_ccw(p1, p4, p3, p2);
24 LayerQuad layer_quad_ccw(quad_ccw);
25 EXPECT_EQ(layer_quad_ccw.ToQuadF(), quad_ccw);
26 }
27
28 TEST(LayerQuadTest, Inflate) {
29 gfx::PointF p1(-0.5f, -0.5f);
30 gfx::PointF p2(0.5f, -0.5f);
31 gfx::PointF p3(0.5f, 0.5f);
32 gfx::PointF p4(-0.5f, 0.5f);
33
34 gfx::QuadF quad(p1, p2, p3, p4);
35 LayerQuad layer_quad(quad);
36 quad.Scale(2.f, 2.f);
37 layer_quad.Inflate(0.5f);
38 EXPECT_EQ(layer_quad.ToQuadF(), quad);
39 }
40
41 TEST(LayerQuadTest, Degenerate) {
42 gfx::QuadF quad;
43 gfx::PointF p1(1.0f, 1.0f);
44 gfx::PointF p2(0.0f, 1.0f);
45 gfx::PointF p3(1.0f, 0.0f);
46 gfx::QuadF triangle(p1, p2, p3, p1);
47
48 LayerQuad::Edge e1d(p1, p1);
49 LayerQuad::Edge e2d(p2, p2);
50 LayerQuad::Edge e2(p1, p2);
51 LayerQuad::Edge e3(p2, p3);
52 LayerQuad::Edge e4(p3, p1);
53 EXPECT_TRUE(e1d.degenerate());
54 EXPECT_TRUE(e2d.degenerate());
55 EXPECT_FALSE(e2.degenerate());
56 EXPECT_FALSE(e3.degenerate());
57 EXPECT_FALSE(e4.degenerate());
58
59 LayerQuad degenerate_quad(e1d, e2d, e2, e3);
60 // With more than one degenerate edge, we expect the quad to be zero.
61 EXPECT_EQ(quad, degenerate_quad.ToQuadF());
62
63 LayerQuad triangle_quad(e1d, e2, e3, e4);
64 // With only one degenerate edge, we expect the quad to be a triangle.
65 EXPECT_EQ(triangle, triangle_quad.ToQuadF());
66 }
67
68 } // namespace
69 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/layer_quad.cc ('k') | cc/resources/platform_color.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698