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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell/toplevel_window.h" 8 #include "ash/shell/toplevel_window.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/test_shell_delegate.h"
10 #include "ash/wm/window_positioner.h" 11 #include "ash/wm/window_positioner.h"
11 #include "ash/wm/window_state.h" 12 #include "ash/wm/window_state.h"
12 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/gfx/screen.h" 14 #include "ui/gfx/screen.h"
14 #include "ui/views/widget/widget.h" 15 #include "ui/views/widget/widget.h"
15 #include "ui/views/widget/widget_delegate.h" 16 #include "ui/views/widget/widget_delegate.h"
16 17
17 namespace ash { 18 namespace ash {
18 19
19 typedef test::AshTestBase WindowPositionerTest; 20 typedef test::AshTestBase WindowPositionerTest;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 params.context = Shell::GetPrimaryRootWindow(); 140 params.context = Shell::GetPrimaryRootWindow();
140 widget->Init(params); 141 widget->Init(params);
141 widget->SetBounds(gfx::Rect(450,10, 100, 100)); 142 widget->SetBounds(gfx::Rect(450,10, 100, 100));
142 wm::GetWindowState(widget->GetNativeView())->set_minimum_visibility(true); 143 wm::GetWindowState(widget->GetNativeView())->set_minimum_visibility(true);
143 widget->Show(); 144 widget->Show();
144 // Make sure the bounds is adjusted to be inside the work area. 145 // Make sure the bounds is adjusted to be inside the work area.
145 EXPECT_EQ("390,10 100x100", widget->GetWindowBoundsInScreen().ToString()); 146 EXPECT_EQ("390,10 100x100", widget->GetWindowBoundsInScreen().ToString());
146 widget->CloseNow(); 147 widget->CloseNow();
147 } 148 }
148 149
150 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.
151 UpdateDisplay("1900x720");
152 gfx::Rect bounds_in_out(0, 0, 320, 240);
153 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
154
155 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.
156 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
157 d->SetFirstTimeMaximized(true);
158
159 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:10 Done.
160 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.
161 &show_state_out);
162
163 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
164 }
165
166 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) {
167 // 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.
168 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.
169 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.
170 UpdateDisplay(kResolution);
171 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
172 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
173
174 test::TestShellDelegate* d =
bartfab (slow) 2015/03/12 11:54:44 As above: s/d/delegate/
peletskyi 2015/03/18 13:28:09 Done.
175 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
176 d->SetFirstTimeMaximized(true);
177
178 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:10 Done.
179 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.
180 &show_state_out);
181
182 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
183 }
184
185 TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) {
186 // 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.
187 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.
188 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.
189 UpdateDisplay(kResolution);
190 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.
191 ui::WindowShowState show_state_out = ui::SHOW_STATE_DEFAULT;
192
193 test::TestShellDelegate* d =
bartfab (slow) 2015/03/12 11:54:44 As above: s/d/delegate/
peletskyi 2015/03/18 13:28:10 Done.
194 static_cast<test::TestShellDelegate*>(Shell::GetInstance()->delegate());
195 d->SetFirstTimeMaximized(true);
196
197 ash::WindowPositioner::GetBoundsAndShowStateForNewWindow(
bartfab (slow) 2015/03/12 11:54:44 Nit: s/ash:://
peletskyi 2015/03/18 13:28:09 Done.
198 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.
199 &show_state_out);
200
201 EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
202 }
203
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.
149 } // namespace 204 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698