| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/point_base.h" | 5 #include "ui/gfx/point_base.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "ui/gfx/point_conversions.h" | 10 #include "ui/gfx/point_conversions.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 { Point(-10, 9), a - v1 + v2 } | 67 { Point(-10, 9), a - v1 + v2 } |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) | 70 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) |
| 71 EXPECT_EQ(tests[i].expected.ToString(), tests[i].actual.ToString()); | 71 EXPECT_EQ(tests[i].expected.ToString(), tests[i].actual.ToString()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST(PointTest, OffsetFromPoint) { | 74 TEST(PointTest, OffsetFromPoint) { |
| 75 Point a(1, 5); | 75 Point a(1, 5); |
| 76 Point b(-20, 8); | 76 Point b(-20, 8); |
| 77 EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), b.OffsetFrom(a).ToString()); | |
| 78 EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), (b - a).ToString()); | 77 EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), (b - a).ToString()); |
| 79 } | 78 } |
| 80 | 79 |
| 81 TEST(PointTest, ToRoundedPoint) { | 80 TEST(PointTest, ToRoundedPoint) { |
| 82 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0, 0))); | 81 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0, 0))); |
| 83 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.0001f, 0.0001f))); | 82 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.0001f, 0.0001f))); |
| 84 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.4999f, 0.4999f))); | 83 EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.4999f, 0.4999f))); |
| 85 EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.5f, 0.5f))); | 84 EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.5f, 0.5f))); |
| 86 EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.9999f, 0.9999f))); | 85 EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.9999f, 0.9999f))); |
| 87 | 86 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 114 zero.Scale(3, 1.5); | 113 zero.Scale(3, 1.5); |
| 115 | 114 |
| 116 one.Scale(2); | 115 one.Scale(2); |
| 117 one.Scale(3, 1.5); | 116 one.Scale(3, 1.5); |
| 118 | 117 |
| 119 EXPECT_EQ(PointF().ToString(), zero.ToString()); | 118 EXPECT_EQ(PointF().ToString(), zero.ToString()); |
| 120 EXPECT_EQ(PointF(6, -3).ToString(), one.ToString()); | 119 EXPECT_EQ(PointF(6, -3).ToString(), one.ToString()); |
| 121 } | 120 } |
| 122 | 121 |
| 123 } // namespace gfx | 122 } // namespace gfx |
| OLD | NEW |