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

Unified Diff: ui/gfx/rect_unittest.cc

Issue 11293194: ui: Prefer +/- operators to apply offsets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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_f.cc ('k') | ui/gfx/render_text.cc » ('j') | 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 621e5d90fc73b9d8c844660425a6678897b97bcf..07d79a9e89fe2c9ca728beb2027a0350e1d54de5 100644
--- a/ui/gfx/rect_unittest.cc
+++ b/ui/gfx/rect_unittest.cc
@@ -700,4 +700,25 @@ TEST(RectTest, IsExpressibleAsRect) {
EXPECT_FALSE(gfx::RectF(0, 0, 1, infinity).IsExpressibleAsRect());
}
+TEST(RectTest, Offset) {
+ Rect i(1, 2, 3, 4);
+
+ EXPECT_EQ(Rect(2, 1, 3, 4).ToString(), (i + Vector2d(1, -1)).ToString());
+ i += Vector2d(1, -1);
+ EXPECT_EQ(Rect(2, 1, 3, 4).ToString(), i.ToString());
+ EXPECT_EQ(Rect(1, 2, 3, 4).ToString(), (i - Vector2d(1, -1)).ToString());
+ i -= Vector2d(1, -1);
+ EXPECT_EQ(Rect(1, 2, 3, 4).ToString(), i.ToString());
+
+ RectF f(1.1f, 2.2f, 3.3f, 4.4f);
+ EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(),
+ (f + Vector2dF(1.1f, -1.1f)).ToString());
+ f += Vector2dF(1.1f, -1.1f);
+ EXPECT_EQ(RectF(2.2f, 1.1f, 3.3f, 4.4f).ToString(), f.ToString());
+ EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(),
+ (f - Vector2dF(1.1f, -1.1f)).ToString());
+ f -= Vector2dF(1.1f, -1.1f);
+ EXPECT_EQ(RectF(1.1f, 2.2f, 3.3f, 4.4f).ToString(), f.ToString());
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/rect_f.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698