| 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/scoped_target_root_window.h" | 5 #include "ash/scoped_target_root_window.h" |
| 6 #include "ash/screen_util.h" | 6 #include "ash/screen_util.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/test_shell_delegate.h" | 9 #include "ash/test/test_shell_delegate.h" |
| 10 #include "ash/wm/common/window_positioner.h" | 10 #include "ash/wm/common/window_positioner.h" |
| 11 #include "ash/wm/common/window_resizer.h" | 11 #include "ash/wm/common/window_resizer.h" |
| 12 #include "ash/wm/common/window_state.h" | 12 #include "ash/wm/common/window_state.h" |
| 13 #include "ash/wm/window_state_aura.h" | 13 #include "ash/wm/window_state_aura.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "chrome/browser/ui/ash/ash_util.h" | 17 #include "chrome/browser/ui/ash/ash_util.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" | 19 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/test_browser_window_aura.h" | 21 #include "chrome/test/base/test_browser_window_aura.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 22 #include "chrome/test/base/testing_profile.h" |
| 23 #include "content/public/test/render_view_test.h" | 23 #include "content/public/test/render_view_test.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
| 26 #include "ui/aura/env.h" | 26 #include "ui/aura/env.h" |
| 27 #include "ui/aura/test/test_windows.h" | 27 #include "ui/aura/test/test_windows.h" |
| 28 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
| 29 #include "ui/gfx/screen.h" | 29 #include "ui/display/screen.h" |
| 30 #include "ui/wm/public/activation_client.h" | 30 #include "ui/wm/public/activation_client.h" |
| 31 | 31 |
| 32 typedef ash::test::AshTestBase WindowSizerAshTest; | 32 typedef ash::test::AshTestBase WindowSizerAshTest; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 std::unique_ptr<Browser> CreateTestBrowser(aura::Window* window, | 36 std::unique_ptr<Browser> CreateTestBrowser(aura::Window* window, |
| 37 const gfx::Rect& bounds, | 37 const gfx::Rect& bounds, |
| 38 Browser::CreateParams* params) { | 38 Browser::CreateParams* params) { |
| 39 if (!bounds.IsEmpty()) | 39 if (!bounds.IsEmpty()) |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay
s | 576 #define MAYBE_PlaceNewWindowsOnMultipleDisplays PlaceNewWindowsOnMultipleDisplay
s |
| 577 #else | 577 #else |
| 578 // No multiple displays on windows ash. | 578 // No multiple displays on windows ash. |
| 579 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip
leDisplays | 579 #define MAYBE_PlaceNewWindowsOnMultipleDisplays DISABLED_PlaceNewWindowsOnMultip
leDisplays |
| 580 #endif | 580 #endif |
| 581 | 581 |
| 582 // Test the placement of newly created windows on multiple dislays. | 582 // Test the placement of newly created windows on multiple dislays. |
| 583 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { | 583 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { |
| 584 UpdateDisplay("1600x1200,1600x1200"); | 584 UpdateDisplay("1600x1200,1600x1200"); |
| 585 gfx::Rect primary_bounds = | 585 gfx::Rect primary_bounds = |
| 586 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 586 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 587 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); | 587 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); |
| 588 | 588 |
| 589 ash::Shell::GetInstance()->set_target_root_window( | 589 ash::Shell::GetInstance()->set_target_root_window( |
| 590 ash::Shell::GetPrimaryRootWindow()); | 590 ash::Shell::GetPrimaryRootWindow()); |
| 591 | 591 |
| 592 std::unique_ptr<TestingProfile> profile(new TestingProfile()); | 592 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 593 | 593 |
| 594 // Create browser windows that are used as reference. | 594 // Create browser windows that are used as reference. |
| 595 Browser::CreateParams params(profile.get()); | 595 Browser::CreateParams params(profile.get()); |
| 596 std::unique_ptr<Browser> browser(CreateTestBrowser( | 596 std::unique_ptr<Browser> browser(CreateTestBrowser( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 626 &window_bounds); | 626 &window_bounds); |
| 627 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 627 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 628 // moved to ash and changed to include the result from | 628 // moved to ash and changed to include the result from |
| 629 // RearrangeVisibleWindowOnShow. | 629 // RearrangeVisibleWindowOnShow. |
| 630 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); | 630 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
| 631 } | 631 } |
| 632 | 632 |
| 633 // Move the window to the right side of the secondary display and create a new | 633 // Move the window to the right side of the secondary display and create a new |
| 634 // window. It should be opened then on the secondary display. | 634 // window. It should be opened then on the secondary display. |
| 635 { | 635 { |
| 636 gfx::Display second_display = | 636 display::Display second_display = |
| 637 gfx::Screen::GetScreen()->GetDisplayNearestPoint( | 637 display::Screen::GetScreen()->GetDisplayNearestPoint( |
| 638 gfx::Point(1600 + 100, 10)); | 638 gfx::Point(1600 + 100, 10)); |
| 639 browser_window->GetNativeWindow()->SetBoundsInScreen( | 639 browser_window->GetNativeWindow()->SetBoundsInScreen( |
| 640 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), | 640 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
| 641 second_display); | 641 second_display); |
| 642 aura::client::GetActivationClient(native_window->GetRootWindow()) | 642 aura::client::GetActivationClient(native_window->GetRootWindow()) |
| 643 ->ActivateWindow(native_window); | 643 ->ActivateWindow(native_window); |
| 644 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 644 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
| 645 ash::Shell::GetTargetRootWindow()); | 645 ash::Shell::GetTargetRootWindow()); |
| 646 gfx::Rect window_bounds; | 646 gfx::Rect window_bounds; |
| 647 ui::WindowShowState out_show_state = ui::SHOW_STATE_DEFAULT; | 647 ui::WindowShowState out_show_state = ui::SHOW_STATE_DEFAULT; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 } | 815 } |
| 816 | 816 |
| 817 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { | 817 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { |
| 818 // Create a browser to pass into the GetWindowBounds function. | 818 // Create a browser to pass into the GetWindowBounds function. |
| 819 std::unique_ptr<TestingProfile> profile(new TestingProfile()); | 819 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 820 Browser::CreateParams native_params(profile.get()); | 820 Browser::CreateParams native_params(profile.get()); |
| 821 std::unique_ptr<Browser> browser( | 821 std::unique_ptr<Browser> browser( |
| 822 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 822 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 823 | 823 |
| 824 gfx::Rect display_bounds = | 824 gfx::Rect display_bounds = |
| 825 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 825 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 826 gfx::Rect specified_bounds = display_bounds; | 826 gfx::Rect specified_bounds = display_bounds; |
| 827 | 827 |
| 828 // Make a window bigger than the display work area. | 828 // Make a window bigger than the display work area. |
| 829 specified_bounds.Inset(-20, -20); | 829 specified_bounds.Inset(-20, -20); |
| 830 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; | 830 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; |
| 831 gfx::Rect bounds; | 831 gfx::Rect bounds; |
| 832 WindowSizer::GetBrowserWindowBoundsAndShowState( | 832 WindowSizer::GetBrowserWindowBoundsAndShowState( |
| 833 std::string(), specified_bounds, browser.get(), &bounds, &show_state); | 833 std::string(), specified_bounds, browser.get(), &bounds, &show_state); |
| 834 // The window should start maximized with its restore bounds shrunken. | 834 // The window should start maximized with its restore bounds shrunken. |
| 835 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, show_state); | 835 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, show_state); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 EXPECT_EQ( | 898 EXPECT_EQ( |
| 899 ui::SHOW_STATE_DEFAULT, | 899 ui::SHOW_STATE_DEFAULT, |
| 900 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 900 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 901 trusted_popup.get(), p1280x1024, p1600x1200)); | 901 trusted_popup.get(), p1280x1024, p1600x1200)); |
| 902 // A popup that is sized to occupy the whole work area has default state. | 902 // A popup that is sized to occupy the whole work area has default state. |
| 903 EXPECT_EQ( | 903 EXPECT_EQ( |
| 904 ui::SHOW_STATE_DEFAULT, | 904 ui::SHOW_STATE_DEFAULT, |
| 905 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 905 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 906 trusted_popup.get(), p1600x1200, p1600x1200)); | 906 trusted_popup.get(), p1600x1200, p1600x1200)); |
| 907 } | 907 } |
| OLD | NEW |