| 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 #include "ui/views/controls/native/native_view_host_mac.h" | 5 #include "ui/views/controls/native/native_view_host_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 EXPECT_TRUE([native_view_ superview]); | 93 EXPECT_TRUE([native_view_ superview]); |
| 94 EXPECT_TRUE([native_view_ window]); | 94 EXPECT_TRUE([native_view_ window]); |
| 95 | 95 |
| 96 // Expect the top-left to be 10 pixels below the titlebar. | 96 // Expect the top-left to be 10 pixels below the titlebar. |
| 97 int bottom = toplevel()->GetClientAreaBoundsInScreen().height() - 10 - 60; | 97 int bottom = toplevel()->GetClientAreaBoundsInScreen().height() - 10 - 60; |
| 98 EXPECT_NSEQ(NSMakeRect(10, bottom, 80, 60), [native_view_ frame]); | 98 EXPECT_NSEQ(NSMakeRect(10, bottom, 80, 60), [native_view_ frame]); |
| 99 | 99 |
| 100 DestroyHost(); | 100 DestroyHost(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Test that the content windows' bounds are set to the correct values while the |
| 104 // rendering size is equal or not equal to the View size. |
| 105 TEST_F(NativeViewHostMacTest, ContentViewPositionAndSize) { |
| 106 CreateHost(); |
| 107 toplevel()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 108 EXPECT_EQ(gfx::Transform(), host()->native_view()->transform()); |
| 109 |
| 110 native_host()->ShowWidget(5, 10, 100, 100, 200, 200); |
| 111 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 112 host()->native_view()->bounds().ToString()); |
| 113 |
| 114 native_host()->ShowWidget(10, 25, 50, 50, 50, 50); |
| 115 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 116 host()->native_view()->bounds().ToString()); |
| 117 |
| 118 DestroyHost(); |
| 119 } |
| 120 |
| 103 // Ensure the native view is hidden along with its host, and when detaching, or | 121 // Ensure the native view is hidden along with its host, and when detaching, or |
| 104 // when attaching to a host that is already hidden. | 122 // when attaching to a host that is already hidden. |
| 105 TEST_F(NativeViewHostMacTest, NativeViewHidden) { | 123 TEST_F(NativeViewHostMacTest, NativeViewHidden) { |
| 106 CreateHost(); | 124 CreateHost(); |
| 107 toplevel()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 125 toplevel()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 108 host()->SetBounds(10, 10, 80, 60); | 126 host()->SetBounds(10, 10, 80, 60); |
| 109 | 127 |
| 110 EXPECT_FALSE([native_view_ isHidden]); | 128 EXPECT_FALSE([native_view_ isHidden]); |
| 111 host()->SetVisible(false); | 129 host()->SetVisible(false); |
| 112 EXPECT_TRUE([native_view_ isHidden]); | 130 EXPECT_TRUE([native_view_ isHidden]); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 174 } |
| 157 | 175 |
| 158 // During teardown, NativeViewDetaching() is called in RemovedFromWidget(). | 176 // During teardown, NativeViewDetaching() is called in RemovedFromWidget(). |
| 159 // Just trigger it with Detach(). | 177 // Just trigger it with Detach(). |
| 160 host()->Detach(); | 178 host()->Detach(); |
| 161 | 179 |
| 162 DestroyHost(); | 180 DestroyHost(); |
| 163 } | 181 } |
| 164 | 182 |
| 165 } // namespace views | 183 } // namespace views |
| OLD | NEW |