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

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: address comments 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
442 gfx::Rect restore = window_state->GetRestoreBoundsInScreen(); 449 gfx::Rect restore = window_state->GetRestoreBoundsInScreen();
443 EXPECT_EQ("0,0 800x597", w1->bounds().ToString()); 450 EXPECT_EQ(
451 gfx::Rect(0, 0, 800, 597 + GetMdAutoHiddenShelfHeightOffset()).ToString(),
452 w1->bounds().ToString());
444 EXPECT_EQ("0,1 101x102", restore.ToString()); 453 EXPECT_EQ("0,1 101x102", restore.ToString());
445 window_state->ClearRestoreBounds(); 454 window_state->ClearRestoreBounds();
446 w1->SetBounds(restore); 455 w1->SetBounds(restore);
447 456
448 // Restore. 457 // Restore.
449 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 458 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
450 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 459 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
451 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); 460 EXPECT_EQ("0,1 101x102", w1->bounds().ToString());
452 461
453 // Create another window, maximized. 462 // Create another window, maximized.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 wm::ActivateWindow(w1.get()); 503 wm::ActivateWindow(w1.get());
495 EXPECT_FALSE(GetWindowOverlapsShelf()); 504 EXPECT_FALSE(GetWindowOverlapsShelf());
496 505
497 // Restore w2. 506 // Restore w2.
498 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 507 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
499 EXPECT_TRUE(GetWindowOverlapsShelf()); 508 EXPECT_TRUE(GetWindowOverlapsShelf());
500 } 509 }
501 510
502 // Verifies going from maximized to minimized sets the right state for painting 511 // Verifies going from maximized to minimized sets the right state for painting
503 // the background of the launcher. 512 // the background of the launcher.
504 TEST_F(WorkspaceControllerTest, MinimizeResetsVisibility) { 513 TEST_P(WorkspaceControllerTest, MinimizeResetsVisibility) {
505 std::unique_ptr<Window> w1(CreateTestWindow()); 514 std::unique_ptr<Window> w1(CreateTestWindow());
506 w1->Show(); 515 w1->Show();
507 wm::ActivateWindow(w1.get()); 516 wm::ActivateWindow(w1.get());
508 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 517 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
509 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType()); 518 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, shelf_widget()->GetBackgroundType());
510 519
511 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 520 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
512 Shelf* shelf = Shelf::ForPrimaryDisplay(); 521 Shelf* shelf = Shelf::ForPrimaryDisplay();
513 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 522 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
514 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType()); 523 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, shelf_widget()->GetBackgroundType());
515 } 524 }
516 525
517 // Verifies window visibility during various workspace changes. 526 // Verifies window visibility during various workspace changes.
518 TEST_F(WorkspaceControllerTest, VisibilityTests) { 527 TEST_P(WorkspaceControllerTest, VisibilityTests) {
519 std::unique_ptr<Window> w1(CreateTestWindow()); 528 std::unique_ptr<Window> w1(CreateTestWindow());
520 w1->Show(); 529 w1->Show();
521 EXPECT_TRUE(w1->IsVisible()); 530 EXPECT_TRUE(w1->IsVisible());
522 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); 531 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity());
523 532
524 // Create another window, activate it and make it fullscreen. 533 // Create another window, activate it and make it fullscreen.
525 std::unique_ptr<Window> w2(CreateTestWindow()); 534 std::unique_ptr<Window> w2(CreateTestWindow());
526 w2->Show(); 535 w2->Show();
527 wm::ActivateWindow(w2.get()); 536 wm::ActivateWindow(w2.get());
528 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 537 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()); 574 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity());
566 EXPECT_TRUE(w1->IsVisible()); 575 EXPECT_TRUE(w1->IsVisible());
567 576
568 // Close |w2|. 577 // Close |w2|.
569 w2.reset(); 578 w2.reset();
570 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); 579 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity());
571 EXPECT_TRUE(w1->IsVisible()); 580 EXPECT_TRUE(w1->IsVisible());
572 } 581 }
573 582
574 // Verifies windows that are offscreen don't move when switching workspaces. 583 // Verifies windows that are offscreen don't move when switching workspaces.
575 TEST_F(WorkspaceControllerTest, DontMoveOnSwitch) { 584 TEST_P(WorkspaceControllerTest, DontMoveOnSwitch) {
576 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 585 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
577 gfx::Point()); 586 gfx::Point());
578 generator.MoveMouseTo(0, 0); 587 generator.MoveMouseTo(0, 0);
579 588
580 std::unique_ptr<Window> w1(CreateTestWindow()); 589 std::unique_ptr<Window> w1(CreateTestWindow());
581 const gfx::Rect touches_shelf_bounds( 590 const gfx::Rect touches_shelf_bounds(
582 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102); 591 0, shelf_layout_manager()->GetIdealBounds().y() - 10, 101, 102);
583 // Move |w1| to overlap the shelf. 592 // Move |w1| to overlap the shelf.
584 w1->SetBounds(touches_shelf_bounds); 593 w1->SetBounds(touches_shelf_bounds);
585 w1->Show(); 594 w1->Show();
586 wm::ActivateWindow(w1.get()); 595 wm::ActivateWindow(w1.get());
587 596
588 // Create another window and maximize it. 597 // Create another window and maximize it.
589 std::unique_ptr<Window> w2(CreateTestWindow()); 598 std::unique_ptr<Window> w2(CreateTestWindow());
590 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 599 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
591 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 600 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
592 w2->Show(); 601 w2->Show();
593 wm::ActivateWindow(w2.get()); 602 wm::ActivateWindow(w2.get());
594 603
595 // Switch to w1. 604 // Switch to w1.
596 wm::ActivateWindow(w1.get()); 605 wm::ActivateWindow(w1.get());
597 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString()); 606 EXPECT_EQ(touches_shelf_bounds.ToString(), w1->bounds().ToString());
598 } 607 }
599 608
600 // Verifies that windows that are completely offscreen move when switching 609 // Verifies that windows that are completely offscreen move when switching
601 // workspaces. 610 // workspaces.
602 TEST_F(WorkspaceControllerTest, MoveOnSwitch) { 611 TEST_P(WorkspaceControllerTest, MoveOnSwitch) {
603 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 612 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
604 gfx::Point()); 613 gfx::Point());
605 generator.MoveMouseTo(0, 0); 614 generator.MoveMouseTo(0, 0);
606 615
607 std::unique_ptr<Window> w1(CreateTestWindow()); 616 std::unique_ptr<Window> w1(CreateTestWindow());
608 const gfx::Rect w1_bounds(0, shelf_layout_manager()->GetIdealBounds().y(), 617 const gfx::Rect w1_bounds(0, shelf_layout_manager()->GetIdealBounds().y(),
609 100, 200); 618 100, 200);
610 // Move |w1| so that the top edge is the same as the top edge of the shelf. 619 // Move |w1| so that the top edge is the same as the top edge of the shelf.
611 w1->SetBounds(w1_bounds); 620 w1->SetBounds(w1_bounds);
612 w1->Show(); 621 w1->Show();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 DISALLOW_COPY_AND_ASSIGN(DontCrashOnChangeAndActivateDelegate); 666 DISALLOW_COPY_AND_ASSIGN(DontCrashOnChangeAndActivateDelegate);
658 }; 667 };
659 668
660 } // namespace 669 } // namespace
661 670
662 // Exercises possible crash in W2. Here's the sequence: 671 // Exercises possible crash in W2. Here's the sequence:
663 // . minimize a maximized window. 672 // . minimize a maximized window.
664 // . remove the window (which happens when switching displays). 673 // . remove the window (which happens when switching displays).
665 // . add the window back. 674 // . add the window back.
666 // . show the window and during the bounds change activate it. 675 // . show the window and during the bounds change activate it.
667 TEST_F(WorkspaceControllerTest, DontCrashOnChangeAndActivate) { 676 TEST_P(WorkspaceControllerTest, DontCrashOnChangeAndActivate) {
668 // Force the shelf 677 // Force the shelf
669 Shelf* shelf = Shelf::ForPrimaryDisplay(); 678 Shelf* shelf = Shelf::ForPrimaryDisplay();
670 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 679 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
671 680
672 DontCrashOnChangeAndActivateDelegate delegate; 681 DontCrashOnChangeAndActivateDelegate delegate;
673 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate( 682 std::unique_ptr<Window> w1(CreateTestWindowInShellWithDelegate(
674 &delegate, 1000, gfx::Rect(10, 11, 250, 251))); 683 &delegate, 1000, gfx::Rect(10, 11, 250, 251)));
675 684
676 w1->Show(); 685 w1->Show();
677 wm::WindowState* w1_state = wm::GetWindowState(w1.get()); 686 wm::WindowState* w1_state = wm::GetWindowState(w1.get());
678 w1_state->Activate(); 687 w1_state->Activate();
679 w1_state->Maximize(); 688 w1_state->Maximize();
680 w1_state->Minimize(); 689 w1_state->Minimize();
681 690
682 w1->parent()->RemoveChild(w1.get()); 691 w1->parent()->RemoveChild(w1.get());
683 692
684 // Do this so that when we Show() the window a resize occurs and we make the 693 // Do this so that when we Show() the window a resize occurs and we make the
685 // window active. 694 // window active.
686 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 695 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
687 696
688 ParentWindowInPrimaryRootWindow(w1.get()); 697 ParentWindowInPrimaryRootWindow(w1.get());
689 delegate.set_window(w1.get()); 698 delegate.set_window(w1.get());
690 w1->Show(); 699 w1->Show();
691 } 700 }
692 701
693 // Verifies a window with a transient parent not managed by workspace works. 702 // Verifies a window with a transient parent not managed by workspace works.
694 TEST_F(WorkspaceControllerTest, TransientParent) { 703 TEST_P(WorkspaceControllerTest, TransientParent) {
695 // Normal window with no transient parent. 704 // Normal window with no transient parent.
696 std::unique_ptr<Window> w2(CreateTestWindow()); 705 std::unique_ptr<Window> w2(CreateTestWindow());
697 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); 706 w2->SetBounds(gfx::Rect(10, 11, 250, 251));
698 w2->Show(); 707 w2->Show();
699 wm::ActivateWindow(w2.get()); 708 wm::ActivateWindow(w2.get());
700 709
701 // Window with a transient parent. We set the transient parent to the root, 710 // 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. 711 // which would never happen but is enough to exercise the bug.
703 std::unique_ptr<Window> w1(CreateTestWindowUnparented()); 712 std::unique_ptr<Window> w1(CreateTestWindowUnparented());
704 ::wm::AddTransientChild(Shell::GetInstance()->GetPrimaryRootWindow(), 713 ::wm::AddTransientChild(Shell::GetInstance()->GetPrimaryRootWindow(),
705 w1.get()); 714 w1.get());
706 w1->SetBounds(gfx::Rect(10, 11, 250, 251)); 715 w1->SetBounds(gfx::Rect(10, 11, 250, 251));
707 ParentWindowInPrimaryRootWindow(w1.get()); 716 ParentWindowInPrimaryRootWindow(w1.get());
708 w1->Show(); 717 w1->Show();
709 wm::ActivateWindow(w1.get()); 718 wm::ActivateWindow(w1.get());
710 719
711 // The window with the transient parent should get added to the same parent as 720 // The window with the transient parent should get added to the same parent as
712 // the normal window. 721 // the normal window.
713 EXPECT_EQ(w2->parent(), w1->parent()); 722 EXPECT_EQ(w2->parent(), w1->parent());
714 } 723 }
715 724
716 // Test the placement of newly created windows. 725 // Test the placement of newly created windows.
717 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnCreate) { 726 TEST_P(WorkspaceControllerTest, BasicAutoPlacingOnCreate) {
718 if (!SupportsHostWindowResize()) 727 if (!SupportsHostWindowResize())
719 return; 728 return;
720 UpdateDisplay("1600x1200"); 729 UpdateDisplay("1600x1200");
721 // Creating a popup handler here to make sure it does not interfere with the 730 // Creating a popup handler here to make sure it does not interfere with the
722 // existing windows. 731 // existing windows.
723 gfx::Rect source_browser_bounds(16, 32, 640, 320); 732 gfx::Rect source_browser_bounds(16, 32, 640, 320);
724 std::unique_ptr<aura::Window> browser_window( 733 std::unique_ptr<aura::Window> browser_window(
725 CreateBrowserLikeWindow(source_browser_bounds)); 734 CreateBrowserLikeWindow(source_browser_bounds));
726 735
727 // Creating a popup to make sure it does not interfere with the positioning. 736 // 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(); 772 browser_window->Hide();
764 { // If a window is there but not shown the default should be centered. 773 { // If a window is there but not shown the default should be centered.
765 std::unique_ptr<aura::Window> new_browser_window( 774 std::unique_ptr<aura::Window> new_browser_window(
766 CreateBrowserLikeWindow(gfx::Rect(50, 100, 300, 150))); 775 CreateBrowserLikeWindow(gfx::Rect(50, 100, 300, 150)));
767 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString()); 776 EXPECT_EQ("650,100 300x150", new_browser_window->bounds().ToString());
768 } 777 }
769 } 778 }
770 779
771 // Test that adding a second window shifts both the first window and its 780 // Test that adding a second window shifts both the first window and its
772 // transient child. 781 // transient child.
773 TEST_F(WorkspaceControllerTest, AutoPlacingMovesTransientChild) { 782 TEST_P(WorkspaceControllerTest, AutoPlacingMovesTransientChild) {
774 // Create an auto-positioned window. 783 // Create an auto-positioned window.
775 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 784 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
776 gfx::Rect desktop_area = window1->parent()->bounds(); 785 gfx::Rect desktop_area = window1->parent()->bounds();
777 wm::GetWindowState(window1.get())->set_window_position_managed(true); 786 wm::GetWindowState(window1.get())->set_window_position_managed(true);
778 // Hide and then show |window1| to trigger auto-positioning logic. 787 // Hide and then show |window1| to trigger auto-positioning logic.
779 window1->Hide(); 788 window1->Hide();
780 window1->SetBounds(gfx::Rect(16, 32, 300, 300)); 789 window1->SetBounds(gfx::Rect(16, 32, 300, 300));
781 window1->Show(); 790 window1->Show();
782 791
783 // |window1| should be horizontally centered. 792 // |window1| should be horizontally centered.
(...skipping 27 matching lines...) Expand all
811 EXPECT_EQ("0,32 300x300", window1->bounds().ToString()); 820 EXPECT_EQ("0,32 300x300", window1->bounds().ToString());
812 int x = x_child - x_window1; 821 int x = x_child - x_window1;
813 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString()); 822 EXPECT_EQ(base::IntToString(x) + ",20 200x200", child->bounds().ToString());
814 // Check that |window2| has moved right. 823 // Check that |window2| has moved right.
815 x = desktop_area.width() - window2->bounds().width(); 824 x = desktop_area.width() - window2->bounds().width();
816 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString()); 825 EXPECT_EQ(base::IntToString(x) + ",48 250x250", window2->bounds().ToString());
817 } 826 }
818 827
819 // Test the basic auto placement of one and or two windows in a "simulated 828 // Test the basic auto placement of one and or two windows in a "simulated
820 // session" of sequential window operations. 829 // session" of sequential window operations.
821 TEST_F(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) { 830 TEST_P(WorkspaceControllerTest, BasicAutoPlacingOnShowHide) {
822 // Test 1: In case there is no manageable window, no window should shift. 831 // Test 1: In case there is no manageable window, no window should shift.
823 832
824 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 833 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
825 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 834 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
826 gfx::Rect desktop_area = window1->parent()->bounds(); 835 gfx::Rect desktop_area = window1->parent()->bounds();
827 836
828 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 837 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
829 // Trigger the auto window placement function by making it visible. 838 // Trigger the auto window placement function by making it visible.
830 // Note that the bounds are getting changed while it is invisible. 839 // Note that the bounds are getting changed while it is invisible.
831 window2->Hide(); 840 window2->Hide();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 window1->Hide(); 898 window1->Hide();
890 window1->Show(); 899 window1->Show();
891 // |window1| should be centered. 900 // |window1| should be centered.
892 EXPECT_EQ(base::IntToString( 901 EXPECT_EQ(base::IntToString(
893 (desktop_area.width() - window1->bounds().width()) / 2) + 902 (desktop_area.width() - window1->bounds().width()) / 2) +
894 ",32 640x320", 903 ",32 640x320",
895 window1->bounds().ToString()); 904 window1->bounds().ToString());
896 } 905 }
897 906
898 // Test the proper usage of user window movement interaction. 907 // Test the proper usage of user window movement interaction.
899 TEST_F(WorkspaceControllerTest, TestUserMovedWindowRepositioning) { 908 TEST_P(WorkspaceControllerTest, TestUserMovedWindowRepositioning) {
900 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 909 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
901 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 910 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
902 gfx::Rect desktop_area = window1->parent()->bounds(); 911 gfx::Rect desktop_area = window1->parent()->bounds();
903 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 912 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
904 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 913 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
905 window1->Hide(); 914 window1->Hide();
906 window2->Hide(); 915 window2->Hide();
907 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 916 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
908 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 917 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
909 918
(...skipping 26 matching lines...) Expand all
936 EXPECT_FALSE(window2_state->bounds_changed_by_user()); 945 EXPECT_FALSE(window2_state->bounds_changed_by_user());
937 946
938 // Going back to one shown window should keep the state. 947 // Going back to one shown window should keep the state.
939 window1_state->set_bounds_changed_by_user(true); 948 window1_state->set_bounds_changed_by_user(true);
940 window2->Hide(); 949 window2->Hide();
941 EXPECT_EQ("0,32 640x320", window1->bounds().ToString()); 950 EXPECT_EQ("0,32 640x320", window1->bounds().ToString());
942 EXPECT_TRUE(window1_state->bounds_changed_by_user()); 951 EXPECT_TRUE(window1_state->bounds_changed_by_user());
943 } 952 }
944 953
945 // Test if the single window will be restored at original position. 954 // Test if the single window will be restored at original position.
946 TEST_F(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) { 955 TEST_P(WorkspaceControllerTest, TestSingleWindowsRestoredBounds) {
947 std::unique_ptr<aura::Window> window1( 956 std::unique_ptr<aura::Window> window1(
948 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); 957 CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
949 std::unique_ptr<aura::Window> window2( 958 std::unique_ptr<aura::Window> window2(
950 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100))); 959 CreateTestWindowInShellWithBounds(gfx::Rect(110, 110, 100, 100)));
951 std::unique_ptr<aura::Window> window3( 960 std::unique_ptr<aura::Window> window3(
952 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100))); 961 CreateTestWindowInShellWithBounds(gfx::Rect(120, 120, 100, 100)));
953 window1->Hide(); 962 window1->Hide();
954 window2->Hide(); 963 window2->Hide();
955 window3->Hide(); 964 window3->Hide();
956 wm::GetWindowState(window1.get())->set_window_position_managed(true); 965 wm::GetWindowState(window1.get())->set_window_position_managed(true);
(...skipping 28 matching lines...) Expand all
985 EXPECT_EQ(window3->GetRootWindow()->bounds().right(), 994 EXPECT_EQ(window3->GetRootWindow()->bounds().right(),
986 window3->bounds().right()); 995 window3->bounds().right());
987 996
988 // Being a single window will retore the original location. 997 // Being a single window will retore the original location.
989 window2->Hide(); 998 window2->Hide();
990 EXPECT_EQ("120,120 100x100", window3->bounds().ToString()); 999 EXPECT_EQ("120,120 100x100", window3->bounds().ToString());
991 } 1000 }
992 1001
993 // Test that user placed windows go back to their user placement after the user 1002 // Test that user placed windows go back to their user placement after the user
994 // closes all other windows. 1003 // closes all other windows.
995 TEST_F(WorkspaceControllerTest, TestUserHandledWindowRestore) { 1004 TEST_P(WorkspaceControllerTest, TestUserHandledWindowRestore) {
996 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1005 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
997 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320); 1006 gfx::Rect user_pos = gfx::Rect(16, 42, 640, 320);
998 window1->SetBounds(user_pos); 1007 window1->SetBounds(user_pos);
999 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1008 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1000 1009
1001 window1_state->SetPreAutoManageWindowBounds(user_pos); 1010 window1_state->SetPreAutoManageWindowBounds(user_pos);
1002 gfx::Rect desktop_area = window1->parent()->bounds(); 1011 gfx::Rect desktop_area = window1->parent()->bounds();
1003 1012
1004 // Create a second window to let the auto manager kick in. 1013 // Create a second window to let the auto manager kick in.
1005 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1014 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
(...skipping 17 matching lines...) Expand all
1023 1032
1024 // After the other window get hidden the window has to move back to the 1033 // 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. 1034 // previous position and the bounds should still be set and unchanged.
1026 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString()); 1035 EXPECT_EQ(user_pos.ToString(), window1->bounds().ToString());
1027 ASSERT_TRUE(window1_state->pre_auto_manage_window_bounds()); 1036 ASSERT_TRUE(window1_state->pre_auto_manage_window_bounds());
1028 EXPECT_EQ(user_pos.ToString(), 1037 EXPECT_EQ(user_pos.ToString(),
1029 window1_state->pre_auto_manage_window_bounds()->ToString()); 1038 window1_state->pre_auto_manage_window_bounds()->ToString());
1030 } 1039 }
1031 1040
1032 // Solo window should be restored to the bounds where a user moved to. 1041 // Solo window should be restored to the bounds where a user moved to.
1033 TEST_F(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) { 1042 TEST_P(WorkspaceControllerTest, TestRestoreToUserModifiedBounds) {
1034 if (!SupportsHostWindowResize()) 1043 if (!SupportsHostWindowResize())
1035 return; 1044 return;
1036 1045
1037 UpdateDisplay("400x300"); 1046 UpdateDisplay("400x300");
1038 gfx::Rect default_bounds(10, 0, 100, 100); 1047 gfx::Rect default_bounds(10, 0, 100, 100);
1039 std::unique_ptr<aura::Window> window1( 1048 std::unique_ptr<aura::Window> window1(
1040 CreateTestWindowInShellWithBounds(default_bounds)); 1049 CreateTestWindowInShellWithBounds(default_bounds));
1041 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1050 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1042 window1->Hide(); 1051 window1->Hide();
1043 window1_state->set_window_position_managed(true); 1052 window1_state->set_window_position_managed(true);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 window2->Show(); 1084 window2->Show();
1076 EXPECT_EQ("0,0 100x100", window1->bounds().ToString()); 1085 EXPECT_EQ("0,0 100x100", window1->bounds().ToString());
1077 EXPECT_EQ("300,0 100x100", window2->bounds().ToString()); 1086 EXPECT_EQ("300,0 100x100", window2->bounds().ToString());
1078 1087
1079 // Window 1 should be restored to the user modified bounds. 1088 // Window 1 should be restored to the user modified bounds.
1080 window2->Hide(); 1089 window2->Hide();
1081 EXPECT_EQ("100,0 100x100", window1->bounds().ToString()); 1090 EXPECT_EQ("100,0 100x100", window1->bounds().ToString());
1082 } 1091 }
1083 1092
1084 // Test that a window from normal to minimize will repos the remaining. 1093 // Test that a window from normal to minimize will repos the remaining.
1085 TEST_F(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) { 1094 TEST_P(WorkspaceControllerTest, ToMinimizeRepositionsRemaining) {
1086 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1095 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1087 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1096 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1088 window1_state->set_window_position_managed(true); 1097 window1_state->set_window_position_managed(true);
1089 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1098 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1090 gfx::Rect desktop_area = window1->parent()->bounds(); 1099 gfx::Rect desktop_area = window1->parent()->bounds();
1091 1100
1092 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1101 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1093 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1102 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1094 window2_state->set_window_position_managed(true); 1103 window2_state->set_window_position_managed(true);
1095 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1104 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
(...skipping 11 matching lines...) Expand all
1107 window1_state->Restore(); 1116 window1_state->Restore();
1108 // |window1| should be flush right and |window3| flush left. 1117 // |window1| should be flush right and |window3| flush left.
1109 EXPECT_EQ( 1118 EXPECT_EQ(
1110 base::IntToString(desktop_area.width() - window1->bounds().width()) + 1119 base::IntToString(desktop_area.width() - window1->bounds().width()) +
1111 ",32 640x320", 1120 ",32 640x320",
1112 window1->bounds().ToString()); 1121 window1->bounds().ToString());
1113 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); 1122 EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
1114 } 1123 }
1115 1124
1116 // Test that minimizing an initially maximized window will repos the remaining. 1125 // Test that minimizing an initially maximized window will repos the remaining.
1117 TEST_F(WorkspaceControllerTest, MaxToMinRepositionsRemaining) { 1126 TEST_P(WorkspaceControllerTest, MaxToMinRepositionsRemaining) {
1118 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1127 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1119 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1128 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1120 window1_state->set_window_position_managed(true); 1129 window1_state->set_window_position_managed(true);
1121 gfx::Rect desktop_area = window1->parent()->bounds(); 1130 gfx::Rect desktop_area = window1->parent()->bounds();
1122 1131
1123 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1132 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1124 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1133 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1125 window2_state->set_window_position_managed(true); 1134 window2_state->set_window_position_managed(true);
1126 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1135 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
1127 1136
1128 window1_state->Maximize(); 1137 window1_state->Maximize();
1129 window1_state->Minimize(); 1138 window1_state->Minimize();
1130 1139
1131 // |window2| should be centered now. 1140 // |window2| should be centered now.
1132 EXPECT_TRUE(window2->IsVisible()); 1141 EXPECT_TRUE(window2->IsVisible());
1133 EXPECT_TRUE(window2_state->IsNormalStateType()); 1142 EXPECT_TRUE(window2_state->IsNormalStateType());
1134 EXPECT_EQ(base::IntToString( 1143 EXPECT_EQ(base::IntToString(
1135 (desktop_area.width() - window2->bounds().width()) / 2) + 1144 (desktop_area.width() - window2->bounds().width()) / 2) +
1136 ",48 256x512", 1145 ",48 256x512",
1137 window2->bounds().ToString()); 1146 window2->bounds().ToString());
1138 } 1147 }
1139 1148
1140 // Test that nomral, maximize, minimizing will repos the remaining. 1149 // Test that nomral, maximize, minimizing will repos the remaining.
1141 TEST_F(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) { 1150 TEST_P(WorkspaceControllerTest, NormToMaxToMinRepositionsRemaining) {
1142 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1151 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1143 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1152 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1144 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1153 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1145 window1_state->set_window_position_managed(true); 1154 window1_state->set_window_position_managed(true);
1146 gfx::Rect desktop_area = window1->parent()->bounds(); 1155 gfx::Rect desktop_area = window1->parent()->bounds();
1147 1156
1148 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1157 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1149 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); 1158 wm::WindowState* window2_state = wm::GetWindowState(window2.get());
1150 window2_state->set_window_position_managed(true); 1159 window2_state->set_window_position_managed(true);
1151 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); 1160 window2->SetBounds(gfx::Rect(32, 40, 256, 512));
(...skipping 15 matching lines...) Expand all
1167 // |window2| should be centered now. 1176 // |window2| should be centered now.
1168 EXPECT_TRUE(window2->IsVisible()); 1177 EXPECT_TRUE(window2->IsVisible());
1169 EXPECT_TRUE(window2_state->IsNormalStateType()); 1178 EXPECT_TRUE(window2_state->IsNormalStateType());
1170 EXPECT_EQ(base::IntToString( 1179 EXPECT_EQ(base::IntToString(
1171 (desktop_area.width() - window2->bounds().width()) / 2) + 1180 (desktop_area.width() - window2->bounds().width()) / 2) +
1172 ",40 256x512", 1181 ",40 256x512",
1173 window2->bounds().ToString()); 1182 window2->bounds().ToString());
1174 } 1183 }
1175 1184
1176 // Test that nomral, maximize, normal will repos the remaining. 1185 // Test that nomral, maximize, normal will repos the remaining.
1177 TEST_F(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) { 1186 TEST_P(WorkspaceControllerTest, NormToMaxToNormRepositionsRemaining) {
1178 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1187 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1179 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1188 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1180 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); 1189 wm::WindowState* window1_state = wm::GetWindowState(window1.get());
1181 window1_state->set_window_position_managed(true); 1190 window1_state->set_window_position_managed(true);
1182 gfx::Rect desktop_area = window1->parent()->bounds(); 1191 gfx::Rect desktop_area = window1->parent()->bounds();
1183 1192
1184 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1193 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1185 wm::GetWindowState(window2.get())->set_window_position_managed(true); 1194 wm::GetWindowState(window2.get())->set_window_position_managed(true);
1186 window2->SetBounds(gfx::Rect(32, 40, 256, 512)); 1195 window2->SetBounds(gfx::Rect(32, 40, 256, 512));
1187 1196
(...skipping 13 matching lines...) Expand all
1201 1210
1202 // |window1| should be flush right and |window2| flush left. 1211 // |window1| should be flush right and |window2| flush left.
1203 EXPECT_EQ( 1212 EXPECT_EQ(
1204 base::IntToString(desktop_area.width() - window1->bounds().width()) + 1213 base::IntToString(desktop_area.width() - window1->bounds().width()) +
1205 ",32 640x320", 1214 ",32 640x320",
1206 window1->bounds().ToString()); 1215 window1->bounds().ToString());
1207 EXPECT_EQ("0,40 256x512", window2->bounds().ToString()); 1216 EXPECT_EQ("0,40 256x512", window2->bounds().ToString());
1208 } 1217 }
1209 1218
1210 // Test that animations are triggered. 1219 // Test that animations are triggered.
1211 TEST_F(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) { 1220 TEST_P(WorkspaceControllerTest, AnimatedNormToMaxToNormRepositionsRemaining) {
1212 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1221 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1213 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1222 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1214 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); 1223 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0));
1215 window1->Hide(); 1224 window1->Hide();
1216 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); 1225 window1->SetBounds(gfx::Rect(16, 32, 640, 320));
1217 gfx::Rect desktop_area = window1->parent()->bounds(); 1226 gfx::Rect desktop_area = window1->parent()->bounds();
1218 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1)); 1227 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(1));
1219 window2->Hide(); 1228 window2->Hide();
1220 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); 1229 window2->SetBounds(gfx::Rect(32, 48, 256, 512));
1221 1230
(...skipping 21 matching lines...) Expand all
1243 ",32 640x320", 1252 ",32 640x320",
1244 window1->bounds().ToString()); 1253 window1->bounds().ToString());
1245 EXPECT_EQ("0,48 256x512", window2->bounds().ToString()); 1254 EXPECT_EQ("0,48 256x512", window2->bounds().ToString());
1246 } 1255 }
1247 1256
1248 // This tests simulates a browser and an app and verifies the ordering of the 1257 // 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 1258 // 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 1259 // 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 1260 // with a real browser the browser here has a transient child window
1252 // (corresponds to the status bubble). 1261 // (corresponds to the status bubble).
1253 TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) { 1262 TEST_P(WorkspaceControllerTest, VerifyLayerOrdering) {
1254 std::unique_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate( 1263 std::unique_ptr<Window> browser(aura::test::CreateTestWindowWithDelegate(
1255 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL)); 1264 NULL, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 6, 7, 8), NULL));
1256 browser->SetName("browser"); 1265 browser->SetName("browser");
1257 ParentWindowInPrimaryRootWindow(browser.get()); 1266 ParentWindowInPrimaryRootWindow(browser.get());
1258 browser->Show(); 1267 browser->Show();
1259 wm::ActivateWindow(browser.get()); 1268 wm::ActivateWindow(browser.get());
1260 1269
1261 // |status_bubble| is made a transient child of |browser| and as a result 1270 // |status_bubble| is made a transient child of |browser| and as a result
1262 // owned by |browser|. 1271 // owned by |browser|.
1263 aura::test::TestWindowDelegate* status_bubble_delegate = 1272 aura::test::TestWindowDelegate* status_bubble_delegate =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 aura::Window* window_; 1354 aura::Window* window_;
1346 1355
1347 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); 1356 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver);
1348 }; 1357 };
1349 1358
1350 } // namespace 1359 } // namespace
1351 1360
1352 // Verifies that a new maximized window becomes visible after its activation 1361 // Verifies that a new maximized window becomes visible after its activation
1353 // is requested, even though it does not become activated because a system 1362 // is requested, even though it does not become activated because a system
1354 // modal window is active. 1363 // modal window is active.
1355 TEST_F(WorkspaceControllerTest, SwitchFromModal) { 1364 TEST_P(WorkspaceControllerTest, SwitchFromModal) {
1356 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented()); 1365 std::unique_ptr<Window> modal_window(CreateTestWindowUnparented());
1357 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); 1366 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22));
1358 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 1367 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
1359 ParentWindowInPrimaryRootWindow(modal_window.get()); 1368 ParentWindowInPrimaryRootWindow(modal_window.get());
1360 modal_window->Show(); 1369 modal_window->Show();
1361 wm::ActivateWindow(modal_window.get()); 1370 wm::ActivateWindow(modal_window.get());
1362 1371
1363 std::unique_ptr<Window> maximized_window(CreateTestWindow()); 1372 std::unique_ptr<Window> maximized_window(CreateTestWindow());
1364 maximized_window->SetProperty(aura::client::kShowStateKey, 1373 maximized_window->SetProperty(aura::client::kShowStateKey,
1365 ui::SHOW_STATE_MAXIMIZED); 1374 ui::SHOW_STATE_MAXIMIZED);
(...skipping 12 matching lines...) Expand all
1378 ~WorkspaceControllerTestDragging() override {} 1387 ~WorkspaceControllerTestDragging() override {}
1379 1388
1380 private: 1389 private:
1381 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging); 1390 DISALLOW_COPY_AND_ASSIGN(WorkspaceControllerTestDragging);
1382 }; 1391 };
1383 1392
1384 } // namespace 1393 } // namespace
1385 1394
1386 // Verifies that when dragging a window over the shelf overlap is detected 1395 // Verifies that when dragging a window over the shelf overlap is detected
1387 // during and after the drag. 1396 // during and after the drag.
1388 TEST_F(WorkspaceControllerTestDragging, DragWindowOverlapShelf) { 1397 TEST_P(WorkspaceControllerTestDragging, DragWindowOverlapShelf) {
1389 aura::test::TestWindowDelegate delegate; 1398 aura::test::TestWindowDelegate delegate;
1390 delegate.set_window_component(HTCAPTION); 1399 delegate.set_window_component(HTCAPTION);
1391 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( 1400 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate(
1392 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); 1401 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL));
1393 ParentWindowInPrimaryRootWindow(w1.get()); 1402 ParentWindowInPrimaryRootWindow(w1.get());
1394 1403
1395 Shelf* shelf = Shelf::ForPrimaryDisplay(); 1404 Shelf* shelf = Shelf::ForPrimaryDisplay();
1396 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1405 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1397 1406
1398 // Drag near the shelf. 1407 // Drag near the shelf.
1399 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1408 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1400 gfx::Point()); 1409 gfx::Point());
1401 generator.MoveMouseTo(10, 10); 1410 generator.MoveMouseTo(10, 10);
1402 generator.PressLeftButton(); 1411 generator.PressLeftButton();
1403 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70); 1412 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 70);
1404 1413
1405 // Shelf should not be in overlapped state. 1414 // Shelf should not be in overlapped state.
1406 EXPECT_FALSE(GetWindowOverlapsShelf()); 1415 EXPECT_FALSE(GetWindowOverlapsShelf());
1407 1416
1408 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20); 1417 generator.MoveMouseTo(100, shelf_layout_manager()->GetIdealBounds().y() - 20);
1409 1418
1410 // Shelf should detect overlap. Overlap state stays after mouse is released. 1419 // Shelf should detect overlap. Overlap state stays after mouse is released.
1411 EXPECT_TRUE(GetWindowOverlapsShelf()); 1420 EXPECT_TRUE(GetWindowOverlapsShelf());
1412 generator.ReleaseLeftButton(); 1421 generator.ReleaseLeftButton();
1413 EXPECT_TRUE(GetWindowOverlapsShelf()); 1422 EXPECT_TRUE(GetWindowOverlapsShelf());
1414 } 1423 }
1415 1424
1416 // Verifies that when dragging a window autohidden shelf stays hidden during 1425 // Verifies that when dragging a window autohidden shelf stays hidden during
1417 // and after the drag. 1426 // and after the drag.
1418 TEST_F(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) { 1427 TEST_P(WorkspaceControllerTestDragging, DragWindowKeepsShelfAutohidden) {
1419 aura::test::TestWindowDelegate delegate; 1428 aura::test::TestWindowDelegate delegate;
1420 delegate.set_window_component(HTCAPTION); 1429 delegate.set_window_component(HTCAPTION);
1421 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate( 1430 std::unique_ptr<Window> w1(aura::test::CreateTestWindowWithDelegate(
1422 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL)); 1431 &delegate, ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(5, 5, 100, 50), NULL));
1423 ParentWindowInPrimaryRootWindow(w1.get()); 1432 ParentWindowInPrimaryRootWindow(w1.get());
1424 1433
1425 Shelf* shelf = Shelf::ForPrimaryDisplay(); 1434 Shelf* shelf = Shelf::ForPrimaryDisplay();
1426 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1435 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1427 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1428 1437
1429 // Drag very little. 1438 // Drag very little.
1430 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1439 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1431 gfx::Point()); 1440 gfx::Point());
1432 generator.MoveMouseTo(10, 10); 1441 generator.MoveMouseTo(10, 10);
1433 generator.PressLeftButton(); 1442 generator.PressLeftButton();
1434 generator.MoveMouseTo(12, 12); 1443 generator.MoveMouseTo(12, 12);
1435 1444
1436 // Shelf should be hidden during and after the drag. 1445 // Shelf should be hidden during and after the drag.
1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1446 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1438 generator.ReleaseLeftButton(); 1447 generator.ReleaseLeftButton();
1439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1448 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1440 } 1449 }
1441 1450
1442 // Verifies that events are targeted properly just outside the window edges. 1451 // Verifies that events are targeted properly just outside the window edges.
1443 TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) { 1452 TEST_P(WorkspaceControllerTest, WindowEdgeHitTest) {
1444 aura::test::TestWindowDelegate d_first, d_second; 1453 aura::test::TestWindowDelegate d_first, d_second;
1445 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate( 1454 std::unique_ptr<Window> first(aura::test::CreateTestWindowWithDelegate(
1446 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL)); 1455 &d_first, 123, gfx::Rect(20, 10, 100, 50), NULL));
1447 ParentWindowInPrimaryRootWindow(first.get()); 1456 ParentWindowInPrimaryRootWindow(first.get());
1448 first->Show(); 1457 first->Show();
1449 1458
1450 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate( 1459 std::unique_ptr<Window> second(aura::test::CreateTestWindowWithDelegate(
1451 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL)); 1460 &d_second, 234, gfx::Rect(30, 40, 40, 10), NULL));
1452 ParentWindowInPrimaryRootWindow(second.get()); 1461 ParentWindowInPrimaryRootWindow(second.get());
1453 second->Show(); 1462 second->Show();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } 1499 }
1491 // Apply a transform on |second|. After the transform is applied, the window 1500 // Apply a transform on |second|. After the transform is applied, the window
1492 // should no longer be targeted. 1501 // should no longer be targeted.
1493 gfx::Transform transform; 1502 gfx::Transform transform;
1494 transform.Translate(70, 40); 1503 transform.Translate(70, 40);
1495 second->SetTransform(transform); 1504 second->SetTransform(transform);
1496 } 1505 }
1497 } 1506 }
1498 1507
1499 // Verifies mouse event targeting just outside the window edges for panels. 1508 // Verifies mouse event targeting just outside the window edges for panels.
1500 TEST_F(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) { 1509 TEST_P(WorkspaceControllerTest, WindowEdgeMouseHitTestPanel) {
1501 aura::test::TestWindowDelegate delegate; 1510 aura::test::TestWindowDelegate delegate;
1502 std::unique_ptr<Window> window( 1511 std::unique_ptr<Window> window(
1503 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); 1512 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50)));
1504 ui::EventTarget* root = window->GetRootWindow(); 1513 ui::EventTarget* root = window->GetRootWindow();
1505 ui::EventTargeter* targeter = root->GetEventTargeter(); 1514 ui::EventTargeter* targeter = root->GetEventTargeter();
1506 const gfx::Rect bounds = window->bounds(); 1515 const gfx::Rect bounds = window->bounds();
1507 const int kNumPoints = 5; 1516 const int kNumPoints = 5;
1508 struct { 1517 struct {
1509 const char* direction; 1518 const char* direction;
1510 gfx::Point location; 1519 gfx::Point location;
(...skipping 15 matching lines...) Expand all
1526 EXPECT_EQ(window.get(), target); 1535 EXPECT_EQ(window.get(), target);
1527 else 1536 else
1528 EXPECT_NE(window.get(), target); 1537 EXPECT_NE(window.get(), target);
1529 } 1538 }
1530 } 1539 }
1531 1540
1532 // Verifies touch event targeting just outside the window edges for panels. 1541 // 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 1542 // 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 1543 // the bottom edge of the panel should not target the panel itself because
1535 // an AttachedPanelWindowTargeter is installed on the panel container. 1544 // an AttachedPanelWindowTargeter is installed on the panel container.
1536 TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) { 1545 TEST_P(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) {
1537 aura::test::TestWindowDelegate delegate; 1546 aura::test::TestWindowDelegate delegate;
1538 std::unique_ptr<Window> window( 1547 std::unique_ptr<Window> window(
1539 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50))); 1548 CreateTestPanel(&delegate, gfx::Rect(20, 10, 100, 50)));
1540 ui::EventTarget* root = window->GetRootWindow(); 1549 ui::EventTarget* root = window->GetRootWindow();
1541 ui::EventTargeter* targeter = root->GetEventTargeter(); 1550 ui::EventTargeter* targeter = root->GetEventTargeter();
1542 const gfx::Rect bounds = window->bounds(); 1551 const gfx::Rect bounds = window->bounds();
1543 const int kNumPoints = 5; 1552 const int kNumPoints = 5;
1544 struct { 1553 struct {
1545 const char* direction; 1554 const char* direction;
1546 gfx::Point location; 1555 gfx::Point location;
(...skipping 12 matching lines...) Expand all
1559 ui::EventTimeForNow()); 1568 ui::EventTimeForNow());
1560 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch); 1569 ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch);
1561 if (points[i].is_target_hit) 1570 if (points[i].is_target_hit)
1562 EXPECT_EQ(window.get(), target); 1571 EXPECT_EQ(window.get(), target);
1563 else 1572 else
1564 EXPECT_NE(window.get(), target); 1573 EXPECT_NE(window.get(), target);
1565 } 1574 }
1566 } 1575 }
1567 1576
1568 // Verifies events targeting just outside the window edges for docked windows. 1577 // Verifies events targeting just outside the window edges for docked windows.
1569 TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) { 1578 TEST_P(WorkspaceControllerTest, WindowEdgeHitTestDocked) {
1570 aura::test::TestWindowDelegate delegate; 1579 aura::test::TestWindowDelegate delegate;
1571 // Make window smaller than the minimum docked area so that the window edges 1580 // Make window smaller than the minimum docked area so that the window edges
1572 // are exposed. 1581 // are exposed.
1573 delegate.set_maximum_size(gfx::Size(180, 200)); 1582 delegate.set_maximum_size(gfx::Size(180, 200));
1574 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate( 1583 std::unique_ptr<Window> window(aura::test::CreateTestWindowWithDelegate(
1575 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL)); 1584 &delegate, 123, gfx::Rect(20, 10, 100, 50), NULL));
1576 ParentWindowInPrimaryRootWindow(window.get()); 1585 ParentWindowInPrimaryRootWindow(window.get());
1577 aura::Window* docked_container = Shell::GetContainer( 1586 aura::Window* docked_container = Shell::GetContainer(
1578 window->GetRootWindow(), kShellWindowId_DockedContainer); 1587 window->GetRootWindow(), kShellWindowId_DockedContainer);
1579 docked_container->AddChild(window.get()); 1588 docked_container->AddChild(window.get());
(...skipping 28 matching lines...) Expand all
1608 ui::EventTimeForNow()); 1617 ui::EventTimeForNow());
1609 target = targeter->FindTargetForEvent(root, &touch); 1618 target = targeter->FindTargetForEvent(root, &touch);
1610 if (points[i].is_target_hit) 1619 if (points[i].is_target_hit)
1611 EXPECT_EQ(window.get(), target); 1620 EXPECT_EQ(window.get(), target);
1612 else 1621 else
1613 EXPECT_NE(window.get(), target); 1622 EXPECT_NE(window.get(), target);
1614 } 1623 }
1615 } 1624 }
1616 1625
1617 } // namespace ash 1626 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698