| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_aura.h" | 5 #include "ui/views/controls/native/native_view_host_aura.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 clipping_window()->bounds().ToString()); | 250 clipping_window()->bounds().ToString()); |
| 251 | 251 |
| 252 DestroyHost(); | 252 DestroyHost(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Ensure native view is parented to the root window after detaching. This is | 255 // Ensure native view is parented to the root window after detaching. This is |
| 256 // a regression test for http://crbug.com/389261. | 256 // a regression test for http://crbug.com/389261. |
| 257 TEST_F(NativeViewHostAuraTest, ParentAfterDetach) { | 257 TEST_F(NativeViewHostAuraTest, ParentAfterDetach) { |
| 258 CreateHost(); | 258 CreateHost(); |
| 259 aura::Window* child_win = child()->GetNativeView(); | 259 aura::Window* child_win = child()->GetNativeView(); |
| 260 aura::Window* root_window = child_win->GetRootWindow(); |
| 261 aura::WindowTreeHost* child_win_tree_host = child_win->GetHost(); |
| 260 | 262 |
| 261 NativeViewHostWindowObserver test_observer; | 263 NativeViewHostWindowObserver test_observer; |
| 262 child_win->AddObserver(&test_observer); | 264 child_win->AddObserver(&test_observer); |
| 263 | 265 |
| 264 host()->Detach(); | 266 host()->Detach(); |
| 265 EXPECT_EQ(nullptr, child_win->GetRootWindow()); | 267 EXPECT_EQ(root_window, child_win->GetRootWindow()); |
| 266 EXPECT_EQ(nullptr, child_win->GetHost()); | 268 EXPECT_EQ(child_win_tree_host, child_win->GetHost()); |
| 267 | 269 |
| 268 DestroyHost(); | 270 DestroyHost(); |
| 271 DestroyTopLevel(); |
| 272 if (!IsMus()) { |
| 273 // The window is detached, so no longer associated with any Widget |
| 274 // hierarchy. The root window still owns it, but the test harness checks |
| 275 // for orphaned windows during TearDown(). |
| 276 EXPECT_EQ(0u, test_observer.events().size()) |
| 277 << (*test_observer.events().begin()).type; |
| 278 delete child_win; |
| 279 } else { |
| 280 // In mus, the child window is still attached to the aura::WindowTreeHost |
| 281 // for the Widget. So destroying the toplevel Widget takes down the child |
| 282 // window with it. |
| 283 } |
| 269 | 284 |
| 270 // The window is detached, so no longer associated with any Widget hierarchy. | |
| 271 // The root window still owns it, but the test harness checks for orphaned | |
| 272 // windows during TearDown(). | |
| 273 DestroyTopLevel(); | |
| 274 EXPECT_EQ(0u, test_observer.events().size()); | |
| 275 delete child_win; | |
| 276 ASSERT_EQ(1u, test_observer.events().size()); | 285 ASSERT_EQ(1u, test_observer.events().size()); |
| 277 EXPECT_EQ(NativeViewHostWindowObserver::EVENT_DESTROYED, | 286 EXPECT_EQ(NativeViewHostWindowObserver::EVENT_DESTROYED, |
| 278 test_observer.events().back().type); | 287 test_observer.events().back().type); |
| 279 } | 288 } |
| 280 | 289 |
| 281 // Ensure the clipping window is hidden before setting the native view's bounds. | 290 // Ensure the clipping window is hidden before setting the native view's bounds. |
| 282 // This is a regression test for http://crbug.com/388699. | 291 // This is a regression test for http://crbug.com/388699. |
| 283 TEST_F(NativeViewHostAuraTest, RemoveClippingWindowOrder) { | 292 TEST_F(NativeViewHostAuraTest, RemoveClippingWindowOrder) { |
| 284 CreateHost(); | 293 CreateHost(); |
| 285 toplevel()->SetBounds(gfx::Rect(20, 20, 100, 100)); | 294 toplevel()->SetBounds(gfx::Rect(20, 20, 100, 100)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 370 |
| 362 host()->SetVisible(false); | 371 host()->SetVisible(false); |
| 363 EXPECT_FALSE(clipping_window()->IsVisible()); | 372 EXPECT_FALSE(clipping_window()->IsVisible()); |
| 364 EXPECT_FALSE(child()->IsVisible()); | 373 EXPECT_FALSE(child()->IsVisible()); |
| 365 | 374 |
| 366 DestroyHost(); | 375 DestroyHost(); |
| 367 DestroyTopLevel(); | 376 DestroyTopLevel(); |
| 368 } | 377 } |
| 369 | 378 |
| 370 } // namespace views | 379 } // namespace views |
| OLD | NEW |