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

Side by Side Diff: ash/wm/workspace_controller_unittest.cc

Issue 2165693002: Fix tests in when MD is set to EXPERIMENTAL by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/workspace_controller.h" 5 #include "ash/wm/workspace_controller.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
11 #include "ash/common/system/status_area_widget.h" 11 #include "ash/common/system/status_area_widget.h"
12 #include "ash/common/wm/panels/panel_layout_manager.h" 12 #include "ash/common/wm/panels/panel_layout_manager.h"
13 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm/workspace/workspace_window_resizer.h" 14 #include "ash/common/wm/workspace/workspace_window_resizer.h"
15 #include "ash/root_window_controller.h" 15 #include "ash/root_window_controller.h"
16 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
17 #include "ash/shelf/shelf_layout_manager.h" 17 #include "ash/shelf/shelf_layout_manager.h"
18 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_md_test_base.h"
21 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
22 #include "ash/test/test_shelf_delegate.h" 22 #include "ash/test/test_shelf_delegate.h"
23 #include "ash/wm/window_state_aura.h" 23 #include "ash/wm/window_state_aura.h"
24 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
25 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
26 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
27 #include "ui/aura/test/test_window_delegate.h" 27 #include "ui/aura/test/test_window_delegate.h"
28 #include "ui/aura/test/test_windows.h" 28 #include "ui/aura/test/test_windows.h"
29 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
30 #include "ui/aura/window_event_dispatcher.h" 30 #include "ui/aura/window_event_dispatcher.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 LayerToWindowNameMap::iterator layer_i = window_names.find(layers[i]); 73 LayerToWindowNameMap::iterator layer_i = window_names.find(layers[i]);
74 if (layer_i != window_names.end()) { 74 if (layer_i != window_names.end()) {
75 if (!result.empty()) 75 if (!result.empty())
76 result += " "; 76 result += " ";
77 result += layer_i->second; 77 result += layer_i->second;
78 } 78 }
79 } 79 }
80 return result; 80 return result;
81 } 81 }
82 82
83 class WorkspaceControllerTest : public test::AshTestBase { 83 class WorkspaceControllerTest : public test::AshMDTestBase {
84 public: 84 public:
85 WorkspaceControllerTest() {} 85 WorkspaceControllerTest() {}
86 ~WorkspaceControllerTest() override {} 86 ~WorkspaceControllerTest() override {}
87 87
88 aura::Window* CreateTestWindowUnparented() { 88 aura::Window* CreateTestWindowUnparented() {
89 aura::Window* window = new aura::Window(NULL); 89 aura::Window* window = new aura::Window(NULL);
90 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 90 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
91 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 91 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
92 window->Init(ui::LAYER_TEXTURED); 92 window->Init(ui::LAYER_TEXTURED);
93 return window; 93 return window;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 bool GetWindowOverlapsShelf() { 152 bool GetWindowOverlapsShelf() {
153 return shelf_layout_manager()->window_overlaps_shelf(); 153 return shelf_layout_manager()->window_overlaps_shelf();
154 } 154 }
155 155
156 private: 156 private:
157 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest); 157 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTest);
158 }; 158 };
159 159
160 INSTANTIATE_TEST_CASE_P(
161 /* prefix intentionally left blank due to only one parameterization */,
162 WorkspaceControllerTest,
163 testing::Values(MaterialDesignController::NON_MATERIAL,
164 MaterialDesignController::MATERIAL_NORMAL,
165 MaterialDesignController::MATERIAL_EXPERIMENTAL));
166
160 // Assertions around adding a normal window. 167 // Assertions around adding a normal window.
161 TEST_F(WorkspaceControllerTest, AddNormalWindowWhenEmpty) { 168 TEST_P(WorkspaceControllerTest, AddNormalWindowWhenEmpty) {
162 std::unique_ptr<Window> w1(CreateTestWindow()); 169 std::unique_ptr<Window> w1(CreateTestWindow());
163 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 170 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
164 171
165 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 172 wm::WindowState* window_state = wm::GetWindowState(w1.get());
166 173
167 EXPECT_FALSE(window_state->HasRestoreBounds()); 174 EXPECT_FALSE(window_state->HasRestoreBounds());
168 175
169 w1->Show(); 176 w1->Show();
170 177
171 EXPECT_FALSE(window_state->HasRestoreBounds()); 178 EXPECT_FALSE(window_state->HasRestoreBounds());
172 179
173 ASSERT_TRUE(w1->layer() != NULL); 180 ASSERT_TRUE(w1->layer() != NULL);
174 EXPECT_TRUE(w1->layer()->visible()); 181 EXPECT_TRUE(w1->layer()->visible());
175 182
176 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); 183 EXPECT_EQ("0,0 250x251", w1->bounds().ToString());
177 184
178 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 185 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
179 } 186 }
180 187
181 // Assertions around maximizing/unmaximizing. 188 // Assertions around maximizing/unmaximizing.
182 TEST_F(WorkspaceControllerTest, SingleMaximizeWindow) { 189 TEST_P(WorkspaceControllerTest, SingleMaximizeWindow) {
183 std::unique_ptr<Window> w1(CreateTestWindow()); 190 std::unique_ptr<Window> w1(CreateTestWindow());
184 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 191 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
185 192
186 w1->Show(); 193 w1->Show();
187 wm::ActivateWindow(w1.get()); 194 wm::ActivateWindow(w1.get());
188 195
189 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); 196 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
190 197
191 ASSERT_TRUE(w1->layer() != NULL); 198 ASSERT_TRUE(w1->layer() != NULL);
192 EXPECT_TRUE(w1->layer()->visible()); 199 EXPECT_TRUE(w1->layer()->visible());
(...skipping 12 matching lines...) Expand all
205 w1->bounds().height()); 212 w1->bounds().height());
206 213
207 // Restore the window. 214 // Restore the window.
208 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 215 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
209 216
210 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 217 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
211 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); 218 EXPECT_EQ("0,0 250x251", w1->bounds().ToString());
212 } 219 }
213 220
214 // Assertions around two windows and toggling one to be fullscreen. 221 // Assertions around two windows and toggling one to be fullscreen.
215 TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) { 222 TEST_P(WorkspaceControllerTest, FullscreenWithNormalWindow) {
216 std::unique_ptr<Window> w1(CreateTestWindow()); 223 std::unique_ptr<Window> w1(CreateTestWindow());
217 std::unique_ptr<Window> w2(CreateTestWindow()); 224 std::unique_ptr<Window> w2(CreateTestWindow());
218 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 225 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
219 w1->Show(); 226 w1->Show();
220 227
221 ASSERT_TRUE(w1->layer() != NULL); 228 ASSERT_TRUE(w1->layer() != NULL);
222 EXPECT_TRUE(w1->layer()->visible()); 229 EXPECT_TRUE(w1->layer()->visible());
223 230
224 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); 231 w2->SetBounds(gfx::Rect(0, 0, 50, 51));
225 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 232 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
226 w2->Show(); 233 w2->Show();
227 wm::ActivateWindow(w2.get()); 234 wm::ActivateWindow(w2.get());
228 235
229 // Both windows should be in the same workspace. 236 // Both windows should be in the same workspace.
230 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 237 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
231 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]); 238 EXPECT_EQ(w2.get(), GetDesktop()->children()[1]);
232 239
233 gfx::Rect work_area(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get())); 240 gfx::Rect work_area(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()));
234 EXPECT_EQ(work_area.width(), w2->bounds().width()); 241 EXPECT_EQ(work_area.width(), w2->bounds().width());
235 EXPECT_EQ(work_area.height(), w2->bounds().height()); 242 EXPECT_EQ(work_area.height(), w2->bounds().height());
236 243
237 // Restore w2, which should then go back to one workspace. 244 // Restore w2, which should then go back to one workspace.
238 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 245 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
239 EXPECT_EQ(50, w2->bounds().width()); 246 EXPECT_EQ(50, w2->bounds().width());
240 EXPECT_EQ(51, w2->bounds().height()); 247 EXPECT_EQ(51, w2->bounds().height());
241 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); 248 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
242 } 249 }
243 250
244 // Makes sure requests to change the bounds of a normal window go through. 251 // Makes sure requests to change the bounds of a normal window go through.
245 TEST_F(WorkspaceControllerTest, ChangeBoundsOfNormalWindow) { 252 TEST_P(WorkspaceControllerTest, ChangeBoundsOfNormalWindow) {
246 std::unique_ptr<Window> w1(CreateTestWindow()); 253 std::unique_ptr<Window> w1(CreateTestWindow());
247 w1->Show(); 254 w1->Show();
248 255
249 // Setting the bounds should go through since the window is in the normal 256 // Setting the bounds should go through since the window is in the normal
250 // workspace. 257 // workspace.
251 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); 258 w1->SetBounds(gfx::Rect(0, 0, 200, 500));
252 EXPECT_EQ(200, w1->bounds().width()); 259 EXPECT_EQ(200, w1->bounds().width());
253 EXPECT_EQ(500, w1->bounds().height()); 260 EXPECT_EQ(500, w1->bounds().height());
254 } 261 }
255 262
256 // Verifies the bounds is not altered when showing and grid is enabled. 263 // Verifies the bounds is not altered when showing and grid is enabled.
257 TEST_F(WorkspaceControllerTest, SnapToGrid) { 264 TEST_P(WorkspaceControllerTest, SnapToGrid) {
258 std::unique_ptr<Window> w1(CreateTestWindowUnparented()); 265 std::unique_ptr<Window> w1(CreateTestWindowUnparented());
259 w1->SetBounds(gfx::Rect(1, 6, 25, 30)); 266 w1->SetBounds(gfx::Rect(1, 6, 25, 30));
260 ParentWindowInPrimaryRootWindow(w1.get()); 267 ParentWindowInPrimaryRootWindow(w1.get());
261 // We are not aligning this anymore this way. When the window gets shown 268 // We are not aligning this anymore this way. When the window gets shown
262 // the window is expected to be handled differently, but this cannot be 269 // the window is expected to be handled differently, but this cannot be
263 // tested with this test. So the result of this test should be that the 270 // tested with this test. So the result of this test should be that the
264 // bounds are exactly as passed in. 271 // bounds are exactly as passed in.
265 EXPECT_EQ("1,6 25x30", w1->bounds().ToString()); 272 EXPECT_EQ("1,6 25x30", w1->bounds().ToString());
266 } 273 }
267 274
268 // Assertions around a fullscreen window. 275 // Assertions around a fullscreen window.
269 TEST_F(WorkspaceControllerTest, SingleFullscreenWindow) { 276 TEST_P(WorkspaceControllerTest, SingleFullscreenWindow) {
270 std::unique_ptr<Window> w1(CreateTestWindow()); 277 std::unique_ptr<Window> w1(CreateTestWindow());
271 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); 278 w1->SetBounds(gfx::Rect(0, 0, 250, 251));
272 // Make the window fullscreen. 279 // Make the window fullscreen.
273 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 280 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
274 w1->Show(); 281 w1->Show();
275 wm::ActivateWindow(w1.get()); 282 wm::ActivateWindow(w1.get());
276 283
277 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 284 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
278 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); 285 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width());
279 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); 286 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height());
(...skipping 12 matching lines...) Expand all
292 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); 299 EXPECT_EQ(w1.get(), GetDesktop()->children()[0]);
293 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); 300 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width());
294 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); 301 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height());
295 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 302 wm::WindowState* window_state = wm::GetWindowState(w1.get());
296 303
297 ASSERT_TRUE(window_state->HasRestoreBounds()); 304 ASSERT_TRUE(window_state->HasRestoreBounds());
298 EXPECT_EQ("0,0 250x251", window_state->GetRestoreBoundsInScreen().ToString()); 305 EXPECT_EQ("0,0 250x251", window_state->GetRestoreBoundsInScreen().ToString());
299 } 306 }
300 307
301 // Assertions around minimizing a single window. 308 // Assertions around minimizing a single window.
302 TEST_F(WorkspaceControllerTest, MinimizeSingleWindow) { 309 TEST_P(WorkspaceControllerTest, MinimizeSingleWindow) {
303 std::unique_ptr<Window> w1(CreateTestWindow()); 310 std::unique_ptr<Window> w1(CreateTestWindow());
304 311
305 w1->Show(); 312 w1->Show();
306 313
307 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 314 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
308 EXPECT_FALSE(w1->layer()->IsDrawn()); 315 EXPECT_FALSE(w1->layer()->IsDrawn());
309 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity()); 316 EXPECT_TRUE(w1->layer()->GetTargetTransform().IsIdentity());
310 317
311 // Show the window. 318 // Show the window.
312 w1->Show(); 319 w1->Show();
313 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalStateType()); 320 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsNormalStateType());
314 EXPECT_TRUE(w1->layer()->IsDrawn()); 321 EXPECT_TRUE(w1->layer()->IsDrawn());
315 } 322 }
316 323
317 // Assertions around minimizing a fullscreen window. 324 // Assertions around minimizing a fullscreen window.
318 TEST_F(WorkspaceControllerTest, MinimizeFullscreenWindow) { 325 TEST_P(WorkspaceControllerTest, MinimizeFullscreenWindow) {
319 // Two windows, w1 normal, w2 fullscreen. 326 // Two windows, w1 normal, w2 fullscreen.
320 std::unique_ptr<Window> w1(CreateTestWindow()); 327 std::unique_ptr<Window> w1(CreateTestWindow());
321 std::unique_ptr<Window> w2(CreateTestWindow()); 328 std::unique_ptr<Window> w2(CreateTestWindow());
322 w1->Show(); 329 w1->Show();
323 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 330 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
324 w2->Show(); 331 w2->Show();
325 332
326 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); 333 wm::WindowState* w1_state = wm::GetWindowState(w1.get());
327 wm::WindowState* w2_state = wm::GetWindowState(w2.get()); 334 wm::WindowState* w2_state = wm::GetWindowState(w2.get());
328 335
(...skipping 26 matching lines...) Expand all
355 // Setting back to normal doesn't change the activation. 362 // Setting back to normal doesn't change the activation.
356 EXPECT_FALSE(w2_state->IsActive()); 363 EXPECT_FALSE(w2_state->IsActive());
357 EXPECT_TRUE(w1_state->IsActive()); 364 EXPECT_TRUE(w1_state->IsActive());
358 EXPECT_EQ(w2.get(), GetDesktop()->children()[0]); 365 EXPECT_EQ(w2.get(), GetDesktop()->children()[0]);
359 EXPECT_EQ(w1.get(), GetDesktop()->children()[1]); 366 EXPECT_EQ(w1.get(), GetDesktop()->children()[1]);
360 EXPECT_TRUE(w2->layer()->IsDrawn()); 367 EXPECT_TRUE(w2->layer()->IsDrawn());
361 } 368 }
362 369
363 // Verifies ShelfLayoutManager's visibility/auto-hide state is correctly 370 // Verifies ShelfLayoutManager's visibility/auto-hide state is correctly
364 // updated. 371 // updated.
365 TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { 372 TEST_P(WorkspaceControllerTest, ShelfStateUpdated) {
366 // Since ShelfLayoutManager queries for mouse location, move the mouse so 373 // Since ShelfLayoutManager queries for mouse location, move the mouse so
367 // it isn't over the shelf. 374 // it isn't over the shelf.
368 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 375 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
369 gfx::Point()); 376 gfx::Point());
370 generator.MoveMouseTo(0, 0); 377 generator.MoveMouseTo(0, 0);
371 378
372 std::unique_ptr<Window> w1(CreateTestWindow()); 379 std::unique_ptr<Window> w1(CreateTestWindow());
373 const gfx::Rect w1_bounds(0, 1, 101, 102); 380 const gfx::Rect w1_bounds(0, 1, 101, 102);
374 Shelf* shelf = Shelf::ForPrimaryDisplay(); 381 Shelf* shelf = Shelf::ForPrimaryDisplay();
375 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 382 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 439
433 // Minimize. 440 // Minimize.
434 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 441 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 442 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
436 443
437 // Since the restore from minimize will restore to the pre-minimize 444 // Since the restore from minimize will restore to the pre-minimize
438 // state (tested elsewhere), we abandon the current size and restore 445 // state (tested elsewhere), we abandon the current size and restore
439 // rect and set them to the window. 446 // rect and set them to the window.
440 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 447 wm::WindowState* window_state = wm::GetWindowState(w1.get());
441 448
449 // 3 pixels was reserved for auto hidden shelf in non-MD, so screen height is
450 // 600 - 3 = 597; no pixel was reserved for auto hidden shelf in MD, so screen
451 // height is 600.
tdanderson 2016/07/19 21:10:23 I would omit this comment entirely; the documentat
yiyix 2016/07/20 06:03:07 Done.
442 gfx::Rect restore = window_state->GetRestoreBoundsInScreen(); 452 gfx::Rect restore = window_state->GetRestoreBoundsInScreen();
443 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); 453 EXPECT_EQ(
454 gfx::Rect(0, 0, 800, 597 + GetMdAutoHiddenShelfHeightOffset()).ToString(),
455 w1->bounds().ToString());
444 EXPECT_EQ("0,1 101x102", restore.ToString()); 456 EXPECT_EQ("0,1 101x102", restore.ToString());
445 window_state->ClearRestoreBounds(); 457 window_state->ClearRestoreBounds();
446 w1->SetBounds(restore); 458 w1->SetBounds(restore);
447 459
448 // Restore. 460 // Restore.
449 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 461 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
450 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 462 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
451 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 463 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
452 464
453 // Create another window, maximized. 465 // Create another window, maximized.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 wm::ActivateWindow(w1.get()); 506 wm::ActivateWindow(w1.get());
495 EXPECT_FALSE(GetWindowOverlapsShelf()); 507 EXPECT_FALSE(GetWindowOverlapsShelf());
496 508
497 // Restore w2. 509 // Restore w2.
498 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 510 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
499 EXPECT_TRUE(GetWindowOverlapsShelf()); 511 EXPECT_TRUE(GetWindowOverlapsShelf());
500 } 512 }
501 513
502 // Verifies going from maximized to minimized sets the right state for painting 514 // Verifies going from maximized to minimized sets the right state for painting
503 // the background of the launcher. 515 // the background of the launcher.
504 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { 516 TEST_P(WorkspaceControllerTest, MinimizeResetsVisibility) {
505 std::unique_ptr<Window> w1(CreateTestWindow()); 517 std::unique_ptr<Window> w1(CreateTestWindow());
506 w1->Show(); 518 w1->Show();
507 wm::ActivateWindow(w1.get()); 519 wm::ActivateWindow(w1.get());
508 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 520 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
509 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); 521 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType());
510 522
511 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 523 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
512 Shelf* shelf = Shelf::ForPrimaryDisplay(); 524 Shelf* shelf = Shelf::ForPrimaryDisplay();
513 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 525 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
514 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); 526 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType());
515 } 527 }
516 528
517 // Verifies window visibility during various workspace changes. 529 // Verifies window visibility during various workspace changes.
518 TEST_F(WorkspaceControllerTest, VisibilityTests) { 530 TEST_P(WorkspaceControllerTest, VisibilityTests) {
519 std::unique_ptr<Window> w1(CreateTestWindow()); 531 std::unique_ptr<Window> w1(CreateTestWindow());
520 w1->Show(); 532 w1->Show();
521 EXPECT_TRUE(w1->IsVisible()); 533 EXPECT_TRUE(w1->IsVisible());
522 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); 534 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity());
523 535
524 // Create another window, activate it and make it fullscreen. 536 // Create another window, activate it and make it fullscreen.
525 std::unique_ptr<Window> w2(CreateTestWindow()); 537 std::unique_ptr<Window> w2(CreateTestWindow());
526 w2->Show(); 538 w2->Show();
527 wm::ActivateWindow(w2.get()); 539 wm::ActivateWindow(w2.get());
528 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 540 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); 577 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity());
566 EXPECT_TRUE(w1->IsVisible()); 578 EXPECT_TRUE(w1->IsVisible());
567 579
568 // Close |w2|. 580 // Close |w2|.
569 w2.reset(); 581 w2.reset();
570 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); 582 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity());
571 EXPECT_TRUE(w1->IsVisible()); 583 EXPECT_TRUE(w1->IsVisible());
572 } 584 }
573 585
574 // Verifies windows that are offscreen don't move when switching workspaces. 586 // Verifies windows that are offscreen don't move when switching workspaces.
575 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { 587 TEST_P(WorkspaceControllerTest, DontMoveOnSwitch) {
576 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 588 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
577 gfx::Point()); 589 gfx::Point());
578 generator.MoveMouseTo(0, 0); 590 generator.MoveMouseTo(0, 0);
579 591
580 std::unique_ptr<Window> w1(CreateTestWindow()); 592 std::unique_ptr<Window> w1(CreateTestWindow());
581 const gfx::Rect touches_shelf_bounds( 593 const gfx::Rect touches_shelf_bounds(
582 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); 594 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102);
583 // Move |w1| to overlap the shelf. 595 // Move |w1| to overlap the shelf.
584 w1->SetBounds(touches_shelf_bounds); 596 w1->SetBounds(touches_shelf_bounds);
585 w1->Show(); 597 w1->Show();
586 wm::ActivateWindow(w1.get()); 598 wm::ActivateWindow(w1.get());
587 599
588 // Create another window and maximize it. 600 // Create another window and maximize it.
589 std::unique_ptr<Window> w2(CreateTestWindow()); 601 std::unique_ptr<Window> w2(CreateTestWindow());
590 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 602 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
591 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 603 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
592 w2->Show(); 604 w2->Show();
593 wm::ActivateWindow(w2.get()); 605 wm::ActivateWindow(w2.get());
594 606
595 // Switch to w1. 607 // Switch to w1.
596 wm::ActivateWindow(w1.get()); 608 wm::ActivateWindow(w1.get());
597 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); 609 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString());
598 } 610 }
599 611
600 // Verifies that windows that are completely offscreen move when switching 612 // Verifies that windows that are completely offscreen move when switching
601 // workspaces. 613 // workspaces.
602 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { 614 TEST_P(WorkspaceControllerTest, MoveOnSwitch) {
603 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 615 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
604 gfx::Point()); 616 gfx::Point());
605 generator.MoveMouseTo(0, 0); 617 generator.MoveMouseTo(0, 0);
606 618
607 std::unique_ptr<Window> w1(CreateTestWindow()); 619 std::unique_ptr<Window> w1(CreateTestWindow());
608 const gfx::Rect w1_bounds(0, shelf_layout_manager()->GetIdealBounds().y(), 620 const gfx::Rect w1_bounds(0, shelf_layout_manager()->GetIdealBounds().y(),
609 100, 200); 621 100, 200);
610 // Move |w1| so that the top edge is the same as the top edge of the shelf. 622 // Move |w1| so that the top edge is the same as the top edge of the shelf.
611 w1->SetBounds(w1_bounds); 623 w1->SetBounds(w1_bounds);
612 w1->Show(); 624 w1->Show();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 DISALLOW_COPY_AND_ASSIGN(DontCrashOnChangeAndActivateDelegate); 669 DISALLOW_COPY_AND_ASSIGN(DontCrashOnChangeAndActivateDelegate);
658 }; 670 };
659 671
660 } // namespace 672 } // namespace
661 673
662 // Exercises possible crash in W2. Here's the sequence: 674 // Exercises possible crash in W2. Here's the sequence:
663 // . minimize a maximized window. 675 // . minimize a maximized window.
664 // . remove the window (which happens when switching displays). 676 // . remove the window (which happens when switching displays).
665 // . add the window back. 677 // . add the window back.
666 // . show the window and during the bounds change activate it. 678 // . show the window and during the bounds change activate it.
667 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { 679 TEST_P(WorkspaceControllerTest, DontCrashOnChangeAndActivate) {
668 // Force the shelf 680 // Force the shelf
669 Shelf* shelf = Shelf::ForPrimaryDisplay(); 681 Shelf* shelf = Shelf::ForPrimaryDisplay();
670 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 682 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
671 683
672 DontCrashOnChangeAndActivateDelegate delegate; 684 DontCrashOnChangeAndActivateDelegate delegate;
673 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( 685 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate(
674 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); 686 &delegate, 1000, gfx::Rect(10, 11, 250, 251)));
675 687
676 w1->Show(); 688 w1->Show();
677 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); 689 wm::WindowState* w1_state = wm::GetWindowState(w1.get());
678 w1_state->Activate(); 690 w1_state->Activate();
679 w1_state->Maximize(); 691 w1_state->Maximize();
680 w1_state->Minimize(); 692 w1_state->Minimize();
681 693
682 w1->parent()->RemoveChild(w1.get()); 694 w1->parent()->RemoveChild(w1.get());
683 695
684 // Do this so that when we Show() the window a resize occurs and we make the 696 // Do this so that when we Show() the window a resize occurs and we make the
685 // window active. 697 // window active.
686 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 698 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
687 699
688 ParentWindowInPrimaryRootWindow(w1.get()); 700 ParentWindowInPrimaryRootWindow(w1.get());
689 delegate.set_window(w1.get()); 701 delegate.set_window(w1.get());
690 w1->Show(); 702 w1->Show();
691 } 703 }
692 704
693 // Verifies a window with a transient parent not managed by workspace works. 705 // Verifies a window with a transient parent not managed by workspace works.
694 TEST_F(WorkspaceControllerTest, TransientParent) { 706 TEST_P(WorkspaceControllerTest, TransientParent) {
695 // Normal window with no transient parent. 707 // Normal window with no transient parent.
696 std::unique_ptr<Window> w2(CreateTestWindow()); 708 std::unique_ptr<Window> w2(CreateTestWindow());
697 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 709 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
698 w2->Show(); 710 w2->Show();
699 wm::ActivateWindow(w2.get()); 711 wm::ActivateWindow(w2.get());
700 712
701 // Window with a transient parent. We set the transient parent to the root, 713 // Window with a transient parent. We set the transient parent to the root,
702 // which would never happen but is enough to exercise the bug. 714 // which would never happen but is enough to exercise the bug.
703 std::unique_ptr<Window> w1(CreateTestWindowUnparented()); 715 std::unique_ptr<Window> w1(CreateTestWindowUnparented());
704 ::wm::AddTransientChild(Shell::GetInstance()->GetPrimaryRootWindow(), 716 ::wm::AddTransientChild(Shell::GetInstance()->GetPrimaryRootWindow(),
705 w1.get()); 717 w1.get());
706 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); 718 w1->SetBounds(gfx::Rect(10, 11, 250, 251));
707 ParentWindowInPrimaryRootWindow(w1.get()); 719 ParentWindowInPrimaryRootWindow(w1.get());
708 w1->Show(); 720 w1->Show();
709 wm::ActivateWindow(w1.get()); 721 wm::ActivateWindow(w1.get());
710 722
711 // The window with the transient parent should get added to the same parent as 723 // The window with the transient parent should get added to the same parent as
712 // the normal window. 724 // the normal window.
713 EXPECT_EQ(w2->parent(), w1->parent()); 725 EXPECT_EQ(w2->parent(), w1->parent());
714 } 726 }
715 727
716 // Test the placement of newly created windows. 728 // Test the placement of newly created windows.
717 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnCreate) { 729 TEST_P(WorkspaceControllerTest, BasicAutoPlacingOnCreate) {
718 if (!SupportsHostWindowResize()) 730 if (!SupportsHostWindowResize())
719 return; 731 return;
720 UpdateDisplay("1600x1200"); 732 UpdateDisplay("1600x1200");
721 // Creating a popup handler here to make sure it does not interfere with the 733 // Creating a popup handler here to make sure it does not interfere with the
722 // existing windows. 734 // existing windows.
723 gfx::Rect source_browser_bounds(16, 32, 640, 320); 735 gfx::Rect source_browser_bounds(16, 32, 640, 320);
724 std::unique_ptr<aura::Window> browser_window( 736 std::unique_ptr<aura::Window> browser_window(
725 CreateBrowserLikeWindow(source_browser_bounds)); 737 CreateBrowserLikeWindow(source_browser_bounds));
726 738
727 // Creating a popup to make sure it does not interfere with the positioning. 739 // Creating a popup to make sure it does not interfere with the positioning.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 browser_window->Hide(); 775 browser_window->Hide();
764 { // If a window is there but not shown the default should be centered. 776 { // If a window is there but not shown the default should be centered.
765 std::unique_ptr<aura::Window> new_browser_window( 777 std::unique_ptr<aura::Window> new_browser_window(
766 CreateBrowserLikeWindow(gfx::Rect(50, 100, 300, 150))); 778 CreateBrowserLikeWindow(gfx::Rect(50, 100, 300, 150)));
767 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString()); 779 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString());
768 } 780 }
769 } 781 }
770 782
771 // Test that adding a second window shifts both the first window and its 783 // Test that adding a second window shifts both the first window and its
772 // transient child. 784 // transient child.
773 TEST_F(WorkspaceControllerTest, AutoPlacingMovesTransientChild) { 785 TEST_P(WorkspaceControllerTest, AutoPlacingMovesTransientChild) {
774 // Create an auto-positioned window. 786 // Create an auto-positioned window.
775 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 787 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
776 gfx::Rect desktop_area = window1->parent()->bounds(); 788 gfx::Rect desktop_area = window1->parent()->bounds();
777 wm::GetWindowState(window1.get())->set_window_position_managed(true); 789 wm::GetWindowState(window1.get())->set_window_position_managed(true);
778 // Hide and then show |window1| to trigger auto-positioning logic. 790 // Hide and then show |window1| to trigger auto-positioning logic.
779 window1->Hide(); 791 window1->Hide();
780 window1->SetBounds(gfx::Rect(16, 32, 300, 300)); 792 window1->SetBounds(gfx::Rect(16, 32, 300, 300));
781 window1->Show(); 793 window1->Show();
782 794
783 // |window1| should be horizontally centered. 795 // |window1| should be horizontally centered.
(...skipping 27 matching lines...) Expand all
811 EXPECT_EQ("0,32 300x300", window1->bounds().ToString()); 823 EXPECT_EQ("0,32 300x300", window1->bounds().ToString());
812 int x = x_child - x_window1; 824 int x = x_child - x_window1;
813 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString()); 825 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString());
814 // Check that |window2| has moved right. 826 // Check that |window2| has moved right.
815 x = desktop_area.width() - window2->bounds().width(); 827 x = desktop_area.width() - window2->bounds().width();
816 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString()); 828 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString());
817 } 829 }
818 830
819 // Test the basic auto placement of one and or two windows in a "simulated 831 // Test the basic auto placement of one and or two windows in a "simulated
820 // session" of sequential window operations. 832 // session" of sequential window operations.
821 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { 833 TEST_P(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) {
822 // Test 1: In case there is no manageable window, no window should shift. 834 // Test 1: In case there is no manageable window, no window should shift.
823 835
824 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 836 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
825 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 837 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
826 gfx::Rect desktop_area = window1->parent()->bounds(); 838 gfx::Rect desktop_area = window1->parent()->bounds();
827 839
828 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 840 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
829 // Trigger the auto window placement function by making it visible. 841 // Trigger the auto window placement function by making it visible.
830 // Note that the bounds are getting changed while it is invisible. 842 // Note that the bounds are getting changed while it is invisible.
831 window2->Hide(); 843 window2->Hide();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 window1->Hide(); 901 window1->Hide();
890 window1->Show(); 902 window1->Show();
891 // |window1| should be centered. 903 // |window1| should be centered.
892 EXPECT_EQ(base::IntToString( 904 EXPECT_EQ(base::IntToString(
893 (desktop_area.width() - window1->bounds().width()) / 2) + 905 (desktop_area.width() - window1->bounds().width()) / 2) +
894 ",32 640x320", 906 ",32 640x320",
895 window1->bounds().ToString()); 907 window1->bounds().ToString());
896 } 908 }
897 909
898 // Test the proper usage of user window movement interaction. 910 // Test the proper usage of user window movement interaction.
899 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { 911 TEST_P(WorkspaceControllerTest, TestUserMovedWindowRepositioning) {
900 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 912 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
901 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 913 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
902 gfx::Rect desktop_area = window1->parent()->bounds(); 914 gfx::Rect desktop_area = window1->parent()->bounds();
903 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 915 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
904 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 916 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
905 window1->Hide(); 917 window1->Hide();
906 window2->Hide(); 918 window2->Hide();
907 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 919 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
908 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 920 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
909 921
(...skipping 26 matching lines...) Expand all
936 EXPECT_FALSE(window2_state->bounds_changed_by_user()); 948 EXPECT_FALSE(window2_state->bounds_changed_by_user());
937 949
938 // Going back to one shown window should keep the state. 950 // Going back to one shown window should keep the state.
939 window1_state->set_bounds_changed_by_user(true); 951 window1_state->set_bounds_changed_by_user(true);
940 window2->Hide(); 952 window2->Hide();
941 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); 953 EXPECT_EQ("0,32 640x320", window1->bounds().ToString());
942 EXPECT_TRUE(window1_state->bounds_changed_by_user()); 954 EXPECT_TRUE(window1_state->bounds_changed_by_user());
943 } 955 }
944 956
945 // Test if the single window will be restored at original position. 957 // Test if the single window will be restored at original position.
946 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { 958 TEST_P(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) {
947 std::unique_ptr<aura::Window> window1( 959 std::unique_ptr<aura::Window> window1(
948 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); 960 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
949 std::unique_ptr<aura::Window> window2( 961 std::unique_ptr<aura::Window> window2(
950 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100))); 962 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100)));
951 std::unique_ptr<aura::Window> window3( 963 std::unique_ptr<aura::Window> window3(
952 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100))); 964 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100)));
953 window1->Hide(); 965 window1->Hide();
954 window2->Hide(); 966 window2->Hide();
955 window3->Hide(); 967 window3->Hide();
956 wm::GetWindowState(window1.get())->set_window_position_managed(true); 968 wm::GetWindowState(window1.get())->set_window_position_managed(true);
(...skipping 28 matching lines...) Expand all
985 EXPECT_EQ(window3->GetRootWindow()->bounds().right(), 997 EXPECT_EQ(window3->GetRootWindow()->bounds().right(),
986 window3->bounds().right()); 998 window3->bounds().right());
987 999
988 // Being a single window will retore the original location. 1000 // Being a single window will retore the original location.
989 window2->Hide(); 1001 window2->Hide();
990 EXPECT_EQ("120,120 100x100", window3->bounds().ToString()); 1002 EXPECT_EQ("120,120 100x100", window3->bounds().ToString());
991 } 1003 }
992 1004
993 // Test that user placed windows go back to their user placement after the user 1005 // Test that user placed windows go back to their user placement after the user
994 // closes all other windows. 1006 // closes all other windows.
995 TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { 1007 TEST_P(WorkspaceControllerTest, TestUserHandledWindowRestore) {
996 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1008 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
997 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320); 1009 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320);
998 window1->SetBounds(user_pos); 1010 window1->SetBounds(user_pos);
999 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1011 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1000 1012
1001 window1_state->SetPreAutoManageWindowBounds(user_pos); 1013 window1_state->SetPreAutoManageWindowBounds(user_pos);
1002 gfx::Rect desktop_area = window1->parent()->bounds(); 1014 gfx::Rect desktop_area = window1->parent()->bounds();
1003 1015
1004 // Create a second window to let the auto manager kick in. 1016 // Create a second window to let the auto manager kick in.
1005 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1017 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
(...skipping 17 matching lines...) Expand all
1023 1035
1024 // After the other window get hidden the window has to move back to the 1036 // After the other window get hidden the window has to move back to the
1025 // previous position and the bounds should still be set and unchanged. 1037 // previous position and the bounds should still be set and unchanged.
1026 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString()); 1038 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString());
1027 ASSERT_TRUE(window1_state->pre_auto_manage_window_bounds()); 1039 ASSERT_TRUE(window1_state->pre_auto_manage_window_bounds());
1028 EXPECT_EQ(user_pos.ToString(), 1040 EXPECT_EQ(user_pos.ToString(),
1029 window1_state->pre_auto_manage_window_bounds()->ToString()); 1041 window1_state->pre_auto_manage_window_bounds()->ToString());
1030 } 1042 }
1031 1043
1032 // Solo window should be restored to the bounds where a user moved to. 1044 // Solo window should be restored to the bounds where a user moved to.
1033 TEST_F(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) { 1045 TEST_P(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) {
1034 if (!SupportsHostWindowResize()) 1046 if (!SupportsHostWindowResize())
1035 return; 1047 return;
1036 1048
1037 UpdateDisplay("400x300"); 1049 UpdateDisplay("400x300");
1038 gfx::Rect default_bounds(10, 0, 100, 100); 1050 gfx::Rect default_bounds(10, 0, 100, 100);
1039 std::unique_ptr<aura::Window> window1( 1051 std::unique_ptr<aura::Window> window1(
1040 CreateTestWindowInShellWithBounds(default_bounds)); 1052 CreateTestWindowInShellWithBounds(default_bounds));
1041 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1053 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1042 window1->Hide(); 1054 window1->Hide();
1043 window1_state->set_window_position_managed(true); 1055 window1_state->set_window_position_managed(true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 window2->Show(); 1087 window2->Show();
1076 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); 1088 EXPECT_EQ("0,0 100x100", window1->bounds().ToString());
1077 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); 1089 EXPECT_EQ("300,0 100x100", window2->bounds().ToString());
1078 1090
1079 // Window 1 should be restored to the user modified bounds. 1091 // Window 1 should be restored to the user modified bounds.
1080 window2->Hide(); 1092 window2->Hide();
1081 EXPECT_EQ("100,0 100x100", window1->bounds().ToString()); 1093 EXPECT_EQ("100,0 100x100", window1->bounds().ToString());
1082 } 1094 }
1083 1095
1084 // Test that a window from normal to minimize will repos the remaining. 1096 // Test that a window from normal to minimize will repos the remaining.
1085 TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) { 1097 TEST_P(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) {
1086 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1098 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1087 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1099 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1088 window1_state->set_window_position_managed(true); 1100 window1_state->set_window_position_managed(true);
1089 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1101 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1090 gfx::Rect desktop_area = window1->parent()->bounds(); 1102 gfx::Rect desktop_area = window1->parent()->bounds();
1091 1103
1092 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1104 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1093 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1105 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1094 window2_state->set_window_position_managed(true); 1106 window2_state->set_window_position_managed(true);
1095 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1107 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
(...skipping 11 matching lines...) Expand all
1107 window1_state->Restore(); 1119 window1_state->Restore();
1108 // |window1| should be flush right and |window3| flush left. 1120 // |window1| should be flush right and |window3| flush left.
1109 EXPECT_EQ( 1121 EXPECT_EQ(
1110 base::IntToString(desktop_area.width() - window1->bounds().width()) + 1122 base::IntToString(desktop_area.width() - window1->bounds().width()) +
1111 ",32 640x320", 1123 ",32 640x320",
1112 window1->bounds().ToString()); 1124 window1->bounds().ToString());
1113 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); 1125 EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
1114 } 1126 }
1115 1127
1116 // Test that minimizing an initially maximized window will repos the remaining. 1128 // Test that minimizing an initially maximized window will repos the remaining.
1117 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { 1129 TEST_P(WorkspaceControllerTest, MaxToMinRepositionsRemaining) {
1118 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1130 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1119 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1131 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1120 window1_state->set_window_position_managed(true); 1132 window1_state->set_window_position_managed(true);
1121 gfx::Rect desktop_area = window1->parent()->bounds(); 1133 gfx::Rect desktop_area = window1->parent()->bounds();
1122 1134
1123 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1135 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1124 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1136 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1125 window2_state->set_window_position_managed(true); 1137 window2_state->set_window_position_managed(true);
1126 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1138 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
1127 1139
1128 window1_state->Maximize(); 1140 window1_state->Maximize();
1129 window1_state->Minimize(); 1141 window1_state->Minimize();
1130 1142
1131 // |window2| should be centered now. 1143 // |window2| should be centered now.
1132 EXPECT_TRUE(window2->IsVisible()); 1144 EXPECT_TRUE(window2->IsVisible());
1133 EXPECT_TRUE(window2_state->IsNormalStateType()); 1145 EXPECT_TRUE(window2_state->IsNormalStateType());
1134 EXPECT_EQ(base::IntToString( 1146 EXPECT_EQ(base::IntToString(
1135 (desktop_area.width() - window2->bounds().width()) / 2) + 1147 (desktop_area.width() - window2->bounds().width()) / 2) +
1136 ",48 256x512", 1148 ",48 256x512",
1137 window2->bounds().ToString()); 1149 window2->bounds().ToString());
1138 } 1150 }
1139 1151
1140 // Test that nomral, maximize, minimizing will repos the remaining. 1152 // Test that nomral, maximize, minimizing will repos the remaining.
1141 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { 1153 TEST_P(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) {
1142 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1154 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1143 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1155 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1144 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1156 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1145 window1_state->set_window_position_managed(true); 1157 window1_state->set_window_position_managed(true);
1146 gfx::Rect desktop_area = window1->parent()->bounds(); 1158 gfx::Rect desktop_area = window1->parent()->bounds();
1147 1159
1148 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1160 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1149 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1161 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1150 window2_state->set_window_position_managed(true); 1162 window2_state->set_window_position_managed(true);
1151 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); 1163 window2->SetBounds(gfx::Rect(32, 40, 256, 512));
(...skipping 15 matching lines...) Expand all
1167 // |window2| should be centered now. 1179 // |window2| should be centered now.
1168 EXPECT_TRUE(window2->IsVisible()); 1180 EXPECT_TRUE(window2->IsVisible());
1169 EXPECT_TRUE(window2_state->IsNormalStateType()); 1181 EXPECT_TRUE(window2_state->IsNormalStateType());
1170 EXPECT_EQ(base::IntToString( 1182 EXPECT_EQ(base::IntToString(
1171 (desktop_area.width() - window2->bounds().width()) / 2) + 1183 (desktop_area.width() - window2->bounds().width()) / 2) +
1172 ",40 256x512", 1184 ",40 256x512",
1173 window2->bounds().ToString()); 1185 window2->bounds().ToString());
1174 } 1186 }
1175 1187
1176 // Test that nomral, maximize, normal will repos the remaining. 1188 // Test that nomral, maximize, normal will repos the remaining.
1177 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { 1189 TEST_P(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) {
1178 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1190 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1179 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1191 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1180 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1192 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1181 window1_state->set_window_position_managed(true); 1193 window1_state->set_window_position_managed(true);
1182 gfx::Rect desktop_area = window1->parent()->bounds(); 1194 gfx::Rect desktop_area = window1->parent()->bounds();
1183 1195
1184 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1196 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1185 wm::GetWindowState(window2.get())->set_window_position_managed(true); 1197 wm::GetWindowState(window2.get())->set_window_position_managed(true);
1186 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); 1198 window2->SetBounds(gfx::Rect(32, 40, 256, 512));
1187 1199
(...skipping 13 matching lines...) Expand all
1201 1213
1202 // |window1| should be flush right and |window2| flush left. 1214 // |window1| should be flush right and |window2| flush left.
1203 EXPECT_EQ( 1215 EXPECT_EQ(
1204 base::IntToString(desktop_area.width() - window1->bounds().width()) + 1216 base::IntToString(desktop_area.width() - window1->bounds().width()) +
1205 ",32 640x320", 1217 ",32 640x320",
1206 window1->bounds().ToString()); 1218 window1->bounds().ToString());
1207 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); 1219 EXPECT_EQ("0,40 256x512", window2->bounds().ToString());
1208 } 1220 }
1209 1221
1210 // Test that animations are triggered. 1222 // Test that animations are triggered.
1211 TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) { 1223 TEST_P(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) {
1212 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1224 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1213 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1225 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1214 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1226 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1215 window1->Hide(); 1227 window1->Hide();
1216 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1228 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1217 gfx::Rect desktop_area = window1->parent()->bounds(); 1229 gfx::Rect desktop_area = window1->parent()->bounds();
1218 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1230 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1219 window2->Hide(); 1231 window2->Hide();
1220 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1232 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
1221 1233
(...skipping 21 matching lines...) Expand all
1243 ",32 640x320", 1255 ",32 640x320",
1244 window1->bounds().ToString()); 1256 window1->bounds().ToString());
1245 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); 1257 EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
1246 } 1258 }
1247 1259
1248 // This tests simulates a browser and an app and verifies the ordering of the 1260 // This tests simulates a browser and an app and verifies the ordering of the
1249 // windows and layers doesn't get out of sync as various operations occur. Its 1261 // windows and layers doesn't get out of sync as various operations occur. Its
1250 // really testing code in FocusController, but easier to simulate here. Just as 1262 // really testing code in FocusController, but easier to simulate here. Just as
1251 // with a real browser the browser here has a transient child window 1263 // with a real browser the browser here has a transient child window
1252 // (corresponds to the status bubble). 1264 // (corresponds to the status bubble).
1253 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { 1265 TEST_P(WorkspaceControllerTest, VerifyLayerOrdering) {
1254 std::unique_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate( 1266 std::unique_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate(
1255 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); 1267 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL));
1256 browser->SetName("browser"); 1268 browser->SetName("browser");
1257 ParentWindowInPrimaryRootWindow(browser.get()); 1269 ParentWindowInPrimaryRootWindow(browser.get());
1258 browser->Show(); 1270 browser->Show();
1259 wm::ActivateWindow(browser.get()); 1271 wm::ActivateWindow(browser.get());
1260 1272
1261 // |status_bubble| is made a transient child of |browser| and as a result 1273 // |status_bubble| is made a transient child of |browser| and as a result
1262 // owned by |browser|. 1274 // owned by |browser|.
1263 aura::test::TestWindowDelegate* status_bubble_delegate = 1275 aura::test::TestWindowDelegate* status_bubble_delegate =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 aura::Window* window_; 1357 aura::Window* window_;
1346 1358
1347 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); 1359 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver);
1348 }; 1360 };
1349 1361
1350 } // namespace 1362 } // namespace
1351 1363
1352 // Verifies that a new maximized window becomes visible after its activation 1364 // Verifies that a new maximized window becomes visible after its activation
1353 // is requested, even though it does not become activated because a system 1365 // is requested, even though it does not become activated because a system
1354 // modal window is active. 1366 // modal window is active.
1355 TEST_F(WorkspaceControllerTest, SwitchFromModal) { 1367 TEST_P(WorkspaceControllerTest, SwitchFromModal) {
1356 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented()); 1368 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented());
1357 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); 1369 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22));
1358 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 1370 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
1359 ParentWindowInPrimaryRootWindow(modal_window.get()); 1371 ParentWindowInPrimaryRootWindow(modal_window.get());
1360 modal_window->Show(); 1372 modal_window->Show();
1361 wm::ActivateWindow(modal_window.get()); 1373 wm::ActivateWindow(modal_window.get());
1362 1374
1363 std::unique_ptr<Window> maximized_window(CreateTestWindow()); 1375 std::unique_ptr<Window> maximized_window(CreateTestWindow());
1364 maximized_window->SetProperty(aura::client::kShowStateKey, 1376 maximized_window->SetProperty(aura::client::kShowStateKey,
1365 ui::SHOW_STATE_MAXIMIZED); 1377 ui::SHOW_STATE_MAXIMIZED);
(...skipping 12 matching lines...) Expand all
1378 ~WorkspaceControllerTestDragging() override {} 1390 ~WorkspaceControllerTestDragging() override {}
1379 1391
1380 private: 1392 private:
1381 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); 1393 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging);
1382 }; 1394 };
1383 1395
1384 } // namespace 1396 } // namespace
1385 1397
1386 // Verifies that when dragging a window over the shelf overlap is detected 1398 // Verifies that when dragging a window over the shelf overlap is detected
1387 // during and after the drag. 1399 // during and after the drag.
1388 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { 1400 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) {
1389 aura::test::TestWindowDelegate delegate; 1401 aura::test::TestWindowDelegate delegate;
1390 delegate.set_window_component(HTCAPTION); 1402 delegate.set_window_component(HTCAPTION);
1391 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( 1403 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate(
1392 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); 1404 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL));
1393 ParentWindowInPrimaryRootWindow(w1.get()); 1405 ParentWindowInPrimaryRootWindow(w1.get());
1394 1406
1395 Shelf* shelf = Shelf::ForPrimaryDisplay(); 1407 Shelf* shelf = Shelf::ForPrimaryDisplay();
1396 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1408 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1397 1409
1398 // Drag near the shelf. 1410 // Drag near the shelf.
1399 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1411 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1400 gfx::Point()); 1412 gfx::Point());
1401 generator.MoveMouseTo(10, 10); 1413 generator.MoveMouseTo(10, 10);
1402 generator.PressLeftButton(); 1414 generator.PressLeftButton();
1403 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70); 1415 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70);
1404 1416
1405 // Shelf should not be in overlapped state. 1417 // Shelf should not be in overlapped state.
1406 EXPECT_FALSE(GetWindowOverlapsShelf()); 1418 EXPECT_FALSE(GetWindowOverlapsShelf());
1407 1419
1408 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20); 1420 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20);
1409 1421
1410 // Shelf should detect overlap. Overlap state stays after mouse is released. 1422 // Shelf should detect overlap. Overlap state stays after mouse is released.
1411 EXPECT_TRUE(GetWindowOverlapsShelf()); 1423 EXPECT_TRUE(GetWindowOverlapsShelf());
1412 generator.ReleaseLeftButton(); 1424 generator.ReleaseLeftButton();
1413 EXPECT_TRUE(GetWindowOverlapsShelf()); 1425 EXPECT_TRUE(GetWindowOverlapsShelf());
1414 } 1426 }
1415 1427
1416 // Verifies that when dragging a window autohidden shelf stays hidden during 1428 // Verifies that when dragging a window autohidden shelf stays hidden during
1417 // and after the drag. 1429 // and after the drag.
1418 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { 1430 TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) {
1419 aura::test::TestWindowDelegate delegate; 1431 aura::test::TestWindowDelegate delegate;
1420 delegate.set_window_component(HTCAPTION); 1432 delegate.set_window_component(HTCAPTION);
1421 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( 1433 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate(
1422 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); 1434 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL));
1423 ParentWindowInPrimaryRootWindow(w1.get()); 1435 ParentWindowInPrimaryRootWindow(w1.get());
1424 1436
1425 Shelf* shelf = Shelf::ForPrimaryDisplay(); 1437 Shelf* shelf = Shelf::ForPrimaryDisplay();
1426 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1438 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1427 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1428 1440
1429 // Drag very little. 1441 // Drag very little.
1430 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1442 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1431 gfx::Point()); 1443 gfx::Point());
1432 generator.MoveMouseTo(10, 10); 1444 generator.MoveMouseTo(10, 10);
1433 generator.PressLeftButton(); 1445 generator.PressLeftButton();
1434 generator.MoveMouseTo(12, 12); 1446 generator.MoveMouseTo(12, 12);
1435 1447
1436 // Shelf should be hidden during and after the drag. 1448 // Shelf should be hidden during and after the drag.
1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1449 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1438 generator.ReleaseLeftButton(); 1450 generator.ReleaseLeftButton();
1439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1451 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1440 } 1452 }
1441 1453
1442 // Verifies that events are targeted properly just outside the window edges. 1454 // Verifies that events are targeted properly just outside the window edges.
1443 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { 1455 TEST_P(WorkspaceControllerTest, WindowEdgeHitTest) {
1444 aura::test::TestWindowDelegate d_first, d_second; 1456 aura::test::TestWindowDelegate d_first, d_second;
1445 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( 1457 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate(
1446 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); 1458 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL));
1447 ParentWindowInPrimaryRootWindow(first.get()); 1459 ParentWindowInPrimaryRootWindow(first.get());
1448 first->Show(); 1460 first->Show();
1449 1461
1450 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate( 1462 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate(
1451 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL)); 1463 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL));
1452 ParentWindowInPrimaryRootWindow(second.get()); 1464 ParentWindowInPrimaryRootWindow(second.get());
1453 second->Show(); 1465 second->Show();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } 1502 }
1491 // Apply a transform on |second|. After the transform is applied, the window 1503 // Apply a transform on |second|. After the transform is applied, the window
1492 // should no longer be targeted. 1504 // should no longer be targeted.
1493 gfx::Transform transform; 1505 gfx::Transform transform;
1494 transform.Translate(70, 40); 1506 transform.Translate(70, 40);
1495 second->SetTransform(transform); 1507 second->SetTransform(transform);
1496 } 1508 }
1497 } 1509 }
1498 1510
1499 // Verifies mouse event targeting just outside the window edges for panels. 1511 // Verifies mouse event targeting just outside the window edges for panels.
1500 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { 1512 TEST_P(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) {
1501 aura::test::TestWindowDelegate delegate; 1513 aura::test::TestWindowDelegate delegate;
1502 std::unique_ptr<Window> window( 1514 std::unique_ptr<Window> window(
1503 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); 1515 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50)));
1504 ui::EventTarget* root = window->GetRootWindow(); 1516 ui::EventTarget* root = window->GetRootWindow();
1505 ui::EventTargeter* targeter = root->GetEventTargeter(); 1517 ui::EventTargeter* targeter = root->GetEventTargeter();
1506 const gfx::Rect bounds = window->bounds(); 1518 const gfx::Rect bounds = window->bounds();
1507 const int kNumPoints = 5; 1519 const int kNumPoints = 5;
1508 struct { 1520 struct {
1509 const char* direction; 1521 const char* direction;
1510 gfx::Point location; 1522 gfx::Point location;
(...skipping 15 matching lines...) Expand all
1526 EXPECT_EQ(window.get(), target); 1538 EXPECT_EQ(window.get(), target);
1527 else 1539 else
1528 EXPECT_NE(window.get(), target); 1540 EXPECT_NE(window.get(), target);
1529 } 1541 }
1530 } 1542 }
1531 1543
1532 // Verifies touch event targeting just outside the window edges for panels. 1544 // Verifies touch event targeting just outside the window edges for panels.
1533 // The shelf is aligned to the bottom by default, and so touches just below 1545 // The shelf is aligned to the bottom by default, and so touches just below
1534 // the bottom edge of the panel should not target the panel itself because 1546 // the bottom edge of the panel should not target the panel itself because
1535 // an AttachedPanelWindowTargeter is installed on the panel container. 1547 // an AttachedPanelWindowTargeter is installed on the panel container.
1536 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { 1548 TEST_P(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) {
1537 aura::test::TestWindowDelegate delegate; 1549 aura::test::TestWindowDelegate delegate;
1538 std::unique_ptr<Window> window( 1550 std::unique_ptr<Window> window(
1539 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); 1551 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50)));
1540 ui::EventTarget* root = window->GetRootWindow(); 1552 ui::EventTarget* root = window->GetRootWindow();
1541 ui::EventTargeter* targeter = root->GetEventTargeter(); 1553 ui::EventTargeter* targeter = root->GetEventTargeter();
1542 const gfx::Rect bounds = window->bounds(); 1554 const gfx::Rect bounds = window->bounds();
1543 const int kNumPoints = 5; 1555 const int kNumPoints = 5;
1544 struct { 1556 struct {
1545 const char* direction; 1557 const char* direction;
1546 gfx::Point location; 1558 gfx::Point location;
(...skipping 12 matching lines...) Expand all
1559 ui::EventTimeForNow()); 1571 ui::EventTimeForNow());
1560 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); 1572 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch);
1561 if (points[i].is_target_hit) 1573 if (points[i].is_target_hit)
1562 EXPECT_EQ(window.get(), target); 1574 EXPECT_EQ(window.get(), target);
1563 else 1575 else
1564 EXPECT_NE(window.get(), target); 1576 EXPECT_NE(window.get(), target);
1565 } 1577 }
1566 } 1578 }
1567 1579
1568 // Verifies events targeting just outside the window edges for docked windows. 1580 // Verifies events targeting just outside the window edges for docked windows.
1569 TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) { 1581 TEST_P(WorkspaceControllerTest, WindowEdgeHitTestDocked) {
1570 aura::test::TestWindowDelegate delegate; 1582 aura::test::TestWindowDelegate delegate;
1571 // Make window smaller than the minimum docked area so that the window edges 1583 // Make window smaller than the minimum docked area so that the window edges
1572 // are exposed. 1584 // are exposed.
1573 delegate.set_maximum_size(gfx::Size(180, 200)); 1585 delegate.set_maximum_size(gfx::Size(180, 200));
1574 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate( 1586 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate(
1575 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL)); 1587 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL));
1576 ParentWindowInPrimaryRootWindow(window.get()); 1588 ParentWindowInPrimaryRootWindow(window.get());
1577 aura::Window* docked_container = Shell::GetContainer( 1589 aura::Window* docked_container = Shell::GetContainer(
1578 window->GetRootWindow(), kShellWindowId_DockedContainer); 1590 window->GetRootWindow(), kShellWindowId_DockedContainer);
1579 docked_container->AddChild(window.get()); 1591 docked_container->AddChild(window.get());
(...skipping 28 matching lines...) Expand all
1608 ui::EventTimeForNow()); 1620 ui::EventTimeForNow());
1609 target = targeter->FindTargetForEvent(root, &touch); 1621 target = targeter->FindTargetForEvent(root, &touch);
1610 if (points[i].is_target_hit) 1622 if (points[i].is_target_hit)
1611 EXPECT_EQ(window.get(), target); 1623 EXPECT_EQ(window.get(), target);
1612 else 1624 else
1613 EXPECT_NE(window.get(), target); 1625 EXPECT_NE(window.get(), target);
1614 } 1626 }
1615 } 1627 }
1616 1628
1617 } // namespace ash 1629 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698