summaryrefslogtreecommitdiffstats
path: root/cc/layer_quad_unittest.cc
blob: 34e79d9894e69d4b26060d5e3c9188ca89668443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 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/layer_quad.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/quad_f.h"

namespace cc {
namespace {

TEST(LayerQuadTest, QuadFConversion)
{
    gfx::PointF p1(-0.5, -0.5);
    gfx::PointF p2( 0.5, -0.5);
    gfx::PointF p3( 0.5,  0.5);
    gfx::PointF p4(-0.5,  0.5);

    gfx::QuadF quadCW(p1, p2, p3, p4);
    LayerQuad layerQuadCW(quadCW);
    EXPECT_TRUE(layerQuadCW.ToQuadF() == quadCW);

    gfx::QuadF quadCCW(p1, p4, p3, p2);
    LayerQuad layerQuadCCW(quadCCW);
    EXPECT_TRUE(layerQuadCCW.ToQuadF() == quadCCW);
}

TEST(LayerQuadTest, Inflate)
{
    gfx::PointF p1(-0.5, -0.5);
    gfx::PointF p2( 0.5, -0.5);
    gfx::PointF p3( 0.5,  0.5);
    gfx::PointF p4(-0.5,  0.5);

    gfx::QuadF quad(p1, p2, p3, p4);
    LayerQuad layerQuad(quad);
    quad.Scale(2, 2);
    layerQuad.inflate(0.5);
    EXPECT_TRUE(layerQuad.ToQuadF() == quad);
}

}  // namespace
}  // namespace cc