| 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/common/scoped_root_window_for_new_windows.h" |
| 5 #include "ash/common/wm/window_positioner.h" | 6 #include "ash/common/wm/window_positioner.h" |
| 6 #include "ash/common/wm/window_resizer.h" | 7 #include "ash/common/wm/window_resizer.h" |
| 7 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/scoped_target_root_window.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/common/wm_window.h" |
| 9 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
| 10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/wm/window_state_aura.h" | 14 #include "ash/wm/window_state_aura.h" |
| 13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 14 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 15 #include "chrome/browser/ui/ash/ash_util.h" | 17 #include "chrome/browser/ui/ash/ash_util.h" |
| 16 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" | 19 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" |
| 18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip
leDisplays | 556 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip
leDisplays |
| 555 #endif | 557 #endif |
| 556 | 558 |
| 557 // Test the placement of newly created windows on multiple dislays. | 559 // Test the placement of newly created windows on multiple dislays. |
| 558 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { | 560 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { |
| 559 UpdateDisplay("1600x1200,1600x1200"); | 561 UpdateDisplay("1600x1200,1600x1200"); |
| 560 gfx::Rect primary_bounds = | 562 gfx::Rect primary_bounds = |
| 561 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 563 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 562 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); | 564 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); |
| 563 | 565 |
| 564 ash::Shell::GetInstance()->set_target_root_window( | |
| 565 ash::Shell::GetPrimaryRootWindow()); | |
| 566 | |
| 567 std::unique_ptr<TestingProfile> profile(new TestingProfile()); | 566 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 568 | 567 |
| 569 // Create browser windows that are used as reference. | 568 // Create browser windows that are used as reference. |
| 570 Browser::CreateParams params(profile.get()); | 569 Browser::CreateParams params(profile.get()); |
| 571 std::unique_ptr<Browser> browser(CreateTestBrowser( | 570 std::unique_ptr<Browser> browser(CreateTestBrowser( |
| 572 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), ¶ms)); | 571 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), ¶ms)); |
| 573 BrowserWindow* browser_window = browser->window(); | 572 BrowserWindow* browser_window = browser->window(); |
| 574 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); | 573 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); |
| 575 browser_window->Show(); | 574 browser_window->Show(); |
| 576 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); | 575 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 813 } |
| 815 | 814 |
| 816 // Test that the target root window is used as the destination of | 815 // Test that the target root window is used as the destination of |
| 817 // the non browser window. This differ from PersistedBoundsCase | 816 // the non browser window. This differ from PersistedBoundsCase |
| 818 // in that this uses real ash shell implementations + StateProvider | 817 // in that this uses real ash shell implementations + StateProvider |
| 819 // TargetDisplayProvider, rather than mocks. | 818 // TargetDisplayProvider, rather than mocks. |
| 820 TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { | 819 TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { |
| 821 if (!SupportsMultipleDisplays() || !chrome::ShouldOpenAshOnStartup()) | 820 if (!SupportsMultipleDisplays() || !chrome::ShouldOpenAshOnStartup()) |
| 822 return; | 821 return; |
| 823 UpdateDisplay("500x500,600x600"); | 822 UpdateDisplay("500x500,600x600"); |
| 823 |
| 824 // By default windows are placed on the primary display. |
| 825 ash::WmWindow* first_root = ash::WmShell::Get()->GetAllRootWindows()[0]; |
| 826 EXPECT_EQ(first_root, ash::WmShell::Get()->GetRootWindowForNewWindows()); |
| 827 gfx::Rect bounds; |
| 828 ui::WindowShowState show_state; |
| 829 WindowSizer::GetBrowserWindowBoundsAndShowState(std::string(), gfx::Rect(), |
| 830 NULL, &bounds, &show_state); |
| 831 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); |
| 832 |
| 824 { | 833 { |
| 825 aura::Window* first_root = | 834 // When the second display is active new windows are placed there. |
| 826 ash::Shell::GetAllRootWindows()[0]; | 835 ash::WmWindow* second_root = ash::WmShell::Get()->GetAllRootWindows()[1]; |
| 827 ash::ScopedTargetRootWindow tmp(first_root); | 836 ash::ScopedRootWindowForNewWindows tmp(second_root); |
| 828 gfx::Rect bounds; | 837 gfx::Rect bounds; |
| 829 ui::WindowShowState show_state; | 838 ui::WindowShowState show_state; |
| 830 WindowSizer::GetBrowserWindowBoundsAndShowState( | 839 WindowSizer::GetBrowserWindowBoundsAndShowState( |
| 831 std::string(), | |
| 832 gfx::Rect(), | |
| 833 NULL, | |
| 834 &bounds, | |
| 835 &show_state); | |
| 836 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); | |
| 837 } | |
| 838 { | |
| 839 aura::Window* second_root = | |
| 840 ash::Shell::GetAllRootWindows()[1]; | |
| 841 ash::ScopedTargetRootWindow tmp(second_root); | |
| 842 gfx::Rect bounds; | |
| 843 ui::WindowShowState show_state; | |
| 844 WindowSizer::GetBrowserWindowBoundsAndShowState( | |
| 845 std::string(), | 840 std::string(), |
| 846 gfx::Rect(), | 841 gfx::Rect(), |
| 847 NULL, | 842 NULL, |
| 848 &bounds, | 843 &bounds, |
| 849 &show_state); | 844 &show_state); |
| 850 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); | 845 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); |
| 851 } | 846 } |
| 852 } | 847 } |
| 853 | 848 |
| 854 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { | 849 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 865 EXPECT_EQ( | 860 EXPECT_EQ( |
| 866 ui::SHOW_STATE_DEFAULT, | 861 ui::SHOW_STATE_DEFAULT, |
| 867 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 862 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 868 trusted_popup.get(), p1280x1024, p1600x1200)); | 863 trusted_popup.get(), p1280x1024, p1600x1200)); |
| 869 // A popup that is sized to occupy the whole work area has default state. | 864 // A popup that is sized to occupy the whole work area has default state. |
| 870 EXPECT_EQ( | 865 EXPECT_EQ( |
| 871 ui::SHOW_STATE_DEFAULT, | 866 ui::SHOW_STATE_DEFAULT, |
| 872 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 867 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 873 trusted_popup.get(), p1600x1200, p1600x1200)); | 868 trusted_popup.get(), p1600x1200, p1600x1200)); |
| 874 } | 869 } |
| OLD | NEW |