summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 21:59:43 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-02 21:59:43 +0000
commit9afc08f962f070091117482d1287ee46c9e728c8 (patch)
tree8dcb6669064ec8b31f63ce3d788b5ee5f3a307d5
parentfc6fca11b24c4f01ce16e933d93c75735c18de8e (diff)
downloadchromium_src-9afc08f962f070091117482d1287ee46c9e728c8.zip
chromium_src-9afc08f962f070091117482d1287ee46c9e728c8.tar.gz
chromium_src-9afc08f962f070091117482d1287ee46c9e728c8.tar.bz2
ui/gfx: Put unittests back into gfx namespace.
TEST=ui_unittests R=sky@chromium.org Review URL: https://codereview.chromium.org/11360043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165761 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/gfx/point_unittest.cc122
-rw-r--r--ui/gfx/rect_unittest.cc393
-rw-r--r--ui/gfx/safe_integer_conversions_unittest.cc96
-rw-r--r--ui/gfx/size_unittest.cc157
-rw-r--r--ui/gfx/vector2d_unittest.cc80
5 files changed, 392 insertions, 456 deletions
diff --git a/ui/gfx/point_unittest.cc b/ui/gfx/point_unittest.cc
index a95b6cf..3a58e07 100644
--- a/ui/gfx/point_unittest.cc
+++ b/ui/gfx/point_unittest.cc
@@ -10,11 +10,11 @@
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/point_f.h"
-namespace ui {
+namespace gfx {
namespace {
-int TestPointF(const gfx::PointF& p) {
+int TestPointF(const PointF& p) {
return p.x();
}
@@ -22,98 +22,80 @@ int TestPointF(const gfx::PointF& p) {
TEST(PointTest, ToPointF) {
// Check that implicit conversion from integer to float compiles.
- gfx::Point a(10, 20);
+ Point a(10, 20);
float x = TestPointF(a);
EXPECT_EQ(x, a.x());
- gfx::PointF b(10, 20);
+ PointF b(10, 20);
EXPECT_EQ(a, b);
EXPECT_EQ(b, a);
}
TEST(PointTest, IsOrigin) {
- EXPECT_FALSE(gfx::Point(1, 0).IsOrigin());
- EXPECT_FALSE(gfx::Point(0, 1).IsOrigin());
- EXPECT_FALSE(gfx::Point(1, 2).IsOrigin());
- EXPECT_FALSE(gfx::Point(-1, 0).IsOrigin());
- EXPECT_FALSE(gfx::Point(0, -1).IsOrigin());
- EXPECT_FALSE(gfx::Point(-1, -2).IsOrigin());
- EXPECT_TRUE(gfx::Point(0, 0).IsOrigin());
-
- EXPECT_FALSE(gfx::PointF(0.1f, 0).IsOrigin());
- EXPECT_FALSE(gfx::PointF(0, 0.1f).IsOrigin());
- EXPECT_FALSE(gfx::PointF(0.1f, 2).IsOrigin());
- EXPECT_FALSE(gfx::PointF(-0.1f, 0).IsOrigin());
- EXPECT_FALSE(gfx::PointF(0, -0.1f).IsOrigin());
- EXPECT_FALSE(gfx::PointF(-0.1f, -2).IsOrigin());
- EXPECT_TRUE(gfx::PointF(0, 0).IsOrigin());
+ EXPECT_FALSE(Point(1, 0).IsOrigin());
+ EXPECT_FALSE(Point(0, 1).IsOrigin());
+ EXPECT_FALSE(Point(1, 2).IsOrigin());
+ EXPECT_FALSE(Point(-1, 0).IsOrigin());
+ EXPECT_FALSE(Point(0, -1).IsOrigin());
+ EXPECT_FALSE(Point(-1, -2).IsOrigin());
+ EXPECT_TRUE(Point(0, 0).IsOrigin());
+
+ EXPECT_FALSE(PointF(0.1f, 0).IsOrigin());
+ EXPECT_FALSE(PointF(0, 0.1f).IsOrigin());
+ EXPECT_FALSE(PointF(0.1f, 2).IsOrigin());
+ EXPECT_FALSE(PointF(-0.1f, 0).IsOrigin());
+ EXPECT_FALSE(PointF(0, -0.1f).IsOrigin());
+ EXPECT_FALSE(PointF(-0.1f, -2).IsOrigin());
+ EXPECT_TRUE(PointF(0, 0).IsOrigin());
}
TEST(PointTest, VectorArithmetic) {
- gfx::Point a(1, 5);
- gfx::Vector2d v1(3, -3);
- gfx::Vector2d v2(-8, 1);
+ Point a(1, 5);
+ Vector2d v1(3, -3);
+ Vector2d v2(-8, 1);
static const struct {
- gfx::Point expected;
- gfx::Point actual;
+ Point expected;
+ Point actual;
} tests[] = {
- { gfx::Point(4, 2), a + v1 },
- { gfx::Point(-2, 8), a - v1 },
+ { Point(4, 2), a + v1 },
+ { Point(-2, 8), a - v1 },
{ a, a - v1 + v1 },
{ a, a + v1 - v1 },
- { a, a + gfx::Vector2d() },
- { gfx::Point(12, 1), a + v1 - v2 },
- { gfx::Point(-10, 9), a - v1 + v2 }
+ { a, a + Vector2d() },
+ { Point(12, 1), a + v1 - v2 },
+ { Point(-10, 9), a - v1 + v2 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i)
- EXPECT_EQ(tests[i].expected.ToString(),
- tests[i].actual.ToString());
+ EXPECT_EQ(tests[i].expected.ToString(), tests[i].actual.ToString());
}
TEST(PointTest, OffsetFromPoint) {
- gfx::Point a(1, 5);
- gfx::Point b(-20, 8);
- EXPECT_EQ(gfx::Vector2d(-20 - 1, 8 - 5).ToString(),
- b.OffsetFrom(a).ToString());
- EXPECT_EQ(gfx::Vector2d(-20 - 1, 8 - 5).ToString(),
- (b - a).ToString());
+ Point a(1, 5);
+ Point b(-20, 8);
+ EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), b.OffsetFrom(a).ToString());
+ EXPECT_EQ(Vector2d(-20 - 1, 8 - 5).ToString(), (b - a).ToString());
}
TEST(PointTest, ToRoundedPoint) {
- EXPECT_EQ(gfx::Point(0, 0),
- gfx::ToRoundedPoint(gfx::PointF(0, 0)));
- EXPECT_EQ(gfx::Point(0, 0),
- gfx::ToRoundedPoint(gfx::PointF(0.0001f, 0.0001f)));
- EXPECT_EQ(gfx::Point(0, 0),
- gfx::ToRoundedPoint(gfx::PointF(0.4999f, 0.4999f)));
- EXPECT_EQ(gfx::Point(1, 1),
- gfx::ToRoundedPoint(gfx::PointF(0.5f, 0.5f)));
- EXPECT_EQ(gfx::Point(1, 1),
- gfx::ToRoundedPoint(gfx::PointF(0.9999f, 0.9999f)));
-
- EXPECT_EQ(gfx::Point(10, 10),
- gfx::ToRoundedPoint(gfx::PointF(10, 10)));
- EXPECT_EQ(gfx::Point(10, 10),
- gfx::ToRoundedPoint(gfx::PointF(10.0001f, 10.0001f)));
- EXPECT_EQ(gfx::Point(10, 10),
- gfx::ToRoundedPoint(gfx::PointF(10.4999f, 10.4999f)));
- EXPECT_EQ(gfx::Point(11, 11),
- gfx::ToRoundedPoint(gfx::PointF(10.5f, 10.5f)));
- EXPECT_EQ(gfx::Point(11, 11),
- gfx::ToRoundedPoint(gfx::PointF(10.9999f, 10.9999f)));
-
- EXPECT_EQ(gfx::Point(-10, -10),
- gfx::ToRoundedPoint(gfx::PointF(-10, -10)));
- EXPECT_EQ(gfx::Point(-10, -10),
- gfx::ToRoundedPoint(gfx::PointF(-10.0001f, -10.0001f)));
- EXPECT_EQ(gfx::Point(-10, -10),
- gfx::ToRoundedPoint(gfx::PointF(-10.4999f, -10.4999f)));
- EXPECT_EQ(gfx::Point(-11, -11),
- gfx::ToRoundedPoint(gfx::PointF(-10.5f, -10.5f)));
- EXPECT_EQ(gfx::Point(-11, -11),
- gfx::ToRoundedPoint(gfx::PointF(-10.9999f, -10.9999f)));
+ EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0, 0)));
+ EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.0001f, 0.0001f)));
+ EXPECT_EQ(Point(0, 0), ToRoundedPoint(PointF(0.4999f, 0.4999f)));
+ EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.5f, 0.5f)));
+ EXPECT_EQ(Point(1, 1), ToRoundedPoint(PointF(0.9999f, 0.9999f)));
+
+ EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10, 10)));
+ EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10.0001f, 10.0001f)));
+ EXPECT_EQ(Point(10, 10), ToRoundedPoint(PointF(10.4999f, 10.4999f)));
+ EXPECT_EQ(Point(11, 11), ToRoundedPoint(PointF(10.5f, 10.5f)));
+ EXPECT_EQ(Point(11, 11), ToRoundedPoint(PointF(10.9999f, 10.9999f)));
+
+ EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10, -10)));
+ EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10.0001f, -10.0001f)));
+ EXPECT_EQ(Point(-10, -10), ToRoundedPoint(PointF(-10.4999f, -10.4999f)));
+ EXPECT_EQ(Point(-11, -11), ToRoundedPoint(PointF(-10.5f, -10.5f)));
+ EXPECT_EQ(Point(-11, -11), ToRoundedPoint(PointF(-10.9999f, -10.9999f)));
}
-} // namespace ui
+} // namespace gfx
diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc
index 3d50495..a45fe5c 100644
--- a/ui/gfx/rect_unittest.cc
+++ b/ui/gfx/rect_unittest.cc
@@ -10,7 +10,7 @@
#include <limits>
-namespace ui {
+namespace gfx {
TEST(RectTest, Contains) {
static const struct ContainsCase {
@@ -35,8 +35,7 @@ TEST(RectTest, Contains) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) {
const ContainsCase& value = contains_cases[i];
- gfx::Rect rect(value.rect_x, value.rect_y,
- value.rect_width, value.rect_height);
+ Rect rect(value.rect_x, value.rect_y, value.rect_width, value.rect_height);
EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y));
}
}
@@ -63,8 +62,8 @@ TEST(RectTest, Intersects) {
{ 10, 10, 10, 10, 21, 15, 10, 10, false }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
EXPECT_EQ(tests[i].intersects, r1.Intersects(r2));
}
}
@@ -104,10 +103,10 @@ TEST(RectTest, Intersect) {
0, 0, 0, 0 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
- gfx::Rect ir = gfx::IntersectRects(r1, r2);
+ Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
+ Rect ir = IntersectRects(r1, r2);
EXPECT_EQ(r3.x(), ir.x());
EXPECT_EQ(r3.y(), ir.y());
EXPECT_EQ(r3.width(), ir.width());
@@ -153,10 +152,10 @@ TEST(RectTest, Union) {
2, 2, 2, 2 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
- gfx::Rect u = gfx::UnionRects(r1, r2);
+ Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
+ Rect u = UnionRects(r1, r2);
EXPECT_EQ(r3.x(), u.x());
EXPECT_EQ(r3.y(), u.y());
EXPECT_EQ(r3.width(), u.width());
@@ -165,12 +164,12 @@ TEST(RectTest, Union) {
}
TEST(RectTest, Equals) {
- ASSERT_TRUE(gfx::Rect(0, 0, 0, 0) == gfx::Rect(0, 0, 0, 0));
- ASSERT_TRUE(gfx::Rect(1, 2, 3, 4) == gfx::Rect(1, 2, 3, 4));
- ASSERT_FALSE(gfx::Rect(0, 0, 0, 0) == gfx::Rect(0, 0, 0, 1));
- ASSERT_FALSE(gfx::Rect(0, 0, 0, 0) == gfx::Rect(0, 0, 1, 0));
- ASSERT_FALSE(gfx::Rect(0, 0, 0, 0) == gfx::Rect(0, 1, 0, 0));
- ASSERT_FALSE(gfx::Rect(0, 0, 0, 0) == gfx::Rect(1, 0, 0, 0));
+ ASSERT_TRUE(Rect(0, 0, 0, 0) == Rect(0, 0, 0, 0));
+ ASSERT_TRUE(Rect(1, 2, 3, 4) == Rect(1, 2, 3, 4));
+ ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 0, 0, 1));
+ ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 0, 1, 0));
+ ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(0, 1, 0, 0));
+ ASSERT_FALSE(Rect(0, 0, 0, 0) == Rect(1, 0, 0, 0));
}
TEST(RectTest, AdjustToFit) {
@@ -205,10 +204,10 @@ TEST(RectTest, AdjustToFit) {
2, 2, 1, 1 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
- gfx::Rect u = r1;
+ Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3);
+ Rect u = r1;
u.AdjustToFit(r2);
EXPECT_EQ(r3.x(), u.x());
EXPECT_EQ(r3.y(), u.y());
@@ -218,159 +217,159 @@ TEST(RectTest, AdjustToFit) {
}
TEST(RectTest, Subtract) {
- gfx::Rect result;
+ Rect result;
// Matching
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(10, 10, 20, 20));
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(10, 10, 20, 20));
+ EXPECT_EQ(Rect(0, 0, 0, 0).ToString(), result.ToString());
// Contains
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(5, 5, 30, 30));
- EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(5, 5, 30, 30));
+ EXPECT_EQ(Rect(0, 0, 0, 0).ToString(), result.ToString());
// No intersection
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(30, 30, 30, 30));
- EXPECT_EQ(gfx::Rect(10, 10, 20, 20).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(30, 30, 30, 30));
+ EXPECT_EQ(Rect(10, 10, 20, 20).ToString(), result.ToString());
// Not a complete intersection in either direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(15, 15, 20, 20));
- EXPECT_EQ(gfx::Rect(10, 10, 20, 20).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(15, 15, 20, 20));
+ EXPECT_EQ(Rect(10, 10, 20, 20).ToString(), result.ToString());
// Complete intersection in the x-direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(10, 15, 20, 20));
- EXPECT_EQ(gfx::Rect(10, 10, 20, 5).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(10, 15, 20, 20));
+ EXPECT_EQ(Rect(10, 10, 20, 5).ToString(), result.ToString());
// Complete intersection in the x-direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(5, 15, 30, 20));
- EXPECT_EQ(gfx::Rect(10, 10, 20, 5).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(5, 15, 30, 20));
+ EXPECT_EQ(Rect(10, 10, 20, 5).ToString(), result.ToString());
// Complete intersection in the x-direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(5, 5, 30, 20));
- EXPECT_EQ(gfx::Rect(10, 25, 20, 5).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(5, 5, 30, 20));
+ EXPECT_EQ(Rect(10, 25, 20, 5).ToString(), result.ToString());
// Complete intersection in the y-direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(10, 10, 10, 30));
- EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(10, 10, 10, 30));
+ EXPECT_EQ(Rect(20, 10, 10, 20).ToString(), result.ToString());
// Complete intersection in the y-direction
- result = gfx::Rect(10, 10, 20, 20);
- result.Subtract(gfx::Rect(5, 5, 20, 30));
- EXPECT_EQ(gfx::Rect(25, 10, 5, 20).ToString(), result.ToString());
+ result = Rect(10, 10, 20, 20);
+ result.Subtract(Rect(5, 5, 20, 30));
+ EXPECT_EQ(Rect(25, 10, 5, 20).ToString(), result.ToString());
}
TEST(RectTest, IsEmpty) {
- EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).IsEmpty());
- EXPECT_TRUE(gfx::Rect(0, 0, 0, 0).size().IsEmpty());
- EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).IsEmpty());
- EXPECT_TRUE(gfx::Rect(0, 0, 10, 0).size().IsEmpty());
- EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).IsEmpty());
- EXPECT_TRUE(gfx::Rect(0, 0, 0, 10).size().IsEmpty());
- EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).IsEmpty());
- EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).size().IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 0, 0).IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 0, 0).size().IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 10, 0).IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 10, 0).size().IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 0, 10).IsEmpty());
+ EXPECT_TRUE(Rect(0, 0, 0, 10).size().IsEmpty());
+ EXPECT_FALSE(Rect(0, 0, 10, 10).IsEmpty());
+ EXPECT_FALSE(Rect(0, 0, 10, 10).size().IsEmpty());
}
TEST(RectTest, SplitVertically) {
- gfx::Rect left_half, right_half;
+ Rect left_half, right_half;
// Splitting when origin is (0, 0).
- gfx::Rect(0, 0, 20, 20).SplitVertically(&left_half, &right_half);
- EXPECT_TRUE(left_half == gfx::Rect(0, 0, 10, 20));
- EXPECT_TRUE(right_half == gfx::Rect(10, 0, 10, 20));
+ Rect(0, 0, 20, 20).SplitVertically(&left_half, &right_half);
+ EXPECT_TRUE(left_half == Rect(0, 0, 10, 20));
+ EXPECT_TRUE(right_half == Rect(10, 0, 10, 20));
// Splitting when origin is arbitrary.
- gfx::Rect(10, 10, 20, 10).SplitVertically(&left_half, &right_half);
- EXPECT_TRUE(left_half == gfx::Rect(10, 10, 10, 10));
- EXPECT_TRUE(right_half == gfx::Rect(20, 10, 10, 10));
+ Rect(10, 10, 20, 10).SplitVertically(&left_half, &right_half);
+ EXPECT_TRUE(left_half == Rect(10, 10, 10, 10));
+ EXPECT_TRUE(right_half == Rect(20, 10, 10, 10));
// Splitting a rectangle of zero width.
- gfx::Rect(10, 10, 0, 10).SplitVertically(&left_half, &right_half);
- EXPECT_TRUE(left_half == gfx::Rect(10, 10, 0, 10));
- EXPECT_TRUE(right_half == gfx::Rect(10, 10, 0, 10));
+ Rect(10, 10, 0, 10).SplitVertically(&left_half, &right_half);
+ EXPECT_TRUE(left_half == Rect(10, 10, 0, 10));
+ EXPECT_TRUE(right_half == Rect(10, 10, 0, 10));
// Splitting a rectangle of odd width.
- gfx::Rect(10, 10, 5, 10).SplitVertically(&left_half, &right_half);
- EXPECT_TRUE(left_half == gfx::Rect(10, 10, 2, 10));
- EXPECT_TRUE(right_half == gfx::Rect(12, 10, 3, 10));
+ Rect(10, 10, 5, 10).SplitVertically(&left_half, &right_half);
+ EXPECT_TRUE(left_half == Rect(10, 10, 2, 10));
+ EXPECT_TRUE(right_half == Rect(12, 10, 3, 10));
}
TEST(RectTest, CenterPoint) {
- gfx::Point center;
+ Point center;
// When origin is (0, 0).
- center = gfx::Rect(0, 0, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(10, 10));
+ center = Rect(0, 0, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == Point(10, 10));
// When origin is even.
- center = gfx::Rect(10, 10, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(20, 20));
+ center = Rect(10, 10, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == Point(20, 20));
// When origin is odd.
- center = gfx::Rect(11, 11, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(21, 21));
+ center = Rect(11, 11, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == Point(21, 21));
// When 0 width or height.
- center = gfx::Rect(10, 10, 0, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(10, 20));
- center = gfx::Rect(10, 10, 20, 0).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(20, 10));
+ center = Rect(10, 10, 0, 20).CenterPoint();
+ EXPECT_TRUE(center == Point(10, 20));
+ center = Rect(10, 10, 20, 0).CenterPoint();
+ EXPECT_TRUE(center == Point(20, 10));
// When an odd size.
- center = gfx::Rect(10, 10, 21, 21).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(20, 20));
+ center = Rect(10, 10, 21, 21).CenterPoint();
+ EXPECT_TRUE(center == Point(20, 20));
// When an odd size and position.
- center = gfx::Rect(11, 11, 21, 21).CenterPoint();
- EXPECT_TRUE(center == gfx::Point(21, 21));
+ center = Rect(11, 11, 21, 21).CenterPoint();
+ EXPECT_TRUE(center == Point(21, 21));
}
TEST(RectTest, CenterPointF) {
- gfx::PointF center;
+ PointF center;
// When origin is (0, 0).
- center = gfx::RectF(0, 0, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(10, 10));
+ center = RectF(0, 0, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == PointF(10, 10));
// When origin is even.
- center = gfx::RectF(10, 10, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(20, 20));
+ center = RectF(10, 10, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == PointF(20, 20));
// When origin is odd.
- center = gfx::RectF(11, 11, 20, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(21, 21));
+ center = RectF(11, 11, 20, 20).CenterPoint();
+ EXPECT_TRUE(center == PointF(21, 21));
// When 0 width or height.
- center = gfx::RectF(10, 10, 0, 20).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(10, 20));
- center = gfx::RectF(10, 10, 20, 0).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(20, 10));
+ center = RectF(10, 10, 0, 20).CenterPoint();
+ EXPECT_TRUE(center == PointF(10, 20));
+ center = RectF(10, 10, 20, 0).CenterPoint();
+ EXPECT_TRUE(center == PointF(20, 10));
// When an odd size.
- center = gfx::RectF(10, 10, 21, 21).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(20.5f, 20.5f));
+ center = RectF(10, 10, 21, 21).CenterPoint();
+ EXPECT_TRUE(center == PointF(20.5f, 20.5f));
// When an odd size and position.
- center = gfx::RectF(11, 11, 21, 21).CenterPoint();
- EXPECT_TRUE(center == gfx::PointF(21.5f, 21.5f));
+ center = RectF(11, 11, 21, 21).CenterPoint();
+ EXPECT_TRUE(center == PointF(21.5f, 21.5f));
}
TEST(RectTest, SharesEdgeWith) {
- gfx::Rect r(2, 3, 4, 5);
+ Rect r(2, 3, 4, 5);
// Must be non-overlapping
EXPECT_FALSE(r.SharesEdgeWith(r));
- gfx::Rect just_above(2, 1, 4, 2);
- gfx::Rect just_below(2, 8, 4, 2);
- gfx::Rect just_left(0, 3, 2, 5);
- gfx::Rect just_right(6, 3, 2, 5);
+ Rect just_above(2, 1, 4, 2);
+ Rect just_below(2, 8, 4, 2);
+ Rect just_left(0, 3, 2, 5);
+ Rect just_right(6, 3, 2, 5);
EXPECT_TRUE(r.SharesEdgeWith(just_above));
EXPECT_TRUE(r.SharesEdgeWith(just_below));
@@ -378,16 +377,16 @@ TEST(RectTest, SharesEdgeWith) {
EXPECT_TRUE(r.SharesEdgeWith(just_right));
// Wrong placement
- gfx::Rect same_height_no_edge(0, 0, 1, 5);
- gfx::Rect same_width_no_edge(0, 0, 4, 1);
+ Rect same_height_no_edge(0, 0, 1, 5);
+ Rect same_width_no_edge(0, 0, 4, 1);
EXPECT_FALSE(r.SharesEdgeWith(same_height_no_edge));
EXPECT_FALSE(r.SharesEdgeWith(same_width_no_edge));
- gfx::Rect just_above_no_edge(2, 1, 5, 2); // too wide
- gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow
- gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall
- gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short
+ Rect just_above_no_edge(2, 1, 5, 2); // too wide
+ Rect just_below_no_edge(2, 8, 3, 2); // too narrow
+ Rect just_left_no_edge(0, 3, 2, 6); // too tall
+ Rect just_right_no_edge(6, 3, 2, 4); // too short
EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge));
EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge));
@@ -396,9 +395,9 @@ TEST(RectTest, SharesEdgeWith) {
}
TEST(RectTest, SkRectToRect) {
- gfx::Rect src(10, 20, 30, 40);
- SkRect skrect = gfx::RectToSkRect(src);
- EXPECT_EQ(src, gfx::SkRectToRect(skrect));
+ Rect src(10, 20, 30, 40);
+ SkRect skrect = RectToSkRect(src);
+ EXPECT_EQ(src, SkRectToRect(skrect));
}
// Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN
@@ -441,10 +440,10 @@ TEST(RectTest, ScaleRect) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::RectF scaled = gfx::ScaleRect(r1, tests[i].scale);
+ RectF scaled = ScaleRect(r1, tests[i].scale);
EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x());
EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y());
EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width());
@@ -491,10 +490,10 @@ TEST(RectTest, ToEnclosedRect) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect enclosed = ToEnclosedRect(r1);
+ Rect enclosed = ToEnclosedRect(r1);
EXPECT_FLOAT_AND_NAN_EQ(r2.x(), enclosed.x());
EXPECT_FLOAT_AND_NAN_EQ(r2.y(), enclosed.y());
EXPECT_FLOAT_AND_NAN_EQ(r2.width(), enclosed.width());
@@ -541,10 +540,10 @@ TEST(RectTest, ToEnclosingRect) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect enclosed = ToEnclosingRect(r1);
+ Rect enclosed = ToEnclosingRect(r1);
EXPECT_FLOAT_AND_NAN_EQ(r2.x(), enclosed.x());
EXPECT_FLOAT_AND_NAN_EQ(r2.y(), enclosed.y());
EXPECT_FLOAT_AND_NAN_EQ(r2.width(), enclosed.width());
@@ -574,10 +573,10 @@ TEST(RectTest, ToFlooredRect) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
- gfx::RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
- gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
+ RectF r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
+ Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
- gfx::Rect floored = ToFlooredRectDeprecated(r1);
+ Rect floored = ToFlooredRectDeprecated(r1);
EXPECT_FLOAT_EQ(r2.x(), floored.x());
EXPECT_FLOAT_EQ(r2.y(), floored.y());
EXPECT_FLOAT_EQ(r2.width(), floored.width());
@@ -589,17 +588,17 @@ TEST(RectTest, ToFlooredRect) {
TEST(RectTest, ConstructAndAssign) {
const RECT rect_1 = { 0, 0, 10, 10 };
const RECT rect_2 = { 0, 0, -10, -10 };
- gfx::Rect test1(rect_1);
- gfx::Rect test2(rect_2);
+ Rect test1(rect_1);
+ Rect test2(rect_2);
}
#endif
TEST(RectTest, ToRectF) {
// Check that implicit conversion from integer to float compiles.
- gfx::Rect a(10, 20, 30, 40);
- gfx::RectF b(10, 20, 30, 40);
+ Rect a(10, 20, 30, 40);
+ RectF b(10, 20, 30, 40);
- gfx::RectF intersect = gfx::IntersectRects(a, b);
+ RectF intersect = IntersectRects(a, b);
EXPECT_EQ(b.ToString(), intersect.ToString());
EXPECT_EQ(a, b);
@@ -608,65 +607,65 @@ TEST(RectTest, ToRectF) {
TEST(RectTest, BoundingRect) {
struct {
- gfx::Point a;
- gfx::Point b;
- gfx::Rect expected;
+ Point a;
+ Point b;
+ Rect expected;
} int_tests[] = {
// If point B dominates A, then A should be the origin.
- { gfx::Point(4, 6), gfx::Point(4, 6), gfx::Rect(4, 6, 0, 0) },
- { gfx::Point(4, 6), gfx::Point(8, 6), gfx::Rect(4, 6, 4, 0) },
- { gfx::Point(4, 6), gfx::Point(4, 9), gfx::Rect(4, 6, 0, 3) },
- { gfx::Point(4, 6), gfx::Point(8, 9), gfx::Rect(4, 6, 4, 3) },
+ { Point(4, 6), Point(4, 6), Rect(4, 6, 0, 0) },
+ { Point(4, 6), Point(8, 6), Rect(4, 6, 4, 0) },
+ { Point(4, 6), Point(4, 9), Rect(4, 6, 0, 3) },
+ { Point(4, 6), Point(8, 9), Rect(4, 6, 4, 3) },
// If point A dominates B, then B should be the origin.
- { gfx::Point(4, 6), gfx::Point(4, 6), gfx::Rect(4, 6, 0, 0) },
- { gfx::Point(8, 6), gfx::Point(4, 6), gfx::Rect(4, 6, 4, 0) },
- { gfx::Point(4, 9), gfx::Point(4, 6), gfx::Rect(4, 6, 0, 3) },
- { gfx::Point(8, 9), gfx::Point(4, 6), gfx::Rect(4, 6, 4, 3) },
+ { Point(4, 6), Point(4, 6), Rect(4, 6, 0, 0) },
+ { Point(8, 6), Point(4, 6), Rect(4, 6, 4, 0) },
+ { Point(4, 9), Point(4, 6), Rect(4, 6, 0, 3) },
+ { Point(8, 9), Point(4, 6), Rect(4, 6, 4, 3) },
// If neither point dominates, then the origin is a combination of the two.
- { gfx::Point(4, 6), gfx::Point(6, 4), gfx::Rect(4, 4, 2, 2) },
- { gfx::Point(-4, -6), gfx::Point(-6, -4), gfx::Rect(-6, -6, 2, 2) },
- { gfx::Point(-4, 6), gfx::Point(6, -4), gfx::Rect(-4, -4, 10, 10) },
+ { Point(4, 6), Point(6, 4), Rect(4, 4, 2, 2) },
+ { Point(-4, -6), Point(-6, -4), Rect(-6, -6, 2, 2) },
+ { Point(-4, 6), Point(6, -4), Rect(-4, -4, 10, 10) },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(int_tests); ++i) {
- gfx::Rect actual = BoundingRect(int_tests[i].a, int_tests[i].b);
+ Rect actual = BoundingRect(int_tests[i].a, int_tests[i].b);
EXPECT_EQ(int_tests[i].expected.ToString(), actual.ToString());
}
struct {
- gfx::PointF a;
- gfx::PointF b;
- gfx::RectF expected;
+ PointF a;
+ PointF b;
+ RectF expected;
} float_tests[] = {
// If point B dominates A, then A should be the origin.
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(4.2f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 0, 0) },
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(8.5f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 4.3f, 0) },
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(4.2f, 9.3f),
- gfx::RectF(4.2f, 6.8f, 0, 2.5f) },
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(8.5f, 9.3f),
- gfx::RectF(4.2f, 6.8f, 4.3f, 2.5f) },
+ { PointF(4.2f, 6.8f), PointF(4.2f, 6.8f),
+ RectF(4.2f, 6.8f, 0, 0) },
+ { PointF(4.2f, 6.8f), PointF(8.5f, 6.8f),
+ RectF(4.2f, 6.8f, 4.3f, 0) },
+ { PointF(4.2f, 6.8f), PointF(4.2f, 9.3f),
+ RectF(4.2f, 6.8f, 0, 2.5f) },
+ { PointF(4.2f, 6.8f), PointF(8.5f, 9.3f),
+ RectF(4.2f, 6.8f, 4.3f, 2.5f) },
// If point A dominates B, then B should be the origin.
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(4.2f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 0, 0) },
- { gfx::PointF(8.5f, 6.8f), gfx::PointF(4.2f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 4.3f, 0) },
- { gfx::PointF(4.2f, 9.3f), gfx::PointF(4.2f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 0, 2.5f) },
- { gfx::PointF(8.5f, 9.3f), gfx::PointF(4.2f, 6.8f),
- gfx::RectF(4.2f, 6.8f, 4.3f, 2.5f) },
+ { PointF(4.2f, 6.8f), PointF(4.2f, 6.8f),
+ RectF(4.2f, 6.8f, 0, 0) },
+ { PointF(8.5f, 6.8f), PointF(4.2f, 6.8f),
+ RectF(4.2f, 6.8f, 4.3f, 0) },
+ { PointF(4.2f, 9.3f), PointF(4.2f, 6.8f),
+ RectF(4.2f, 6.8f, 0, 2.5f) },
+ { PointF(8.5f, 9.3f), PointF(4.2f, 6.8f),
+ RectF(4.2f, 6.8f, 4.3f, 2.5f) },
// If neither point dominates, then the origin is a combination of the two.
- { gfx::PointF(4.2f, 6.8f), gfx::PointF(6.8f, 4.2f),
- gfx::RectF(4.2f, 4.2f, 2.6f, 2.6f) },
- { gfx::PointF(-4.2f, -6.8f), gfx::PointF(-6.8f, -4.2f),
- gfx::RectF(-6.8f, -6.8f, 2.6f, 2.6f) },
- { gfx::PointF(-4.2f, 6.8f), gfx::PointF(6.8f, -4.2f),
- gfx::RectF(-4.2f, -4.2f, 11.0f, 11.0f) }
+ { PointF(4.2f, 6.8f), PointF(6.8f, 4.2f),
+ RectF(4.2f, 4.2f, 2.6f, 2.6f) },
+ { PointF(-4.2f, -6.8f), PointF(-6.8f, -4.2f),
+ RectF(-6.8f, -6.8f, 2.6f, 2.6f) },
+ { PointF(-4.2f, 6.8f), PointF(6.8f, -4.2f),
+ RectF(-4.2f, -4.2f, 11.0f, 11.0f) }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) {
- gfx::RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b);
+ RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b);
EXPECT_EQ(float_tests[i].expected.ToString(), actual.ToString());
}
}
@@ -678,28 +677,28 @@ TEST(RectTest, IsExpressibleAsRect) {
float max = std::numeric_limits<int>::max();
float infinity = std::numeric_limits<float>::infinity();
- EXPECT_TRUE(gfx::RectF(min, min, max, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(min + 500, min, max, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(min, min + 500, max, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(min - 500, min, max, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(min, min - 500, max, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(min, min, max - 500, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(min, min, max, max - 500).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(min, min, max + 500, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(min, min, max, max + 500).IsExpressibleAsRect());
-
- EXPECT_TRUE(gfx::RectF(0, 0, max, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(500, 0, max, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, 500, max, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(0, 0, max - 500, max).IsExpressibleAsRect());
- EXPECT_TRUE(gfx::RectF(0, 0, max, max - 500).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, 0, max + 500, max).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, 0, max, max + 500).IsExpressibleAsRect());
-
- EXPECT_FALSE(gfx::RectF(infinity, 0, 1, 1).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, infinity, 1, 1).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, 0, infinity, 1).IsExpressibleAsRect());
- EXPECT_FALSE(gfx::RectF(0, 0, 1, infinity).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(min, min, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(min + 500, min, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(min, min + 500, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(min - 500, min, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(min, min - 500, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(min, min, max - 500, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(min, min, max, max - 500).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(min, min, max + 500, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(min, min, max, max + 500).IsExpressibleAsRect());
+
+ EXPECT_TRUE(RectF(0, 0, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(500, 0, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, 500, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(0, 0, max - 500, max).IsExpressibleAsRect());
+ EXPECT_TRUE(RectF(0, 0, max, max - 500).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, 0, max + 500, max).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, 0, max, max + 500).IsExpressibleAsRect());
+
+ EXPECT_FALSE(RectF(infinity, 0, 1, 1).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, infinity, 1, 1).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, 0, infinity, 1).IsExpressibleAsRect());
+ EXPECT_FALSE(RectF(0, 0, 1, infinity).IsExpressibleAsRect());
}
-} // namespace ui
+} // namespace gfx
diff --git a/ui/gfx/safe_integer_conversions_unittest.cc b/ui/gfx/safe_integer_conversions_unittest.cc
index 94e0901..1268f8b 100644
--- a/ui/gfx/safe_integer_conversions_unittest.cc
+++ b/ui/gfx/safe_integer_conversions_unittest.cc
@@ -8,10 +8,10 @@
#include "testing/gtest/include/gtest/gtest.h"
-namespace ui {
+namespace gfx {
TEST(SafeIntegerConversions, ClampToInt) {
- EXPECT_EQ(0, gfx::ClampToInt(std::numeric_limits<float>::quiet_NaN()));
+ EXPECT_EQ(0, ClampToInt(std::numeric_limits<float>::quiet_NaN()));
float max = std::numeric_limits<int>::max();
float min = std::numeric_limits<int>::min();
@@ -20,21 +20,21 @@ TEST(SafeIntegerConversions, ClampToInt) {
int int_max = std::numeric_limits<int>::max();
int int_min = std::numeric_limits<int>::min();
- EXPECT_EQ(int_max, gfx::ClampToInt(infinity));
- EXPECT_EQ(int_max, gfx::ClampToInt(max));
- EXPECT_EQ(int_max, gfx::ClampToInt(max + 100));
+ EXPECT_EQ(int_max, ClampToInt(infinity));
+ EXPECT_EQ(int_max, ClampToInt(max));
+ EXPECT_EQ(int_max, ClampToInt(max + 100));
- EXPECT_EQ(-100, gfx::ClampToInt(-100.5f));
- EXPECT_EQ(0, gfx::ClampToInt(0));
- EXPECT_EQ(100, gfx::ClampToInt(100.5f));
+ EXPECT_EQ(-100, ClampToInt(-100.5f));
+ EXPECT_EQ(0, ClampToInt(0));
+ EXPECT_EQ(100, ClampToInt(100.5f));
- EXPECT_EQ(int_min, gfx::ClampToInt(-infinity));
- EXPECT_EQ(int_min, gfx::ClampToInt(min));
- EXPECT_EQ(int_min, gfx::ClampToInt(min - 100));
+ EXPECT_EQ(int_min, ClampToInt(-infinity));
+ EXPECT_EQ(int_min, ClampToInt(min));
+ EXPECT_EQ(int_min, ClampToInt(min - 100));
}
TEST(SafeIntegerConversions, ToFlooredInt) {
- EXPECT_EQ(0, gfx::ToFlooredInt(std::numeric_limits<float>::quiet_NaN()));
+ EXPECT_EQ(0, ToFlooredInt(std::numeric_limits<float>::quiet_NaN()));
float max = std::numeric_limits<int>::max();
float min = std::numeric_limits<int>::min();
@@ -43,21 +43,21 @@ TEST(SafeIntegerConversions, ToFlooredInt) {
int int_max = std::numeric_limits<int>::max();
int int_min = std::numeric_limits<int>::min();
- EXPECT_EQ(int_max, gfx::ToFlooredInt(infinity));
- EXPECT_EQ(int_max, gfx::ToFlooredInt(max));
- EXPECT_EQ(int_max, gfx::ToFlooredInt(max + 100));
+ EXPECT_EQ(int_max, ToFlooredInt(infinity));
+ EXPECT_EQ(int_max, ToFlooredInt(max));
+ EXPECT_EQ(int_max, ToFlooredInt(max + 100));
- EXPECT_EQ(-101, gfx::ToFlooredInt(-100.5f));
- EXPECT_EQ(0, gfx::ToFlooredInt(0));
- EXPECT_EQ(100, gfx::ToFlooredInt(100.5f));
+ EXPECT_EQ(-101, ToFlooredInt(-100.5f));
+ EXPECT_EQ(0, ToFlooredInt(0));
+ EXPECT_EQ(100, ToFlooredInt(100.5f));
- EXPECT_EQ(int_min, gfx::ToFlooredInt(-infinity));
- EXPECT_EQ(int_min, gfx::ToFlooredInt(min));
- EXPECT_EQ(int_min, gfx::ToFlooredInt(min - 100));
+ EXPECT_EQ(int_min, ToFlooredInt(-infinity));
+ EXPECT_EQ(int_min, ToFlooredInt(min));
+ EXPECT_EQ(int_min, ToFlooredInt(min - 100));
}
TEST(SafeIntegerConversions, ToCeiledInt) {
- EXPECT_EQ(0, gfx::ToCeiledInt(std::numeric_limits<float>::quiet_NaN()));
+ EXPECT_EQ(0, ToCeiledInt(std::numeric_limits<float>::quiet_NaN()));
float max = std::numeric_limits<int>::max();
float min = std::numeric_limits<int>::min();
@@ -66,21 +66,21 @@ TEST(SafeIntegerConversions, ToCeiledInt) {
int int_max = std::numeric_limits<int>::max();
int int_min = std::numeric_limits<int>::min();
- EXPECT_EQ(int_max, gfx::ToCeiledInt(infinity));
- EXPECT_EQ(int_max, gfx::ToCeiledInt(max));
- EXPECT_EQ(int_max, gfx::ToCeiledInt(max + 100));
+ EXPECT_EQ(int_max, ToCeiledInt(infinity));
+ EXPECT_EQ(int_max, ToCeiledInt(max));
+ EXPECT_EQ(int_max, ToCeiledInt(max + 100));
- EXPECT_EQ(-100, gfx::ToCeiledInt(-100.5f));
- EXPECT_EQ(0, gfx::ToCeiledInt(0));
- EXPECT_EQ(101, gfx::ToCeiledInt(100.5f));
+ EXPECT_EQ(-100, ToCeiledInt(-100.5f));
+ EXPECT_EQ(0, ToCeiledInt(0));
+ EXPECT_EQ(101, ToCeiledInt(100.5f));
- EXPECT_EQ(int_min, gfx::ToCeiledInt(-infinity));
- EXPECT_EQ(int_min, gfx::ToCeiledInt(min));
- EXPECT_EQ(int_min, gfx::ToCeiledInt(min - 100));
+ EXPECT_EQ(int_min, ToCeiledInt(-infinity));
+ EXPECT_EQ(int_min, ToCeiledInt(min));
+ EXPECT_EQ(int_min, ToCeiledInt(min - 100));
}
TEST(SafeIntegerConversions, ToRoundedInt) {
- EXPECT_EQ(0, gfx::ToRoundedInt(std::numeric_limits<float>::quiet_NaN()));
+ EXPECT_EQ(0, ToRoundedInt(std::numeric_limits<float>::quiet_NaN()));
float max = std::numeric_limits<int>::max();
float min = std::numeric_limits<int>::min();
@@ -89,21 +89,21 @@ TEST(SafeIntegerConversions, ToRoundedInt) {
int int_max = std::numeric_limits<int>::max();
int int_min = std::numeric_limits<int>::min();
- EXPECT_EQ(int_max, gfx::ToRoundedInt(infinity));
- EXPECT_EQ(int_max, gfx::ToRoundedInt(max));
- EXPECT_EQ(int_max, gfx::ToRoundedInt(max + 100));
-
- EXPECT_EQ(-100, gfx::ToRoundedInt(-100.1f));
- EXPECT_EQ(-101, gfx::ToRoundedInt(-100.5f));
- EXPECT_EQ(-101, gfx::ToRoundedInt(-100.9f));
- EXPECT_EQ(0, gfx::ToRoundedInt(0));
- EXPECT_EQ(100, gfx::ToRoundedInt(100.1f));
- EXPECT_EQ(101, gfx::ToRoundedInt(100.5f));
- EXPECT_EQ(101, gfx::ToRoundedInt(100.9f));
-
- EXPECT_EQ(int_min, gfx::ToRoundedInt(-infinity));
- EXPECT_EQ(int_min, gfx::ToRoundedInt(min));
- EXPECT_EQ(int_min, gfx::ToRoundedInt(min - 100));
+ EXPECT_EQ(int_max, ToRoundedInt(infinity));
+ EXPECT_EQ(int_max, ToRoundedInt(max));
+ EXPECT_EQ(int_max, ToRoundedInt(max + 100));
+
+ EXPECT_EQ(-100, ToRoundedInt(-100.1f));
+ EXPECT_EQ(-101, ToRoundedInt(-100.5f));
+ EXPECT_EQ(-101, ToRoundedInt(-100.9f));
+ EXPECT_EQ(0, ToRoundedInt(0));
+ EXPECT_EQ(100, ToRoundedInt(100.1f));
+ EXPECT_EQ(101, ToRoundedInt(100.5f));
+ EXPECT_EQ(101, ToRoundedInt(100.9f));
+
+ EXPECT_EQ(int_min, ToRoundedInt(-infinity));
+ EXPECT_EQ(int_min, ToRoundedInt(min));
+ EXPECT_EQ(int_min, ToRoundedInt(min - 100));
}
-} // namespace ui
+} // namespace gfx
diff --git a/ui/gfx/size_unittest.cc b/ui/gfx/size_unittest.cc
index 4a281ed..d647f4c 100644
--- a/ui/gfx/size_unittest.cc
+++ b/ui/gfx/size_unittest.cc
@@ -9,11 +9,11 @@
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/size_f.h"
-namespace ui {
+namespace gfx {
namespace {
-int TestSizeF(const gfx::SizeF& s) {
+int TestSizeF(const SizeF& s) {
return s.width();
}
@@ -21,119 +21,74 @@ int TestSizeF(const gfx::SizeF& s) {
TEST(SizeTest, ToSizeF) {
// Check that implicit conversion from integer to float compiles.
- gfx::Size a(10, 20);
+ Size a(10, 20);
float width = TestSizeF(a);
EXPECT_EQ(width, a.width());
- gfx::SizeF b(10, 20);
+ SizeF b(10, 20);
EXPECT_EQ(a, b);
EXPECT_EQ(b, a);
}
TEST(SizeTest, ToFlooredSize) {
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToFlooredSize(gfx::SizeF(0, 0)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToFlooredSize(gfx::SizeF(0.0001f, 0.0001f)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToFlooredSize(gfx::SizeF(0.4999f, 0.4999f)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToFlooredSize(gfx::SizeF(0.5f, 0.5f)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToFlooredSize(gfx::SizeF(0.9999f, 0.9999f)));
-
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToFlooredSize(gfx::SizeF(10, 10)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToFlooredSize(gfx::SizeF(10.0001f, 10.0001f)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToFlooredSize(gfx::SizeF(10.4999f, 10.4999f)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToFlooredSize(gfx::SizeF(10.5f, 10.5f)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToFlooredSize(gfx::SizeF(10.9999f, 10.9999f)));
-
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToFlooredSize(gfx::SizeF(-10, -10)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToFlooredSize(gfx::SizeF(-10.0001f, -10.0001f)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToFlooredSize(gfx::SizeF(-10.4999f, -10.4999f)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToFlooredSize(gfx::SizeF(-10.5f, -10.5f)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToFlooredSize(gfx::SizeF(-10.9999f, -10.9999f)));
+ EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0, 0)));
+ EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.0001f, 0.0001f)));
+ EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.4999f, 0.4999f)));
+ EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.5f, 0.5f)));
+ EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.9999f, 0.9999f)));
+
+ EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10, 10)));
+ EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.0001f, 10.0001f)));
+ EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.4999f, 10.4999f)));
+ EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.5f, 10.5f)));
+ EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10.9999f, 10.9999f)));
+
+ EXPECT_EQ(Size(-10, -10), ToFlooredSize(SizeF(-10, -10)));
+ EXPECT_EQ(Size(-11, -11), ToFlooredSize(SizeF(-10.0001f, -10.0001f)));
+ EXPECT_EQ(Size(-11, -11), ToFlooredSize(SizeF(-10.4999f, -10.4999f)));
+ EXPECT_EQ(Size(-11, -11), ToFlooredSize(SizeF(-10.5f, -10.5f)));
+ EXPECT_EQ(Size(-11, -11), ToFlooredSize(SizeF(-10.9999f, -10.9999f)));
}
TEST(SizeTest, ToCeiledSize) {
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToCeiledSize(gfx::SizeF(0, 0)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToCeiledSize(gfx::SizeF(0.0001f, 0.0001f)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToCeiledSize(gfx::SizeF(0.4999f, 0.4999f)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToCeiledSize(gfx::SizeF(0.5f, 0.5f)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToCeiledSize(gfx::SizeF(0.9999f, 0.9999f)));
-
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToCeiledSize(gfx::SizeF(10, 10)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToCeiledSize(gfx::SizeF(10.0001f, 10.0001f)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToCeiledSize(gfx::SizeF(10.4999f, 10.4999f)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToCeiledSize(gfx::SizeF(10.5f, 10.5f)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToCeiledSize(gfx::SizeF(10.9999f, 10.9999f)));
-
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToCeiledSize(gfx::SizeF(-10, -10)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToCeiledSize(gfx::SizeF(-10.0001f, -10.0001f)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToCeiledSize(gfx::SizeF(-10.4999f, -10.4999f)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToCeiledSize(gfx::SizeF(-10.5f, -10.5f)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToCeiledSize(gfx::SizeF(-10.9999f, -10.9999f)));
+ EXPECT_EQ(Size(0, 0), ToCeiledSize(SizeF(0, 0)));
+ EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.0001f, 0.0001f)));
+ EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.4999f, 0.4999f)));
+ EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.5f, 0.5f)));
+ EXPECT_EQ(Size(1, 1), ToCeiledSize(SizeF(0.9999f, 0.9999f)));
+
+ EXPECT_EQ(Size(10, 10), ToCeiledSize(SizeF(10, 10)));
+ EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.0001f, 10.0001f)));
+ EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.4999f, 10.4999f)));
+ EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.5f, 10.5f)));
+ EXPECT_EQ(Size(11, 11), ToCeiledSize(SizeF(10.9999f, 10.9999f)));
+
+ EXPECT_EQ(Size(-10, -10), ToCeiledSize(SizeF(-10, -10)));
+ EXPECT_EQ(Size(-10, -10), ToCeiledSize(SizeF(-10.0001f, -10.0001f)));
+ EXPECT_EQ(Size(-10, -10), ToCeiledSize(SizeF(-10.4999f, -10.4999f)));
+ EXPECT_EQ(Size(-10, -10), ToCeiledSize(SizeF(-10.5f, -10.5f)));
+ EXPECT_EQ(Size(-10, -10), ToCeiledSize(SizeF(-10.9999f, -10.9999f)));
}
TEST(SizeTest, ToRoundedSize) {
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToRoundedSize(gfx::SizeF(0, 0)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToRoundedSize(gfx::SizeF(0.0001f, 0.0001f)));
- EXPECT_EQ(gfx::Size(0, 0),
- gfx::ToRoundedSize(gfx::SizeF(0.4999f, 0.4999f)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToRoundedSize(gfx::SizeF(0.5f, 0.5f)));
- EXPECT_EQ(gfx::Size(1, 1),
- gfx::ToRoundedSize(gfx::SizeF(0.9999f, 0.9999f)));
-
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToRoundedSize(gfx::SizeF(10, 10)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToRoundedSize(gfx::SizeF(10.0001f, 10.0001f)));
- EXPECT_EQ(gfx::Size(10, 10),
- gfx::ToRoundedSize(gfx::SizeF(10.4999f, 10.4999f)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToRoundedSize(gfx::SizeF(10.5f, 10.5f)));
- EXPECT_EQ(gfx::Size(11, 11),
- gfx::ToRoundedSize(gfx::SizeF(10.9999f, 10.9999f)));
-
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToRoundedSize(gfx::SizeF(-10, -10)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToRoundedSize(gfx::SizeF(-10.0001f, -10.0001f)));
- EXPECT_EQ(gfx::Size(-10, -10),
- gfx::ToRoundedSize(gfx::SizeF(-10.4999f, -10.4999f)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToRoundedSize(gfx::SizeF(-10.5f, -10.5f)));
- EXPECT_EQ(gfx::Size(-11, -11),
- gfx::ToRoundedSize(gfx::SizeF(-10.9999f, -10.9999f)));
+ EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0, 0)));
+ EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0.0001f, 0.0001f)));
+ EXPECT_EQ(Size(0, 0), ToRoundedSize(SizeF(0.4999f, 0.4999f)));
+ EXPECT_EQ(Size(1, 1), ToRoundedSize(SizeF(0.5f, 0.5f)));
+ EXPECT_EQ(Size(1, 1), ToRoundedSize(SizeF(0.9999f, 0.9999f)));
+
+ EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10, 10)));
+ EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10.0001f, 10.0001f)));
+ EXPECT_EQ(Size(10, 10), ToRoundedSize(SizeF(10.4999f, 10.4999f)));
+ EXPECT_EQ(Size(11, 11), ToRoundedSize(SizeF(10.5f, 10.5f)));
+ EXPECT_EQ(Size(11, 11), ToRoundedSize(SizeF(10.9999f, 10.9999f)));
+
+ EXPECT_EQ(Size(-10, -10), ToRoundedSize(SizeF(-10, -10)));
+ EXPECT_EQ(Size(-10, -10), ToRoundedSize(SizeF(-10.0001f, -10.0001f)));
+ EXPECT_EQ(Size(-10, -10), ToRoundedSize(SizeF(-10.4999f, -10.4999f)));
+ EXPECT_EQ(Size(-11, -11), ToRoundedSize(SizeF(-10.5f, -10.5f)));
+ EXPECT_EQ(Size(-11, -11), ToRoundedSize(SizeF(-10.9999f, -10.9999f)));
}
-} // namespace ui
+} // namespace gfx
diff --git a/ui/gfx/vector2d_unittest.cc b/ui/gfx/vector2d_unittest.cc
index 3dfbdf9..ccb6059 100644
--- a/ui/gfx/vector2d_unittest.cc
+++ b/ui/gfx/vector2d_unittest.cc
@@ -13,16 +13,16 @@
namespace gfx {
TEST(Vector2dTest, ConversionToFloat) {
- gfx::Vector2d i(3, 4);
- gfx::Vector2dF f = i;
+ Vector2d i(3, 4);
+ Vector2dF f = i;
EXPECT_EQ(i, f);
}
TEST(Vector2dTest, IsZero) {
- gfx::Vector2d int_zero(0, 0);
- gfx::Vector2d int_nonzero(2, -2);
- gfx::Vector2dF float_zero(0, 0);
- gfx::Vector2dF float_nonzero(0.1f, -0.1f);
+ Vector2d int_zero(0, 0);
+ Vector2d int_nonzero(2, -2);
+ Vector2dF float_zero(0, 0);
+ Vector2dF float_nonzero(0.1f, -0.1f);
EXPECT_TRUE(int_zero.IsZero());
EXPECT_FALSE(int_nonzero.IsZero());
@@ -31,33 +31,33 @@ TEST(Vector2dTest, IsZero) {
}
TEST(Vector2dTest, Add) {
- gfx::Vector2d i1(3, 5);
- gfx::Vector2d i2(4, -1);
+ Vector2d i1(3, 5);
+ Vector2d i2(4, -1);
const struct {
- gfx::Vector2d expected;
- gfx::Vector2d actual;
+ Vector2d expected;
+ Vector2d actual;
} int_tests[] = {
- { gfx::Vector2d(3, 5), i1 + gfx::Vector2d() },
- { gfx::Vector2d(3 + 4, 5 - 1), i1 + i2 },
- { gfx::Vector2d(3 - 4, 5 + 1), i1 - i2 }
+ { Vector2d(3, 5), i1 + Vector2d() },
+ { Vector2d(3 + 4, 5 - 1), i1 + i2 },
+ { Vector2d(3 - 4, 5 + 1), i1 - i2 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(int_tests); ++i)
EXPECT_EQ(int_tests[i].expected.ToString(),
int_tests[i].actual.ToString());
- gfx::Vector2dF f1(3.1f, 5.1f);
- gfx::Vector2dF f2(4.3f, -1.3f);
+ Vector2dF f1(3.1f, 5.1f);
+ Vector2dF f2(4.3f, -1.3f);
const struct {
- gfx::Vector2dF expected;
- gfx::Vector2dF actual;
+ Vector2dF expected;
+ Vector2dF actual;
} float_tests[] = {
- { gfx::Vector2dF(3.1F, 5.1F), f1 + gfx::Vector2d() },
- { gfx::Vector2dF(3.1F, 5.1F), f1 + gfx::Vector2dF() },
- { gfx::Vector2dF(3.1f + 4.3f, 5.1f - 1.3f), f1 + f2 },
- { gfx::Vector2dF(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 }
+ { Vector2dF(3.1F, 5.1F), f1 + Vector2d() },
+ { Vector2dF(3.1F, 5.1F), f1 + Vector2dF() },
+ { Vector2dF(3.1f + 4.3f, 5.1f - 1.3f), f1 + f2 },
+ { Vector2dF(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i)
@@ -67,14 +67,14 @@ TEST(Vector2dTest, Add) {
TEST(Vector2dTest, Negative) {
const struct {
- gfx::Vector2d expected;
- gfx::Vector2d actual;
+ Vector2d expected;
+ Vector2d actual;
} int_tests[] = {
- { gfx::Vector2d(0, 0), -gfx::Vector2d(0, 0) },
- { gfx::Vector2d(-3, -3), -gfx::Vector2d(3, 3) },
- { gfx::Vector2d(3, 3), -gfx::Vector2d(-3, -3) },
- { gfx::Vector2d(-3, 3), -gfx::Vector2d(3, -3) },
- { gfx::Vector2d(3, -3), -gfx::Vector2d(-3, 3) }
+ { Vector2d(0, 0), -Vector2d(0, 0) },
+ { Vector2d(-3, -3), -Vector2d(3, 3) },
+ { Vector2d(3, 3), -Vector2d(-3, -3) },
+ { Vector2d(-3, 3), -Vector2d(3, -3) },
+ { Vector2d(3, -3), -Vector2d(-3, 3) }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(int_tests); ++i)
@@ -82,14 +82,14 @@ TEST(Vector2dTest, Negative) {
int_tests[i].actual.ToString());
const struct {
- gfx::Vector2dF expected;
- gfx::Vector2dF actual;
+ Vector2dF expected;
+ Vector2dF actual;
} float_tests[] = {
- { gfx::Vector2dF(0, 0), -gfx::Vector2d(0, 0) },
- { gfx::Vector2dF(-0.3f, -0.3f), -gfx::Vector2dF(0.3f, 0.3f) },
- { gfx::Vector2dF(0.3f, 0.3f), -gfx::Vector2dF(-0.3f, -0.3f) },
- { gfx::Vector2dF(-0.3f, 0.3f), -gfx::Vector2dF(0.3f, -0.3f) },
- { gfx::Vector2dF(0.3f, -0.3f), -gfx::Vector2dF(-0.3f, 0.3f) }
+ { Vector2dF(0, 0), -Vector2d(0, 0) },
+ { Vector2dF(-0.3f, -0.3f), -Vector2dF(0.3f, 0.3f) },
+ { Vector2dF(0.3f, 0.3f), -Vector2dF(-0.3f, -0.3f) },
+ { Vector2dF(-0.3f, 0.3f), -Vector2dF(0.3f, -0.3f) },
+ { Vector2dF(0.3f, -0.3f), -Vector2dF(-0.3f, 0.3f) }
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i)
@@ -111,7 +111,7 @@ TEST(Vector2dTest, Scale) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(double_values); ++i) {
- gfx::Vector2dF v(double_values[i][0], double_values[i][1]);
+ Vector2dF v(double_values[i][0], double_values[i][1]);
v.Scale(double_values[i][2], double_values[i][3]);
EXPECT_EQ(v.x(), double_values[i][0] * double_values[i][2]);
EXPECT_EQ(v.y(), double_values[i][1] * double_values[i][3]);
@@ -130,7 +130,7 @@ TEST(Vector2dTest, Scale) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(single_values); ++i) {
- gfx::Vector2dF v(single_values[i][0], single_values[i][1]);
+ Vector2dF v(single_values[i][0], single_values[i][1]);
v.Scale(single_values[i][2]);
EXPECT_EQ(v.x(), single_values[i][0] * single_values[i][2]);
EXPECT_EQ(v.y(), single_values[i][1] * single_values[i][2]);
@@ -153,7 +153,7 @@ TEST(Vector2dTest, Length) {
double length_squared =
static_cast<double>(v0) * v0 + static_cast<double>(v1) * v1;
double length = std::sqrt(length_squared);
- gfx::Vector2d vector(v0, v1);
+ Vector2d vector(v0, v1);
EXPECT_EQ(static_cast<float>(length_squared), vector.LengthSquared());
EXPECT_EQ(static_cast<float>(length), vector.Length());
}
@@ -177,10 +177,10 @@ TEST(Vector2dTest, Length) {
double length_squared =
static_cast<double>(v0) * v0 + static_cast<double>(v1) * v1;
double length = std::sqrt(length_squared);
- gfx::Vector2dF vector(v0, v1);
+ Vector2dF vector(v0, v1);
EXPECT_EQ(length_squared, vector.LengthSquared());
EXPECT_EQ(static_cast<float>(length), vector.Length());
}
}
-} // namespace ui
+} // namespace gfx