| 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/wm/window_positioner.h" | 5 #include "ash/wm/window_positioner.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell/toplevel_window.h" | 10 #include "ash/shell/toplevel_window.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 params.can_maximize = true; | 53 params.can_maximize = true; |
| 54 views::Widget* widget = | 54 views::Widget* widget = |
| 55 shell::ToplevelWindow::CreateToplevelWindow(params); | 55 shell::ToplevelWindow::CreateToplevelWindow(params); |
| 56 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); | 56 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); |
| 57 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
| 58 EXPECT_TRUE(widget->IsMaximized()); | 58 EXPECT_TRUE(widget->IsMaximized()); |
| 59 #else | 59 #else |
| 60 // The window should be in the 2nd display with the default size. | 60 // The window should be in the 2nd display with the default size. |
| 61 EXPECT_EQ("300x300", bounds.size().ToString()); | 61 EXPECT_EQ("300x300", bounds.size().ToString()); |
| 62 #endif | 62 #endif |
| 63 EXPECT_TRUE(Shell::GetScreen()->GetDisplayNearestWindow( | 63 EXPECT_TRUE(gfx::Screen::GetScreen() |
| 64 second_root_window).bounds().Contains(bounds)); | 64 ->GetDisplayNearestWindow(second_root_window) |
| 65 .bounds() |
| 66 .Contains(bounds)); |
| 65 } | 67 } |
| 66 | 68 |
| 67 // Tests that second window inherits first window's maximized state as well as | 69 // Tests that second window inherits first window's maximized state as well as |
| 68 // its restore bounds. | 70 // its restore bounds. |
| 69 TEST_F(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) { | 71 TEST_F(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) { |
| 70 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 71 ash::WindowPositioner::SetMaximizeFirstWindow(true); | 73 ash::WindowPositioner::SetMaximizeFirstWindow(true); |
| 72 #endif | 74 #endif |
| 73 UpdateDisplay("1400x900"); | 75 UpdateDisplay("1400x900"); |
| 74 shell::ToplevelWindow::CreateParams params; | 76 shell::ToplevelWindow::CreateParams params; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 const std::string resolution = base::IntToString(width) + "x300"; | 164 const std::string resolution = base::IntToString(width) + "x300"; |
| 163 UpdateDisplay(resolution); | 165 UpdateDisplay(resolution); |
| 164 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 166 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
| 165 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 167 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| 166 | 168 |
| 167 test::TestShellDelegate* const delegate = | 169 test::TestShellDelegate* const delegate = |
| 168 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 170 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| 169 delegate->SetForceMaximizeOnFirstRun(true); | 171 delegate->SetForceMaximizeOnFirstRun(true); |
| 170 | 172 |
| 171 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 173 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 172 Shell::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, | 174 gfx::Screen::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, |
| 173 &bounds_in_out, &show_state_out); | 175 &bounds_in_out, &show_state_out); |
| 174 | 176 |
| 175 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 177 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| 176 } | 178 } |
| 177 | 179 |
| 178 // For detail see description of FirstRunMaximizeWindowHighResloution. | 180 // For detail see description of FirstRunMaximizeWindowHighResloution. |
| 179 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { | 181 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { |
| 180 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; | 182 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; |
| 181 // Set resolution to 1266x300. | 183 // Set resolution to 1266x300. |
| 182 const std::string resolution = base::IntToString(width) + "x300"; | 184 const std::string resolution = base::IntToString(width) + "x300"; |
| 183 UpdateDisplay(resolution); | 185 UpdateDisplay(resolution); |
| 184 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 186 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
| 185 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 187 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| 186 | 188 |
| 187 test::TestShellDelegate* const delegate = | 189 test::TestShellDelegate* const delegate = |
| 188 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 190 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| 189 delegate->SetForceMaximizeOnFirstRun(true); | 191 delegate->SetForceMaximizeOnFirstRun(true); |
| 190 | 192 |
| 191 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 193 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 192 Shell::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, | 194 gfx::Screen::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, |
| 193 &bounds_in_out, &show_state_out); | 195 &bounds_in_out, &show_state_out); |
| 194 | 196 |
| 195 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 197 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| 196 } | 198 } |
| 197 | 199 |
| 198 TEST_F(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { | 200 TEST_F(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { |
| 199 if (!SupportsHostWindowResize()) | 201 if (!SupportsHostWindowResize()) |
| 200 return; | 202 return; |
| 201 // Set bigger than 1366 so that the new window is opened in normal state. | 203 // Set bigger than 1366 so that the new window is opened in normal state. |
| 202 UpdateDisplay("1400x800"); | 204 UpdateDisplay("1400x800"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 224 widget1->SetFullscreen(false); | 226 widget1->SetFullscreen(false); |
| 225 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 227 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 226 | 228 |
| 227 // Closing 2nd widget triggers the rearrange logic but the 1st | 229 // Closing 2nd widget triggers the rearrange logic but the 1st |
| 228 // widget should stay in the current size. | 230 // widget should stay in the current size. |
| 229 widget2->CloseNow(); | 231 widget2->CloseNow(); |
| 230 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 232 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 231 } | 233 } |
| 232 | 234 |
| 233 } // namespace ash | 235 } // namespace ash |
| OLD | NEW |