Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2827)

Unified Diff: ash/wm/window_positioner_unittest.cc

Issue 964503002: Implemented ForceMaximizeBrowserWindowOnFirstRun policy, added unit test and browser test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed description Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bca0bbfd1430a3b7f1d256059f9c068ea8529a5a 100644
--- a/ash/wm/window_positioner_unittest.cc
+++ b/ash/wm/window_positioner_unittest.cc
@@ -7,6 +7,7 @@
#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,58 @@ TEST_F(WindowPositionerTest, EnsureMinimumVisibility) {
widget->CloseNow();
}
+TEST_F(WindowPositionerTest, FirstRunMaximizeWindow) {
bartfab (slow) 2015/03/12 11:54:44 Nit: The test names do not make it clear what comb
peletskyi 2015/03/18 13:28:10 Done.
+ UpdateDisplay("1900x720");
+ gfx::Rect bounds_in_out(0, 0, 320, 240);
+ ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
+
+ test::TestShellDelegate* d =
bartfab (slow) 2015/03/12 11:54:44 Nit: Avoid abbreviations like |d|. Better use |del
peletskyi 2015/03/18 13:28:09 Done.
+ static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
+ d->SetFirstTimeMaximized(true);
+
+ ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:10 Done.
+ Shell::GetScreen(), NULL, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out,
bartfab (slow) 2015/03/12 11:54:44 Nit: s/NULL/nullptr/
peletskyi 2015/03/18 13:28:10 Done.
+ &show_state_out);
+
+ EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
+}
+
+TEST_F(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) {
+ // Set width of the screen wider than limit.
bartfab (slow) 2015/03/12 11:54:44 Nit: What limit?
peletskyi 2015/03/18 13:28:10 Done.
+ const int kWidth = ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100;
bartfab (slow) 2015/03/12 11:54:44 Nit 1: This is not really a constant if it is calc
peletskyi 2015/03/18 13:28:09 Done.
+ const std::string kResolution = std::to_string(kWidth) + "x300"; //"1466x300"
bartfab (slow) 2015/03/12 11:54:44 1: Nit: s/kResolution/resolution/ for the same rea
peletskyi 2015/03/18 13:28:10 Done.
+ UpdateDisplay(kResolution);
+ gfx::Rect bounds_in_out(0, 0, 320, 240); // random bounds
bartfab (slow) 2015/03/12 11:54:44 Nit: The bounds are "random" in all the tests. Why
+ ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
+
+ test::TestShellDelegate* d =
bartfab (slow) 2015/03/12 11:54:44 As above: s/d/delegate/
peletskyi 2015/03/18 13:28:09 Done.
+ static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
+ d->SetFirstTimeMaximized(true);
+
+ ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:10 Done.
+ Shell::GetScreen(), NULL, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out,
bartfab (slow) 2015/03/12 11:54:44 Nit: s/NULL/nullptr/
peletskyi 2015/03/18 13:28:10 Done.
+ &show_state_out);
+
+ EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
+}
+
+TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) {
+ // Set width of the screen narrower than limit.
bartfab (slow) 2015/03/12 11:54:44 Nit: What limit?
peletskyi 2015/03/18 13:28:10 Done.
+ const int kWidth = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100;
bartfab (slow) 2015/03/12 11:54:44 Nit: As above: s/kWidth/width/
peletskyi 2015/03/18 13:28:09 Done.
+ const std::string kResolution = std::to_string(kWidth) + "x300"; //"1266x300"
bartfab (slow) 2015/03/12 11:54:44 1: Nit: s/kResolution/resolution/ 3: std::to_strin
peletskyi 2015/03/18 13:28:10 Done.
+ UpdateDisplay(kResolution);
+ gfx::Rect bounds_in_out(0, 0, 320, 240); // random bounds
bartfab (slow) 2015/03/12 11:54:44 Nit: As above, I think you can drop this comment.
+ ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
+
+ test::TestShellDelegate* d =
bartfab (slow) 2015/03/12 11:54:44 As above: s/d/delegate/
peletskyi 2015/03/18 13:28:10 Done.
+ static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
+ d->SetFirstTimeMaximized(true);
+
+ ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:09 Done.
+ Shell::GetScreen(), NULL, false, ui::SHOW_STATE_DEFAULT, &bounds_in_out,
bartfab (slow) 2015/03/12 11:54:44 Nit: s/NULL/nullptr/
peletskyi 2015/03/18 13:28:10 Done.
+ &show_state_out);
+
+ EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
+}
+
bartfab (slow) 2015/03/12 11:54:44 You do not seem to have any test that verifies a s
peletskyi 2015/03/18 13:28:10 Added to browser tests.
} // namespace

Powered by Google App Engine
This is Rietveld 408576698