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/wm/window_positioner.h" | 10 #include "ash/common/wm/window_positioner.h" |
11 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
| 12 #include "ash/common/wm_shell.h" |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/shell/toplevel_window.h" | 14 #include "ash/shell/toplevel_window.h" |
14 #include "ash/test/ash_md_test_base.h" | 15 #include "ash/test/ash_md_test_base.h" |
15 #include "ash/test/test_shell_delegate.h" | 16 #include "ash/test/test_shell_delegate.h" |
16 #include "ash/wm/window_state_aura.h" | 17 #include "ash/wm/window_state_aura.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
19 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
20 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
21 #include "ui/views/widget/widget_delegate.h" | 22 #include "ui/views/widget/widget_delegate.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // maximized mode for low and high resolution when this policy is set. | 168 // maximized mode for low and high resolution when this policy is set. |
168 TEST_P(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) { | 169 TEST_P(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) { |
169 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100; | 170 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100; |
170 // Set resolution to 1466x300. | 171 // Set resolution to 1466x300. |
171 const std::string resolution = base::IntToString(width) + "x300"; | 172 const std::string resolution = base::IntToString(width) + "x300"; |
172 UpdateDisplay(resolution); | 173 UpdateDisplay(resolution); |
173 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 174 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
174 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 175 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
175 | 176 |
176 test::TestShellDelegate* const delegate = | 177 test::TestShellDelegate* const delegate = |
177 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 178 static_cast<test::TestShellDelegate*>(WmShell::Get()->delegate()); |
178 delegate->SetForceMaximizeOnFirstRun(true); | 179 delegate->SetForceMaximizeOnFirstRun(true); |
179 | 180 |
180 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 181 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
181 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); | 182 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); |
182 | 183 |
183 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 184 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
184 } | 185 } |
185 | 186 |
186 // For detail see description of FirstRunMaximizeWindowHighResloution. | 187 // For detail see description of FirstRunMaximizeWindowHighResloution. |
187 TEST_P(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { | 188 TEST_P(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { |
188 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; | 189 const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; |
189 // Set resolution to 1266x300. | 190 // Set resolution to 1266x300. |
190 const std::string resolution = base::IntToString(width) + "x300"; | 191 const std::string resolution = base::IntToString(width) + "x300"; |
191 UpdateDisplay(resolution); | 192 UpdateDisplay(resolution); |
192 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. | 193 gfx::Rect bounds_in_out(0, 0, 320, 240); // Random bounds. |
193 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; | 194 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
194 | 195 |
195 test::TestShellDelegate* const delegate = | 196 test::TestShellDelegate* const delegate = |
196 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); | 197 static_cast<test::TestShellDelegate*>(WmShell::Get()->delegate()); |
197 delegate->SetForceMaximizeOnFirstRun(true); | 198 delegate->SetForceMaximizeOnFirstRun(true); |
198 | 199 |
199 WindowPositioner::GetBoundsAndShowStateForNewWindow( | 200 WindowPositioner::GetBoundsAndShowStateForNewWindow( |
200 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); | 201 nullptr, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out, &show_state_out); |
201 | 202 |
202 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); | 203 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
203 } | 204 } |
204 | 205 |
205 TEST_P(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { | 206 TEST_P(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) { |
206 if (!SupportsHostWindowResize()) | 207 if (!SupportsHostWindowResize()) |
(...skipping 24 matching lines...) Expand all Loading... |
231 widget1->SetFullscreen(false); | 232 widget1->SetFullscreen(false); |
232 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 233 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
233 | 234 |
234 // Closing 2nd widget triggers the rearrange logic but the 1st | 235 // Closing 2nd widget triggers the rearrange logic but the 1st |
235 // widget should stay in the current size. | 236 // widget should stay in the current size. |
236 widget2->CloseNow(); | 237 widget2->CloseNow(); |
237 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); | 238 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); |
238 } | 239 } |
239 | 240 |
240 } // namespace ash | 241 } // namespace ash |
OLD | NEW |