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

Unified Diff: ui/gfx/geometry/scroll_offset_unittest.cc

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/geometry/scroll_offset.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/scroll_offset_unittest.cc
diff --git a/ui/gfx/geometry/scroll_offset_unittest.cc b/ui/gfx/geometry/scroll_offset_unittest.cc
index 2d19a6acc6821e8e64ece3a7bbd88b97ccb05c82..782fdf4c10d1a48ef1304cb9e53ac4a24ccc8443 100644
--- a/ui/gfx/geometry/scroll_offset_unittest.cc
+++ b/ui/gfx/geometry/scroll_offset_unittest.cc
@@ -15,23 +15,23 @@ namespace gfx {
TEST(ScrollOffsetTest, IsZero) {
ScrollOffset zero(0, 0);
- ScrollOffset nonzero(0.1, -0.1);
+ ScrollOffset nonzero(0.1f, -0.1f);
EXPECT_TRUE(zero.IsZero());
EXPECT_FALSE(nonzero.IsZero());
}
TEST(ScrollOffsetTest, Add) {
- ScrollOffset f1(3.1, 5.1);
- ScrollOffset f2(4.3, -1.3);
+ ScrollOffset f1(3.1f, 5.1f);
+ ScrollOffset f2(4.3f, -1.3f);
const struct {
ScrollOffset expected;
ScrollOffset actual;
} scroll_offset_tests[] = {
- { ScrollOffset(3.1, 5.1), f1 + ScrollOffset() },
- { ScrollOffset(3.1 + 4.3, 5.1f - 1.3), f1 + f2 },
- { ScrollOffset(3.1 - 4.3, 5.1f + 1.3), f1 - f2 }
+ { ScrollOffset(3.1f, 5.1f), f1 + ScrollOffset() },
+ { ScrollOffset(3.1f + 4.3f, 5.1f - 1.3f), f1 + f2 },
+ { ScrollOffset(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 }
};
for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i)
@@ -44,10 +44,10 @@ TEST(ScrollOffsetTest, Negative) {
ScrollOffset expected;
ScrollOffset actual;
} scroll_offset_tests[] = {
- { ScrollOffset(-0.3, -0.3), -ScrollOffset(0.3, 0.3) },
- { ScrollOffset(0.3, 0.3), -ScrollOffset(-0.3, -0.3) },
- { ScrollOffset(-0.3, 0.3), -ScrollOffset(0.3, -0.3) },
- { ScrollOffset(0.3, -0.3), -ScrollOffset(-0.3, 0.3) }
+ { ScrollOffset(-0.3f, -0.3f), -ScrollOffset(0.3f, 0.3f) },
+ { ScrollOffset(0.3f, 0.3f), -ScrollOffset(-0.3f, -0.3f) },
+ { ScrollOffset(-0.3f, 0.3f), -ScrollOffset(0.3f, -0.3f) },
+ { ScrollOffset(0.3f, -0.3f), -ScrollOffset(-0.3f, 0.3f) }
};
for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i)
@@ -56,35 +56,35 @@ TEST(ScrollOffsetTest, Negative) {
}
TEST(ScrollOffsetTest, Scale) {
- double double_values[][4] = {
- { 4.5, 1.2, 3.3, 5.6 },
- { 4.5, -1.2, 3.3, 5.6 },
- { 4.5, 1.2, 3.3, -5.6 },
- { 4.5, 1.2, -3.3, -5.6 },
- { -4.5, 1.2, 3.3, 5.6 },
- { -4.5, 1.2, 0, 5.6 },
- { -4.5, 1.2, 3.3, 0 },
- { 4.5, 0, 3.3, 5.6 },
- { 0, 1.2, 3.3, 5.6 }
+ float float_values[][4] = {
+ { 4.5f, 1.2f, 3.3f, 5.6f },
+ { 4.5f, -1.2f, 3.3f, 5.6f },
+ { 4.5f, 1.2f, 3.3f, -5.6f },
+ { 4.5f, 1.2f, -3.3f, -5.6f },
+ { -4.5f, 1.2f, 3.3f, 5.6f },
+ { -4.5f, 1.2f, 0, 5.6f },
+ { -4.5f, 1.2f, 3.3f, 0 },
+ { 4.5f, 0, 3.3f, 5.6f },
+ { 0, 1.2f, 3.3f, 5.6f }
};
- for (size_t i = 0; i < arraysize(double_values); ++i) {
- ScrollOffset 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]);
+ for (size_t i = 0; i < arraysize(float_values); ++i) {
+ ScrollOffset v(float_values[i][0], float_values[i][1]);
+ v.Scale(float_values[i][2], float_values[i][3]);
+ EXPECT_EQ(v.x(), float_values[i][0] * float_values[i][2]);
+ EXPECT_EQ(v.y(), float_values[i][1] * float_values[i][3]);
}
- double single_values[][3] = {
- { 4.5, 1.2, 3.3 },
- { 4.5, -1.2, 3.3 },
- { 4.5, 1.2, 3.3 },
- { 4.5, 1.2, -3.3 },
- { -4.5, 1.2, 3.3 },
- { -4.5, 1.2, 0 },
- { -4.5, 1.2, 3.3 },
- { 4.5, 0, 3.3 },
- { 0, 1.2, 3.3 }
+ float single_values[][3] = {
+ { 4.5f, 1.2f, 3.3f },
+ { 4.5f, -1.2f, 3.3f },
+ { 4.5f, 1.2f, 3.3f },
+ { 4.5f, 1.2f, -3.3f },
+ { -4.5f, 1.2f, 3.3f },
+ { -4.5f, 1.2f, 0 },
+ { -4.5f, 1.2f, 3.3f },
+ { 4.5f, 0, 3.3f },
+ { 0, 1.2f, 3.3f }
};
for (size_t i = 0; i < arraysize(single_values); ++i) {
« no previous file with comments | « ui/gfx/geometry/scroll_offset.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698