| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ui/gfx/mac/coordinate_conversion.h" | 5 #import "ui/gfx/mac/coordinate_conversion.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #import "base/mac/scoped_objc_class_swizzler.h" | 9 #import "base/mac/scoped_objc_class_swizzler.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 EXPECT_TRUE(NSEqualRects(NSMakeRect(10, -60, 30, 40), ns_rect)); | 97 EXPECT_TRUE(NSEqualRects(NSMakeRect(10, -60, 30, 40), ns_rect)); |
| 98 EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString()); | 98 EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString()); |
| 99 | 99 |
| 100 // Window in a screen below and to the left primary screen. | 100 // Window in a screen below and to the left primary screen. |
| 101 gfx_rect = Rect(-40, 220, 30, 40); | 101 gfx_rect = Rect(-40, 220, 30, 40); |
| 102 ns_rect = ScreenRectToNSRect(gfx_rect); | 102 ns_rect = ScreenRectToNSRect(gfx_rect); |
| 103 EXPECT_TRUE(NSEqualRects(NSMakeRect(-40, -60, 30, 40), ns_rect)); | 103 EXPECT_TRUE(NSEqualRects(NSMakeRect(-40, -60, 30, 40), ns_rect)); |
| 104 EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString()); | 104 EXPECT_EQ(gfx_rect.ToString(), ScreenRectFromNSRect(ns_rect).ToString()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Test point conversion, using the same setup as above. |
| 108 TEST_F(MacCoordinateConversionTest, ScreenPointFromNSPoint) { |
| 109 Point gfx_point = Point(10, 20); |
| 110 NSPoint ns_point = ScreenPointToNSPoint(gfx_point); |
| 111 EXPECT_TRUE(NSEqualPoints(NSMakePoint(10, 180), ns_point)); |
| 112 EXPECT_EQ(gfx_point.ToString(), ScreenPointFromNSPoint(ns_point).ToString()); |
| 113 |
| 114 // Point in a screen to the left of the primary screen. |
| 115 gfx_point = Point(-40, 20); |
| 116 ns_point = ScreenPointToNSPoint(gfx_point); |
| 117 EXPECT_TRUE(NSEqualPoints(NSMakePoint(-40, 180), ns_point)); |
| 118 EXPECT_EQ(gfx_point.ToString(), ScreenPointFromNSPoint(ns_point).ToString()); |
| 119 |
| 120 // Point in a screen below the primary screen. |
| 121 gfx_point = Point(10, 220); |
| 122 ns_point = ScreenPointToNSPoint(gfx_point); |
| 123 EXPECT_TRUE(NSEqualPoints(NSMakePoint(10, -20), ns_point)); |
| 124 EXPECT_EQ(gfx_point.ToString(), ScreenPointFromNSPoint(ns_point).ToString()); |
| 125 |
| 126 // Point in a screen below and to the left primary screen. |
| 127 gfx_point = Point(-40, 220); |
| 128 ns_point = ScreenPointToNSPoint(gfx_point); |
| 129 EXPECT_TRUE(NSEqualPoints(NSMakePoint(-40, -20), ns_point)); |
| 130 EXPECT_EQ(gfx_point.ToString(), ScreenPointFromNSPoint(ns_point).ToString()); |
| 131 } |
| 132 |
| 107 } // namespace gfx | 133 } // namespace gfx |
| OLD | NEW |