| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const std::string resolution = base::IntToString(width) + "x300"; | 173 const std::string resolution = base::IntToString(width) + "x300"; |
| 174 UpdateDisplay(resolution); | 174 UpdateDisplay(resolution); |
| 175 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 175 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
| 176 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 176 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| 177 | 177 |
| 178 test::TestShellDelegate* const delegate = | 178 test::TestShellDelegate* const delegate = |
| 179 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 179 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| 180 delegate->SetForceMaximizeOnFirstRun(true); | 180 delegate->SetForceMaximizeOnFirstRun(true); |
| 181 | 181 |
| 182 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 182 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 183 gfx::Screen::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, | 183 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); |
| 184 &bounds_in_out, &show_state_out); | |
| 185 | 184 |
| 186 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 185 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| 187 } | 186 } |
| 188 | 187 |
| 189 // For detail see description of FirstRunMaximizeWindowHighResloution. | 188 // For detail see description of FirstRunMaximizeWindowHighResloution. |
| 190 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { | 189 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { |
| 191 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; | 190 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; |
| 192 // Set resolution to 1266x300. | 191 // Set resolution to 1266x300. |
| 193 const std::string resolution = base::IntToString(width) + "x300"; | 192 const std::string resolution = base::IntToString(width) + "x300"; |
| 194 UpdateDisplay(resolution); | 193 UpdateDisplay(resolution); |
| 195 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 194 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
| 196 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 195 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| 197 | 196 |
| 198 test::TestShellDelegate* const delegate = | 197 test::TestShellDelegate* const delegate = |
| 199 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 198 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| 200 delegate->SetForceMaximizeOnFirstRun(true); | 199 delegate->SetForceMaximizeOnFirstRun(true); |
| 201 | 200 |
| 202 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 201 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| 203 gfx::Screen::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, | 202 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); |
| 204 &bounds_in_out, &show_state_out); | |
| 205 | 203 |
| 206 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 204 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| 207 } | 205 } |
| 208 | 206 |
| 209 TEST_F(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { | 207 TEST_F(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { |
| 210 if (!SupportsHostWindowResize()) | 208 if (!SupportsHostWindowResize()) |
| 211 return; | 209 return; |
| 212 // Set bigger than 1366 so that the new window is opened in normal state. | 210 // Set bigger than 1366 so that the new window is opened in normal state. |
| 213 UpdateDisplay("1400x800"); | 211 UpdateDisplay("1400x800"); |
| 214 | 212 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 235 widget1->SetFullscreen(false); | 233 widget1->SetFullscreen(false); |
| 236 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 234 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 237 | 235 |
| 238 // Closing 2nd widget triggers the rearrange logic but the 1st | 236 // Closing 2nd widget triggers the rearrange logic but the 1st |
| 239 // widget should stay in the current size. | 237 // widget should stay in the current size. |
| 240 widget2->CloseNow(); | 238 widget2->CloseNow(); |
| 241 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 239 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
| 242 } | 240 } |
| 243 | 241 |
| 244 } // namespace ash | 242 } // namespace ash |
| OLD | NEW |