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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc

Issue 2739553005: Moves maintaining root_window_for_new_windows_ to Shell (Closed)
Patch Set: remove ash:: Created 3 years, 9 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
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/common/scoped_root_window_for_new_windows.h" 5 #include "ash/common/scoped_root_window_for_new_windows.h"
6 #include "ash/common/wm/window_positioner.h" 6 #include "ash/common/wm/window_positioner.h"
7 #include "ash/common/wm/window_resizer.h" 7 #include "ash/common/wm/window_resizer.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 std::unique_ptr<TestingProfile> profile(new TestingProfile()); 567 std::unique_ptr<TestingProfile> profile(new TestingProfile());
568 568
569 // Create browser windows that are used as reference. 569 // Create browser windows that are used as reference.
570 Browser::CreateParams params(profile.get(), true); 570 Browser::CreateParams params(profile.get(), true);
571 std::unique_ptr<Browser> browser(CreateTestBrowser( 571 std::unique_ptr<Browser> browser(CreateTestBrowser(
572 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), &params)); 572 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), &params));
573 BrowserWindow* browser_window = browser->window(); 573 BrowserWindow* browser_window = browser->window();
574 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); 574 gfx::NativeWindow native_window = browser_window->GetNativeWindow();
575 browser_window->Show(); 575 browser_window->Show();
576 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); 576 EXPECT_EQ(native_window->GetRootWindow(),
577 ash::Shell::GetRootWindowForNewWindows());
577 578
578 Browser::CreateParams another_params(profile.get(), true); 579 Browser::CreateParams another_params(profile.get(), true);
579 std::unique_ptr<Browser> another_browser( 580 std::unique_ptr<Browser> another_browser(
580 CreateTestBrowser(CreateTestWindowInShellWithId(1), 581 CreateTestBrowser(CreateTestWindowInShellWithId(1),
581 gfx::Rect(400, 10, 300, 300), &another_params)); 582 gfx::Rect(400, 10, 300, 300), &another_params));
582 BrowserWindow* another_browser_window = another_browser->window(); 583 BrowserWindow* another_browser_window = another_browser->window();
583 gfx::NativeWindow another_native_window = 584 gfx::NativeWindow another_native_window =
584 another_browser_window->GetNativeWindow(); 585 another_browser_window->GetNativeWindow();
585 another_browser_window->Show(); 586 another_browser_window->Show();
586 587
587 // Creating a new window to verify the new placement. 588 // Creating a new window to verify the new placement.
588 Browser::CreateParams new_params(profile.get(), true); 589 Browser::CreateParams new_params(profile.get(), true);
589 std::unique_ptr<Browser> new_browser(CreateTestBrowser( 590 std::unique_ptr<Browser> new_browser(CreateTestBrowser(
590 CreateTestWindowInShellWithId(0), gfx::Rect(), &new_params)); 591 CreateTestWindowInShellWithId(0), gfx::Rect(), &new_params));
591 592
592 // Make sure the primary root is active. 593 // Make sure the primary root is active.
593 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), 594 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(),
594 ash::Shell::GetTargetRootWindow()); 595 ash::Shell::GetRootWindowForNewWindows());
595 596
596 // First new window should be in the primary. 597 // First new window should be in the primary.
597 { 598 {
598 gfx::Rect window_bounds; 599 gfx::Rect window_bounds;
599 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), 600 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(),
600 secondary_bounds, PERSISTED, new_browser.get(), gfx::Rect(), 601 secondary_bounds, PERSISTED, new_browser.get(), gfx::Rect(),
601 &window_bounds); 602 &window_bounds);
602 // TODO(oshima): Use exact bounds when the window_sizer_ash is 603 // TODO(oshima): Use exact bounds when the window_sizer_ash is
603 // moved to ash and changed to include the result from 604 // moved to ash and changed to include the result from
604 // RearrangeVisibleWindowOnShow. 605 // RearrangeVisibleWindowOnShow.
605 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); 606 EXPECT_TRUE(primary_bounds.Contains(window_bounds));
606 } 607 }
607 608
608 // Move the window to the right side of the secondary display and create a new 609 // Move the window to the right side of the secondary display and create a new
609 // window. It should be opened then on the secondary display. 610 // window. It should be opened then on the secondary display.
610 { 611 {
611 display::Display second_display = 612 display::Display second_display =
612 display::Screen::GetScreen()->GetDisplayNearestPoint( 613 display::Screen::GetScreen()->GetDisplayNearestPoint(
613 gfx::Point(1600 + 100, 10)); 614 gfx::Point(1600 + 100, 10));
614 browser_window->GetNativeWindow()->SetBoundsInScreen( 615 browser_window->GetNativeWindow()->SetBoundsInScreen(
615 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), 616 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200),
616 second_display); 617 second_display);
617 aura::client::GetActivationClient(native_window->GetRootWindow()) 618 aura::client::GetActivationClient(native_window->GetRootWindow())
618 ->ActivateWindow(native_window); 619 ->ActivateWindow(native_window);
619 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), 620 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(),
620 ash::Shell::GetTargetRootWindow()); 621 ash::Shell::GetRootWindowForNewWindows());
621 gfx::Rect window_bounds; 622 gfx::Rect window_bounds;
622 ui::WindowShowState out_show_state = ui::SHOW_STATE_DEFAULT; 623 ui::WindowShowState out_show_state = ui::SHOW_STATE_DEFAULT;
623 GetWindowBoundsAndShowState( 624 GetWindowBoundsAndShowState(
624 p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), secondary_bounds, 625 p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), secondary_bounds,
625 ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_DEFAULT, PERSISTED, 626 ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_DEFAULT, PERSISTED,
626 new_browser.get(), gfx::Rect(), 1u, &window_bounds, &out_show_state); 627 new_browser.get(), gfx::Rect(), 1u, &window_bounds, &out_show_state);
627 // TODO(oshima): Use exact bounds when the window_sizer_ash is 628 // TODO(oshima): Use exact bounds when the window_sizer_ash is
628 // moved to ash and changed to include the result from 629 // moved to ash and changed to include the result from
629 // RearrangeVisibleWindowOnShow. 630 // RearrangeVisibleWindowOnShow.
630 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); 631 EXPECT_TRUE(secondary_bounds.Contains(window_bounds));
631 } 632 }
632 633
633 // Activate another window in the primary display and create a new window. 634 // Activate another window in the primary display and create a new window.
634 // It should be created in the primary display. 635 // It should be created in the primary display.
635 { 636 {
636 aura::client::GetActivationClient(another_native_window->GetRootWindow()) 637 aura::client::GetActivationClient(another_native_window->GetRootWindow())
637 ->ActivateWindow(another_native_window); 638 ->ActivateWindow(another_native_window);
638 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), 639 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(),
639 ash::Shell::GetTargetRootWindow()); 640 ash::Shell::GetRootWindowForNewWindows());
640 641
641 gfx::Rect window_bounds; 642 gfx::Rect window_bounds;
642 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), 643 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(),
643 secondary_bounds, PERSISTED, new_browser.get(), gfx::Rect(), 644 secondary_bounds, PERSISTED, new_browser.get(), gfx::Rect(),
644 &window_bounds); 645 &window_bounds);
645 // TODO(oshima): Use exact bounds when the window_sizer_ash is 646 // TODO(oshima): Use exact bounds when the window_sizer_ash is
646 // moved to ash and changed to include the result from 647 // moved to ash and changed to include the result from
647 // RearrangeVisibleWindowOnShow. 648 // RearrangeVisibleWindowOnShow.
648 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); 649 EXPECT_TRUE(primary_bounds.Contains(window_bounds));
649 } 650 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // the non browser window. This differ from PersistedBoundsCase 818 // the non browser window. This differ from PersistedBoundsCase
818 // in that this uses real ash shell implementations + StateProvider 819 // in that this uses real ash shell implementations + StateProvider
819 // TargetDisplayProvider, rather than mocks. 820 // TargetDisplayProvider, rather than mocks.
820 TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { 821 TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) {
821 if (!ash_util::ShouldOpenAshOnStartup()) 822 if (!ash_util::ShouldOpenAshOnStartup())
822 return; 823 return;
823 UpdateDisplay("500x500,600x600"); 824 UpdateDisplay("500x500,600x600");
824 825
825 // By default windows are placed on the primary display. 826 // By default windows are placed on the primary display.
826 ash::WmWindow* first_root = ash::WmShell::Get()->GetAllRootWindows()[0]; 827 ash::WmWindow* first_root = ash::WmShell::Get()->GetAllRootWindows()[0];
827 EXPECT_EQ(first_root, ash::WmShell::Get()->GetRootWindowForNewWindows()); 828 EXPECT_EQ(first_root, ash::Shell::GetWmRootWindowForNewWindows());
828 gfx::Rect bounds; 829 gfx::Rect bounds;
829 ui::WindowShowState show_state; 830 ui::WindowShowState show_state;
830 WindowSizer::GetBrowserWindowBoundsAndShowState(std::string(), gfx::Rect(), 831 WindowSizer::GetBrowserWindowBoundsAndShowState(std::string(), gfx::Rect(),
831 NULL, &bounds, &show_state); 832 NULL, &bounds, &show_state);
832 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); 833 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds));
833 834
834 { 835 {
835 // When the second display is active new windows are placed there. 836 // When the second display is active new windows are placed there.
836 ash::WmWindow* second_root = ash::WmShell::Get()->GetAllRootWindows()[1]; 837 ash::WmWindow* second_root = ash::WmShell::Get()->GetAllRootWindows()[1];
837 ash::ScopedRootWindowForNewWindows tmp(second_root); 838 ash::ScopedRootWindowForNewWindows tmp(second_root);
(...skipping 23 matching lines...) Expand all
861 EXPECT_EQ( 862 EXPECT_EQ(
862 ui::SHOW_STATE_DEFAULT, 863 ui::SHOW_STATE_DEFAULT,
863 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, 864 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH,
864 trusted_popup.get(), p1280x1024, p1600x1200)); 865 trusted_popup.get(), p1280x1024, p1600x1200));
865 // A popup that is sized to occupy the whole work area has default state. 866 // A popup that is sized to occupy the whole work area has default state.
866 EXPECT_EQ( 867 EXPECT_EQ(
867 ui::SHOW_STATE_DEFAULT, 868 ui::SHOW_STATE_DEFAULT,
868 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, 869 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH,
869 trusted_popup.get(), p1600x1200, p1600x1200)); 870 trusted_popup.get(), p1600x1200, p1600x1200));
870 } 871 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc ('k') | components/exo/wm_helper_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698