| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |