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

Side by Side Diff: ui/gfx/mac/coordinate_conversion_unittest.mm

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: NULL -> nullptr Created 6 years 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/mac/coordinate_conversion.mm ('k') | ui/views/cocoa/bridged_content_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/gfx/mac/coordinate_conversion.mm ('k') | ui/views/cocoa/bridged_content_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698