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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2911393002: Nix GetRootWindowController, use RootWindowController::ForWindow. (Closed)
Patch Set: Sync and rebase AGAIN Created 3 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
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/screen_util.cc » ('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) 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
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 a root window.
572 EXPECT_FALSE(GetRootWindowController(nullptr)); 571 EXPECT_EQ(controllers[0],
572 RootWindowController::ForWindow(Shell::GetPrimaryRootWindow()));
573 573
574 // Test a widget on the first display. 574 // Test a widget on the first display.
575 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 575 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
576 EXPECT_EQ(controllers[0], 576 EXPECT_EQ(controllers[0],
577 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); 577 RootWindowController::ForWindow(w1->GetNativeWindow()));
578 578
579 // Test a child widget. 579 // Test a child widget.
580 Widget* w2 = Widget::CreateWindowWithParentAndBounds( 580 Widget* w2 = Widget::CreateWindowWithParentAndBounds(
581 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); 581 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100));
582 EXPECT_EQ(controllers[0], 582 EXPECT_EQ(controllers[0],
583 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); 583 RootWindowController::ForWindow(w2->GetNativeWindow()));
584 584
585 // Test a widget on the second display. 585 // Test a widget on the second display.
586 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 586 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
587 EXPECT_EQ(controllers[1], 587 EXPECT_EQ(controllers[1],
588 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); 588 RootWindowController::ForWindow(w3->GetNativeWindow()));
589 } 589 }
590 590
591 // Test that user session window can't be focused if user session blocked by 591 // Test that user session window can't be focused if user session blocked by
592 // some overlapping UI. 592 // some overlapping UI.
593 TEST_F(RootWindowControllerTest, FocusBlockedWindow) { 593 TEST_F(RootWindowControllerTest, FocusBlockedWindow) {
594 UpdateDisplay("600x600"); 594 UpdateDisplay("600x600");
595 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 595 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
596 aura::Window* lock_container = 596 aura::Window* lock_container =
597 controller->GetContainer(kShellWindowId_LockScreenContainer); 597 controller->GetContainer(kShellWindowId_LockScreenContainer);
598 aura::Window* lock_window = 598 aura::Window* lock_window =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 650
651 // Verifies shutdown doesn't delete windows that are not owned by the parent. 651 // Verifies shutdown doesn't delete windows that are not owned by the parent.
652 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { 652 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) {
653 DestroyedWindowObserver observer1; 653 DestroyedWindowObserver observer1;
654 aura::test::TestWindowDelegate delegate1; 654 aura::test::TestWindowDelegate delegate1;
655 aura::Window* window1 = new aura::Window(&delegate1); 655 aura::Window* window1 = new aura::Window(&delegate1);
656 window1->SetType(aura::client::WINDOW_TYPE_CONTROL); 656 window1->SetType(aura::client::WINDOW_TYPE_CONTROL);
657 window1->set_owned_by_parent(false); 657 window1->set_owned_by_parent(false);
658 observer1.SetWindow(window1); 658 observer1.SetWindow(window1);
659 window1->Init(ui::LAYER_NOT_DRAWN); 659 window1->Init(ui::LAYER_NOT_DRAWN);
660 aura::client::ParentWindowWithContext( 660 aura::client::ParentWindowWithContext(window1, Shell::GetPrimaryRootWindow(),
661 window1, Shell::Get()->GetPrimaryRootWindow(), gfx::Rect()); 661 gfx::Rect());
662 662
663 DestroyedWindowObserver observer2; 663 DestroyedWindowObserver observer2;
664 aura::Window* window2 = new aura::Window(NULL); 664 aura::Window* window2 = new aura::Window(NULL);
665 window2->set_owned_by_parent(false); 665 window2->set_owned_by_parent(false);
666 observer2.SetWindow(window2); 666 observer2.SetWindow(window2);
667 window2->Init(ui::LAYER_NOT_DRAWN); 667 window2->Init(ui::LAYER_NOT_DRAWN);
668 Shell::Get()->GetPrimaryRootWindow()->AddChild(window2); 668 Shell::GetPrimaryRootWindow()->AddChild(window2);
669 669
670 Shell::GetPrimaryRootWindowController()->CloseChildWindows(); 670 Shell::GetPrimaryRootWindowController()->CloseChildWindows();
671 671
672 ASSERT_FALSE(observer1.destroyed()); 672 ASSERT_FALSE(observer1.destroyed());
673 delete window1; 673 delete window1;
674 674
675 ASSERT_FALSE(observer2.destroyed()); 675 ASSERT_FALSE(observer2.destroyed());
676 delete window2; 676 delete window2;
677 } 677 }
678 678
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1233 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1234 gfx::Rect(0, 400, 800, 200)); 1234 gfx::Rect(0, 400, 800, 200));
1235 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1235 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1236 1236
1237 UpdateDisplay("600x800"); 1237 UpdateDisplay("600x800");
1238 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1238 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1239 } 1239 }
1240 1240
1241 } // namespace test 1241 } // namespace test
1242 } // namespace ash 1242 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/screen_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698