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

Side by Side Diff: ui/base/cocoa/base_view_unittest.mm

Issue 10545050: mac: Use NSWidth() and friends in a few more places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/cocoa/base_view.mm ('k') | ui/base/cocoa/underlay_opengl_hosting_window.mm » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/memory/scoped_nsobject.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h" 9 #include "testing/platform_test.h"
10 #include "ui/base/cocoa/base_view.h" 10 #include "ui/base/cocoa/base_view.h"
(...skipping 16 matching lines...) Expand all
27 TEST_VIEW(BaseViewTest, view_) 27 TEST_VIEW(BaseViewTest, view_)
28 28
29 // Convert a rect in |view_|'s Cocoa coordinate system to gfx::Rect's top-left 29 // Convert a rect in |view_|'s Cocoa coordinate system to gfx::Rect's top-left
30 // coordinate system. Repeat the process in reverse and make sure we come out 30 // coordinate system. Repeat the process in reverse and make sure we come out
31 // with the original rect. 31 // with the original rect.
32 TEST_F(BaseViewTest, flipNSRectToRect) { 32 TEST_F(BaseViewTest, flipNSRectToRect) {
33 NSRect convert = NSMakeRect(10, 10, 50, 50); 33 NSRect convert = NSMakeRect(10, 10, 50, 50);
34 gfx::Rect converted = [view_ flipNSRectToRect:convert]; 34 gfx::Rect converted = [view_ flipNSRectToRect:convert];
35 EXPECT_EQ(converted.x(), 10); 35 EXPECT_EQ(converted.x(), 10);
36 EXPECT_EQ(converted.y(), 40); // Due to view being 100px tall. 36 EXPECT_EQ(converted.y(), 40); // Due to view being 100px tall.
37 EXPECT_EQ(converted.width(), convert.size.width); 37 EXPECT_EQ(converted.width(), NSWidth(convert));
38 EXPECT_EQ(converted.height(), convert.size.height); 38 EXPECT_EQ(converted.height(), NSHeight(convert));
39 39
40 // Go back the other way. 40 // Go back the other way.
41 NSRect back_again = [view_ flipRectToNSRect:converted]; 41 NSRect back_again = [view_ flipRectToNSRect:converted];
42 EXPECT_EQ(back_again.origin.x, convert.origin.x); 42 EXPECT_EQ(NSMinX(back_again), NSMinX(convert));
43 EXPECT_EQ(back_again.origin.y, convert.origin.y); 43 EXPECT_EQ(NSMinY(back_again), NSMinY(convert));
44 EXPECT_EQ(back_again.size.width, convert.size.width); 44 EXPECT_EQ(NSWidth(back_again), NSWidth(convert));
45 EXPECT_EQ(back_again.size.height, convert.size.height); 45 EXPECT_EQ(NSHeight(back_again), NSHeight(convert));
46 } 46 }
47 47
48 } // namespace 48 } // namespace
OLDNEW
« no previous file with comments | « ui/base/cocoa/base_view.mm ('k') | ui/base/cocoa/underlay_opengl_hosting_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698