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

Unified Diff: ui/gfx/rect_unittest.cc

Issue 11364054: ui: Add IsExpressibleAsRect() method to RectF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits 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/safe_integer_conversions.h » ('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 1f31ae261376c4ba419b4f19632315e189ac8291..fbb3c9b8779f5438fd067c8a6c1a1c58ce0bdd2d 100644
--- a/ui/gfx/rect_unittest.cc
+++ b/ui/gfx/rect_unittest.cc
@@ -671,4 +671,35 @@ TEST(RectTest, BoundingRect) {
}
}
+TEST(RectTest, IsExpressibleAsRect) {
+ //EXPECT_TRUE(gfx::RectF().IsExpressibleAsRect());
+
+ float min = std::numeric_limits<int>::min();
+ 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 + 200, min, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(gfx::RectF(min, min + 200, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(min - 200, min, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(min, min - 200, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(gfx::RectF(min, min, max - 200, max).IsExpressibleAsRect());
+ EXPECT_TRUE(gfx::RectF(min, min, max, max - 200).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(min, min, max + 200, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(min, min, max, max + 200).IsExpressibleAsRect());
+
+ EXPECT_TRUE(gfx::RectF(0, 0, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(200, 0, max, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(0, 200, max, max).IsExpressibleAsRect());
+ EXPECT_TRUE(gfx::RectF(0, 0, max - 200, max).IsExpressibleAsRect());
+ EXPECT_TRUE(gfx::RectF(0, 0, max, max - 200).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(0, 0, max + 200, max).IsExpressibleAsRect());
+ EXPECT_FALSE(gfx::RectF(0, 0, max, max + 200).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());
+}
+
} // namespace ui
« no previous file with comments | « ui/gfx/rect_f.cc ('k') | ui/gfx/safe_integer_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698