| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/public/cpp/config.h" | 9 #include "ash/public/cpp/config.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); | 553 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); |
| 554 | 554 |
| 555 // Verify that the first root window controller remains in fullscreen mode | 555 // Verify that the first root window controller remains in fullscreen mode |
| 556 // when a window on the other display is activated. | 556 // when a window on the other display is activated. |
| 557 w3->Activate(); | 557 w3->Activate(); |
| 558 EXPECT_EQ(w2->GetNativeWindow(), | 558 EXPECT_EQ(w2->GetNativeWindow(), |
| 559 controllers[0]->GetWindowForFullscreenMode()); | 559 controllers[0]->GetWindowForFullscreenMode()); |
| 560 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); | 560 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 // Test that GetRootWindowController() works with multiple displays and | 563 // Test that ForWindow() works with multiple displays and child widgets. |
| 564 // child widgets. | 564 TEST_F(RootWindowControllerTest, ForWindow) { |
| 565 TEST_F(RootWindowControllerTest, GetRootWindowController) { | |
| 566 UpdateDisplay("600x600,600x600"); | 565 UpdateDisplay("600x600,600x600"); |
| 567 Shell::RootWindowControllerList controllers = | 566 Shell::RootWindowControllerList controllers = |
| 568 Shell::Get()->GetAllRootWindowControllers(); | 567 Shell::Get()->GetAllRootWindowControllers(); |
| 569 ASSERT_EQ(2u, controllers.size()); | 568 ASSERT_EQ(2u, controllers.size()); |
| 570 | 569 |
| 571 // Test null. | 570 // Test null. |
| 572 EXPECT_FALSE(GetRootWindowController(nullptr)); | 571 EXPECT_FALSE(RootWindowController::ForWindow(nullptr)); |
| 572 |
| 573 // Test a root window. |
| 574 EXPECT_EQ(controllers[0], |
| 575 RootWindowController::ForWindow(Shell::GetPrimaryRootWindow())); |
| 573 | 576 |
| 574 // Test a widget on the first display. | 577 // Test a widget on the first display. |
| 575 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); | 578 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); |
| 576 EXPECT_EQ(controllers[0], | 579 EXPECT_EQ(controllers[0], |
| 577 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); | 580 RootWindowController::ForWindow(w1->GetNativeWindow())); |
| 578 | 581 |
| 579 // Test a child widget. | 582 // Test a child widget. |
| 580 Widget* w2 = Widget::CreateWindowWithParentAndBounds( | 583 Widget* w2 = Widget::CreateWindowWithParentAndBounds( |
| 581 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); | 584 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); |
| 582 EXPECT_EQ(controllers[0], | 585 EXPECT_EQ(controllers[0], |
| 583 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); | 586 RootWindowController::ForWindow(w2->GetNativeWindow())); |
| 584 | 587 |
| 585 // Test a widget on the second display. | 588 // Test a widget on the second display. |
| 586 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); | 589 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); |
| 587 EXPECT_EQ(controllers[1], | 590 EXPECT_EQ(controllers[1], |
| 588 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); | 591 RootWindowController::ForWindow(w3->GetNativeWindow())); |
| 589 } | 592 } |
| 590 | 593 |
| 591 // Test that user session window can't be focused if user session blocked by | 594 // Test that user session window can't be focused if user session blocked by |
| 592 // some overlapping UI. | 595 // some overlapping UI. |
| 593 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { | 596 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { |
| 594 UpdateDisplay("600x600"); | 597 UpdateDisplay("600x600"); |
| 595 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 598 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
| 596 aura::Window* lock_container = | 599 aura::Window* lock_container = |
| 597 controller->GetContainer(kShellWindowId_LockScreenContainer); | 600 controller->GetContainer(kShellWindowId_LockScreenContainer); |
| 598 aura::Window* lock_window = | 601 aura::Window* lock_window = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 | 653 |
| 651 // Verifies shutdown doesn't delete windows that are not owned by the parent. | 654 // Verifies shutdown doesn't delete windows that are not owned by the parent. |
| 652 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { | 655 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { |
| 653 DestroyedWindowObserver observer1; | 656 DestroyedWindowObserver observer1; |
| 654 aura::test::TestWindowDelegate delegate1; | 657 aura::test::TestWindowDelegate delegate1; |
| 655 aura::Window* window1 = new aura::Window(&delegate1); | 658 aura::Window* window1 = new aura::Window(&delegate1); |
| 656 window1->SetType(aura::client::WINDOW_TYPE_CONTROL); | 659 window1->SetType(aura::client::WINDOW_TYPE_CONTROL); |
| 657 window1->set_owned_by_parent(false); | 660 window1->set_owned_by_parent(false); |
| 658 observer1.SetWindow(window1); | 661 observer1.SetWindow(window1); |
| 659 window1->Init(ui::LAYER_NOT_DRAWN); | 662 window1->Init(ui::LAYER_NOT_DRAWN); |
| 660 aura::client::ParentWindowWithContext( | 663 aura::client::ParentWindowWithContext(window1, Shell::GetPrimaryRootWindow(), |
| 661 window1, Shell::Get()->GetPrimaryRootWindow(), gfx::Rect()); | 664 gfx::Rect()); |
| 662 | 665 |
| 663 DestroyedWindowObserver observer2; | 666 DestroyedWindowObserver observer2; |
| 664 aura::Window* window2 = new aura::Window(NULL); | 667 aura::Window* window2 = new aura::Window(NULL); |
| 665 window2->set_owned_by_parent(false); | 668 window2->set_owned_by_parent(false); |
| 666 observer2.SetWindow(window2); | 669 observer2.SetWindow(window2); |
| 667 window2->Init(ui::LAYER_NOT_DRAWN); | 670 window2->Init(ui::LAYER_NOT_DRAWN); |
| 668 Shell::Get()->GetPrimaryRootWindow()->AddChild(window2); | 671 Shell::GetPrimaryRootWindow()->AddChild(window2); |
| 669 | 672 |
| 670 Shell::GetPrimaryRootWindowController()->CloseChildWindows(); | 673 Shell::GetPrimaryRootWindowController()->CloseChildWindows(); |
| 671 | 674 |
| 672 ASSERT_FALSE(observer1.destroyed()); | 675 ASSERT_FALSE(observer1.destroyed()); |
| 673 delete window1; | 676 delete window1; |
| 674 | 677 |
| 675 ASSERT_FALSE(observer2.destroyed()); | 678 ASSERT_FALSE(observer2.destroyed()); |
| 676 delete window2; | 679 delete window2; |
| 677 } | 680 } |
| 678 | 681 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1236 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1234 gfx::Rect(0, 400, 800, 200)); | 1237 gfx::Rect(0, 400, 800, 200)); |
| 1235 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1238 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1236 | 1239 |
| 1237 UpdateDisplay("600x800"); | 1240 UpdateDisplay("600x800"); |
| 1238 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1241 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1239 } | 1242 } |
| 1240 | 1243 |
| 1241 } // namespace test | 1244 } // namespace test |
| 1242 } // namespace ash | 1245 } // namespace ash |
| OLD | NEW |