| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/window_positioner.h" | 5 #include "ash/common/wm/window_positioner.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/scoped_root_window_for_new_windows.h" | 10 #include "ash/common/scoped_root_window_for_new_windows.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using WindowPositionerTest = test::AshMDTestBase; | 27 using WindowPositionerTest = test::AshMDTestBase; |
| 28 | 28 |
| 29 INSTANTIATE_TEST_CASE_P( | 29 INSTANTIATE_TEST_CASE_P( |
| 30 /* prefix intentionally left blank due to only one parameterization */, | 30 /* prefix intentionally left blank due to only one parameterization */, |
| 31 WindowPositionerTest, | 31 WindowPositionerTest, |
| 32 testing::Values(MaterialDesignController::NON_MATERIAL, | 32 testing::Values(MaterialDesignController::NON_MATERIAL, |
| 33 MaterialDesignController::MATERIAL_NORMAL, | 33 MaterialDesignController::MATERIAL_NORMAL, |
| 34 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | 34 MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
| 35 | 35 |
| 36 TEST_P(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) { | 36 TEST_P(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) { |
| 37 if (!SupportsMultipleDisplays()) | |
| 38 return; | |
| 39 const int height_offset = GetMdMaximizedWindowHeightOffset(); | 37 const int height_offset = GetMdMaximizedWindowHeightOffset(); |
| 40 // Tests that for a screen that is narrower than kForceMaximizeWidthLimit | 38 // Tests that for a screen that is narrower than kForceMaximizeWidthLimit |
| 41 // a new window gets maximized. | 39 // a new window gets maximized. |
| 42 UpdateDisplay("400x400,500x500"); | 40 UpdateDisplay("400x400,500x500"); |
| 43 ScopedRootWindowForNewWindows root_for_new_windows( | 41 ScopedRootWindowForNewWindows root_for_new_windows( |
| 44 WmShell::Get()->GetAllRootWindows()[1]); | 42 WmShell::Get()->GetAllRootWindows()[1]); |
| 45 shell::ToplevelWindow::CreateParams params; | 43 shell::ToplevelWindow::CreateParams params; |
| 46 params.can_resize = true; | 44 params.can_resize = true; |
| 47 params.can_maximize = true; | 45 params.can_maximize = true; |
| 48 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); | 46 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); |
| 49 EXPECT_EQ(gfx::Rect(400, 0, 500, 453 + height_offset).ToString(), | 47 EXPECT_EQ(gfx::Rect(400, 0, 500, 453 + height_offset).ToString(), |
| 50 widget->GetWindowBoundsInScreen().ToString()); | 48 widget->GetWindowBoundsInScreen().ToString()); |
| 51 } | 49 } |
| 52 | 50 |
| 53 TEST_P(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) { | 51 TEST_P(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) { |
| 54 if (!SupportsMultipleDisplays()) | |
| 55 return; | |
| 56 | |
| 57 UpdateDisplay("400x400,1400x900"); | 52 UpdateDisplay("400x400,1400x900"); |
| 58 WmWindow* second_root_window = WmShell::Get()->GetAllRootWindows()[1]; | 53 WmWindow* second_root_window = WmShell::Get()->GetAllRootWindows()[1]; |
| 59 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window); | 54 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window); |
| 60 shell::ToplevelWindow::CreateParams params; | 55 shell::ToplevelWindow::CreateParams params; |
| 61 params.can_resize = true; | 56 params.can_resize = true; |
| 62 params.can_maximize = true; | 57 params.can_maximize = true; |
| 63 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); | 58 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); |
| 64 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); | 59 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); |
| 65 | 60 |
| 66 // The window should be in the 2nd display with the default size. | 61 // The window should be in the 2nd display with the default size. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 widget1->SetFullscreen(false); | 214 widget1->SetFullscreen(false); |
| 220 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 215 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 221 | 216 |
| 222 // Closing 2nd widget triggers the rearrange logic but the 1st | 217 // Closing 2nd widget triggers the rearrange logic but the 1st |
| 223 // widget should stay in the current size. | 218 // widget should stay in the current size. |
| 224 widget2->CloseNow(); | 219 widget2->CloseNow(); |
| 225 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 220 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 226 } | 221 } |
| 227 | 222 |
| 228 } // namespace ash | 223 } // namespace ash |
| OLD | NEW |