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

Unified Diff: ui/gfx/mac/coordinate_conversion_unittest.mm

Issue 1287573002: [Mac] Add gfx::ScreenPoint[To|From]NSPoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@openurl
Patch Set: Address comments. Created 5 years, 4 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
« ui/gfx/mac/coordinate_conversion.mm ('K') | « ui/gfx/mac/coordinate_conversion.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mac/coordinate_conversion_unittest.mm
diff --git a/ui/gfx/mac/coordinate_conversion_unittest.mm b/ui/gfx/mac/coordinate_conversion_unittest.mm
index ae4931763c8a212db0fe07e6d1a9c2ca97e7eb58..ac882fa65dff57e2125b90d6f8d34fee0680d060 100644
--- a/ui/gfx/mac/coordinate_conversion_unittest.mm
+++ b/ui/gfx/mac/coordinate_conversion_unittest.mm
@@ -81,28 +81,57 @@ void MacCoordinateConversionTest::TearDown() {
// .. ..
// 0 199
TEST_F(MacCoordinateConversionTest, ScreenRectToFromNSRect) {
+ // Window on the primary screen.
Rect gfx_rect = Rect(10, 20, 30, 40);
NSRect ns_rect = ScreenRectToNSRect(gfx_rect);
EXPECT_NSEQ(NSMakeRect(10, 140, 30, 40), ns_rect);
- EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString());
+ EXPECT_EQ(gfx_rect, ScreenRectFromNSRect(ns_rect));
msw 2015/08/11 17:41:48 nit: I'm not strongly opinionated here, but some f
jackhou1 2015/08/11 22:01:12 gfx::Rect gets pretty good failure messages these
msw 2015/08/11 22:02:02 Acknowledged.
// Window in a screen to the left of the primary screen.
gfx_rect = Rect(-40, 20, 30, 40);
ns_rect = ScreenRectToNSRect(gfx_rect);
EXPECT_NSEQ(NSMakeRect(-40, 140, 30, 40), ns_rect);
- EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString());
+ EXPECT_EQ(gfx_rect, ScreenRectFromNSRect(ns_rect));
// Window in a screen below the primary screen.
gfx_rect = Rect(10, 220, 30, 40);
ns_rect = ScreenRectToNSRect(gfx_rect);
EXPECT_NSEQ(NSMakeRect(10, -60, 30, 40), ns_rect);
- EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString());
+ EXPECT_EQ(gfx_rect, ScreenRectFromNSRect(ns_rect));
// Window in a screen below and to the left primary screen.
gfx_rect = Rect(-40, 220, 30, 40);
ns_rect = ScreenRectToNSRect(gfx_rect);
EXPECT_NSEQ(NSMakeRect(-40, -60, 30, 40), ns_rect);
- EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString());
+ EXPECT_EQ(gfx_rect, ScreenRectFromNSRect(ns_rect));
+}
+
+// Test point conversions using the same setup as ScreenRectToFromNSRect, but
+// using only the origin.
+TEST_F(MacCoordinateConversionTest, ScreenPointToFromNSPoint) {
+ // Point on the primary screen.
+ Point gfx_point = Point(10, 20);
+ NSPoint ns_point = ScreenPointToNSPoint(gfx_point);
+ EXPECT_NSEQ(NSMakePoint(10, 180), ns_point);
+ EXPECT_EQ(gfx_point, ScreenPointFromNSPoint(ns_point));
+
+ // Point in a screen to the left of the primary screen.
+ gfx_point = Point(-40, 20);
+ ns_point = ScreenPointToNSPoint(gfx_point);
+ EXPECT_NSEQ(NSMakePoint(-40, 180), ns_point);
+ EXPECT_EQ(gfx_point, ScreenPointFromNSPoint(ns_point));
+
+ // Point in a screen below the primary screen.
+ gfx_point = Point(10, 220);
+ ns_point = ScreenPointToNSPoint(gfx_point);
+ EXPECT_NSEQ(NSMakePoint(10, -20), ns_point);
+ EXPECT_EQ(gfx_point, ScreenPointFromNSPoint(ns_point));
+
+ // Point in a screen below and to the left primary screen.
+ gfx_point = Point(-40, 220);
+ ns_point = ScreenPointToNSPoint(gfx_point);
+ EXPECT_NSEQ(NSMakePoint(-40, -20), ns_point);
+ EXPECT_EQ(gfx_point, ScreenPointFromNSPoint(ns_point));
}
} // namespace gfx
« ui/gfx/mac/coordinate_conversion.mm ('K') | « ui/gfx/mac/coordinate_conversion.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698