Chromium Code Reviews| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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"); |
| 824 { | 823 { |
| 825 aura::Window* first_root = | 824 ash::WmWindow* first_root = ash::WmShell::Get()->GetAllRootWindows()[0]; |
|
msw
2016/08/02 01:04:51
optional nit: ScopedRootWindowForNewWindows for fi
James Cook
2016/08/02 16:16:04
Done.
| |
| 826 ash::Shell::GetAllRootWindows()[0]; | 825 ash::ScopedRootWindowForNewWindows tmp(first_root); |
| 827 ash::ScopedTargetRootWindow tmp(first_root); | |
| 828 gfx::Rect bounds; | 826 gfx::Rect bounds; |
| 829 ui::WindowShowState show_state; | 827 ui::WindowShowState show_state; |
| 830 WindowSizer::GetBrowserWindowBoundsAndShowState( | 828 WindowSizer::GetBrowserWindowBoundsAndShowState( |
| 831 std::string(), | 829 std::string(), |
| 832 gfx::Rect(), | 830 gfx::Rect(), |
| 833 NULL, | 831 NULL, |
| 834 &bounds, | 832 &bounds, |
| 835 &show_state); | 833 &show_state); |
| 836 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); | 834 EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds)); |
| 837 } | 835 } |
| 838 { | 836 { |
| 839 aura::Window* second_root = | 837 ash::WmWindow* second_root = ash::WmShell::Get()->GetAllRootWindows()[1]; |
| 840 ash::Shell::GetAllRootWindows()[1]; | 838 ash::ScopedRootWindowForNewWindows tmp(second_root); |
| 841 ash::ScopedTargetRootWindow tmp(second_root); | |
| 842 gfx::Rect bounds; | 839 gfx::Rect bounds; |
| 843 ui::WindowShowState show_state; | 840 ui::WindowShowState show_state; |
| 844 WindowSizer::GetBrowserWindowBoundsAndShowState( | 841 WindowSizer::GetBrowserWindowBoundsAndShowState( |
| 845 std::string(), | 842 std::string(), |
| 846 gfx::Rect(), | 843 gfx::Rect(), |
| 847 NULL, | 844 NULL, |
| 848 &bounds, | 845 &bounds, |
| 849 &show_state); | 846 &show_state); |
| 850 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); | 847 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); |
| 851 } | 848 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 865 EXPECT_EQ( | 862 EXPECT_EQ( |
| 866 ui::SHOW_STATE_DEFAULT, | 863 ui::SHOW_STATE_DEFAULT, |
| 867 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 864 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 868 trusted_popup.get(), p1280x1024, p1600x1200)); | 865 trusted_popup.get(), p1280x1024, p1600x1200)); |
| 869 // 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. |
| 870 EXPECT_EQ( | 867 EXPECT_EQ( |
| 871 ui::SHOW_STATE_DEFAULT, | 868 ui::SHOW_STATE_DEFAULT, |
| 872 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 869 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 873 trusted_popup.get(), p1600x1200, p1600x1200)); | 870 trusted_popup.get(), p1600x1200, p1600x1200)); |
| 874 } | 871 } |
| OLD | NEW |