Chromium Code Reviews| Index: ash/wm/window_positioner_unittest.cc |
| diff --git a/ash/wm/window_positioner_unittest.cc b/ash/wm/window_positioner_unittest.cc |
| index af320bc209fe4bb0d8cdf86aca9e6fa20b098555..8b1c26deb7f4cbe5a7465bc4363443fe1a95c555 100644 |
| --- a/ash/wm/window_positioner_unittest.cc |
| +++ b/ash/wm/window_positioner_unittest.cc |
| @@ -2,11 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ash/wm/window_positioner.h" |
|
bartfab (slow)
2015/04/01 14:22:41
This should still be the first include.
peletskyi
2015/04/01 18:55:45
Done.
|
| +#include <string> |
| #include "ash/shell.h" |
| #include "ash/shell/toplevel_window.h" |
| #include "ash/test/ash_test_base.h" |
| +#include "ash/test/test_shell_delegate.h" |
| #include "ash/wm/window_positioner.h" |
| #include "ash/wm/window_state.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| @@ -146,4 +147,49 @@ TEST_F(WindowPositionerTest, EnsureMinimumVisibility) { |
| widget->CloseNow(); |
| } |
| +// In general case on first run the browser window will be maximized only for |
| +// low resolution screens (width < 1366). In case of big screens the browser is |
| +// opened being not maximized. To enforce maximization for all screen |
| +// resolutions of full screen one can set "ForceMaximizeBrowserWindowOnFirstRun" |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: s/of full screen/,/
peletskyi
2015/04/01 18:55:45
Done.
|
| +// policy. In the following tests we check if the window will be opened in |
| +// maximized mode for low and high resolution when this policy is set. |
| +TEST_F(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) { |
| + const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100; |
| + // Set resolution to 1466x300. |
| + const std::string resolution = base::IntToString(width) + "x300"; |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: #include "base/strings/string_number_conversi
peletskyi
2015/04/01 18:55:45
Done.
|
| + UpdateDisplay(resolution); |
| + gfx::Rect bounds_in_out(0, 0, 320, 240); // random bounds |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: s/random bounds/Random bounds./ (we always fo
peletskyi
2015/04/01 18:55:45
Done.
|
| + ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| + |
| + test::TestShellDelegate* delegate = |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: const pointer.
peletskyi
2015/04/01 18:55:45
Method SetForceMaximizeOnFirstRun is not const.
bartfab (slow)
2015/04/02 08:44:28
Const pointer, not pointer to const.
peletskyi
2015/04/02 12:53:28
Done.
|
| + static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| + delegate->SetForceMaximizeOnFirstRun(true); |
| + |
| + WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| + Shell::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, |
| + &bounds_in_out, &show_state_out); |
| + |
| + EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| +} |
| + |
| +// For detail see description of FirstRunMaximizeWindowHighResloution. |
| +TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) { |
| + const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100; |
| + // Set resolution to 1266x300. |
| + const std::string resolution = base::IntToString(width) + "x300"; |
| + UpdateDisplay(resolution); |
| + gfx::Rect bounds_in_out(0, 0, 320, 240); // random bounds |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: s/random bounds/Random bounds./
peletskyi
2015/04/01 18:55:45
Done.
|
| + ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT; |
| + |
| + test::TestShellDelegate* delegate = |
|
bartfab (slow)
2015/04/01 14:22:41
Nit: const pointer.
peletskyi
2015/04/01 18:55:45
Method SetForceMaximizeOnFirstRun is not const.
bartfab (slow)
2015/04/02 08:44:28
Const pointer, not pointer to const.
peletskyi
2015/04/02 12:53:28
Done.
|
| + static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate()); |
| + delegate->SetForceMaximizeOnFirstRun(true); |
| + |
| + WindowPositioner::GetBoundsAndShowStateForNewWindow( |
| + Shell::GetScreen(), nullptr, false, ui::SHOW_STATE_DEFAULT, |
| + &bounds_in_out, &show_state_out); |
| + |
| + EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED); |
| +} |
| + |
| } // namespace |