Removed unused icon resources from app_list.
[chromium-blink-merge.git] / ui / gfx / geometry / point3_unittest.cc
blobd8a7f19b276231f8b6c538e1ce79f9f7f4dab6d2
1 // Copyright (c) 2012 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 "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/geometry/point3_f.h"
9 namespace gfx {
11 TEST(Point3Test, VectorArithmetic) {
12 gfx::Point3F a(1.6f, 5.1f, 3.2f);
13 gfx::Vector3dF v1(3.1f, -3.2f, 9.3f);
14 gfx::Vector3dF v2(-8.1f, 1.2f, 3.3f);
16 static const struct {
17 gfx::Point3F expected;
18 gfx::Point3F actual;
19 } tests[] = {
20 { gfx::Point3F(4.7f, 1.9f, 12.5f), a + v1 },
21 { gfx::Point3F(-1.5f, 8.3f, -6.1f), a - v1 },
22 { a, a - v1 + v1 },
23 { a, a + v1 - v1 },
24 { a, a + gfx::Vector3dF() },
25 { gfx::Point3F(12.8f, 0.7f, 9.2f), a + v1 - v2 },
26 { gfx::Point3F(-9.6f, 9.5f, -2.8f), a - v1 + v2 }
29 for (size_t i = 0; i < arraysize(tests); ++i)
30 EXPECT_EQ(tests[i].expected.ToString(),
31 tests[i].actual.ToString());
33 a += v1;
34 EXPECT_EQ(Point3F(4.7f, 1.9f, 12.5f).ToString(), a.ToString());
36 a -= v2;
37 EXPECT_EQ(Point3F(12.8f, 0.7f, 9.2f).ToString(), a.ToString());
40 TEST(Point3Test, VectorFromPoints) {
41 gfx::Point3F a(1.6f, 5.2f, 3.2f);
42 gfx::Vector3dF v1(3.1f, -3.2f, 9.3f);
44 gfx::Point3F b(a + v1);
45 EXPECT_EQ((b - a).ToString(), v1.ToString());
48 TEST(Point3Test, Scale) {
49 EXPECT_EQ(Point3F().ToString(), ScalePoint(Point3F(), 2.f).ToString());
50 EXPECT_EQ(Point3F().ToString(),
51 ScalePoint(Point3F(), 2.f, 2.f, 2.f).ToString());
53 EXPECT_EQ(Point3F(2.f, -2.f, 4.f).ToString(),
54 ScalePoint(Point3F(1.f, -1.f, 2.f), 2.f).ToString());
55 EXPECT_EQ(Point3F(2.f, -3.f, 8.f).ToString(),
56 ScalePoint(Point3F(1.f, -1.f, 2.f), 2.f, 3.f, 4.f).ToString());
58 Point3F zero;
59 zero.Scale(2.f);
60 zero.Scale(6.f, 3.f, 1.5f);
61 EXPECT_EQ(Point3F().ToString(), zero.ToString());
63 Point3F point(1.f, -1.f, 2.f);
64 point.Scale(2.f);
65 point.Scale(6.f, 3.f, 1.5f);
66 EXPECT_EQ(Point3F(12.f, -6.f, 6.f).ToString(), point.ToString());
69 } // namespace gfx