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

Unified Diff: ui/gfx/rect_unittest.cc

Issue 11235017: Revert to old rect conversion behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 8 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/rect_conversions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/rect_unittest.cc
diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc
index bc73bf3794bcb73b6b5c456dba62e61aa7546b2e..6bdbb3bdb2323c9c2bcbeacb04277197487053fd 100644
--- a/ui/gfx/rect_unittest.cc
+++ b/ui/gfx/rect_unittest.cc
@@ -555,6 +555,39 @@ TEST(RectTest, ToEnclosingRect) {
}
}
+TEST(RectTest, ToFlooredRect) {
+ static const struct Test {
+ float x1; // source
+ float y1;
+ float w1;
+ float h1;
+ int x2; // target
+ int y2;
+ int w2;
+ int h2;
+ } tests [] = {
+ { 0.0f, 0.0f, 0.0f, 0.0f,
+ 0, 0, 0, 0 },
+ { -1.5f, -1.5f, 3.0f, 3.0f,
+ -2, -2, 3, 3 },
+ { -1.5f, -1.5f, 3.5f, 3.5f,
+ -2, -2, 3, 3 },
+ { 20000.5f, 20000.5f, 0.5f, 0.5f,
+ 20000, 20000, 0, 0 },
+ };
+
+ 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);
+
+ gfx::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());
+ EXPECT_FLOAT_EQ(r2.height(), floored.height());
+ }
+}
+
#if defined(OS_WIN)
TEST(RectTest, ConstructAndAssign) {
const RECT rect_1 = { 0, 0, 10, 10 };
« no previous file with comments | « ui/gfx/rect_conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698