OLD | NEW |
---|---|
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/drag_drop/drag_drop_controller.h" | 5 #include "ash/drag_drop/drag_drop_controller.h" |
6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { | 148 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { |
149 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1); | 149 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1); |
150 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2); | 150 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2); |
151 return window1_bounds.Intersects(window2_bounds); | 151 return window1_bounds.Intersects(window2_bounds); |
152 } | 152 } |
153 | 153 |
154 void ToggleOverview() { | 154 void ToggleOverview() { |
155 ash::Shell::GetInstance()->window_selector_controller()->ToggleOverview(); | 155 ash::Shell::GetInstance()->window_selector_controller()->ToggleOverview(); |
156 } | 156 } |
157 | 157 |
158 void Cycle(WindowSelector::Direction direction) { | |
159 ash::Shell::GetInstance()->window_selector_controller()-> | |
160 HandleCycleWindow(direction); | |
161 } | |
162 | |
163 void StopCycling() { | |
164 ash::Shell::GetInstance()->window_selector_controller()->window_selector_-> | |
165 SelectWindow(); | |
166 } | |
167 | |
168 void FireOverviewStartTimer() { | 158 void FireOverviewStartTimer() { |
169 // Calls the method to start overview mode which is normally called by the | 159 // Calls the method to start overview mode which is normally called by the |
170 // timer. The timer will still fire and call this method triggering the | 160 // timer. The timer will still fire and call this method triggering the |
171 // DCHECK that overview mode was not already started, except that we call | 161 // DCHECK that overview mode was not already started, except that we call |
172 // StopCycling before the timer has a chance to fire. | 162 // StopCycling before the timer has a chance to fire. |
173 ash::Shell::GetInstance()->window_selector_controller()->window_selector_-> | 163 ash::Shell::GetInstance()->window_selector_controller()->window_selector_-> |
174 StartOverview(); | 164 StartOverview(); |
175 } | 165 } |
176 | 166 |
177 gfx::Transform GetTransformRelativeTo(gfx::PointF origin, | 167 gfx::Transform GetTransformRelativeTo(gfx::PointF origin, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 311 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
322 EXPECT_FALSE(panel1->IsVisible()); | 312 EXPECT_FALSE(panel1->IsVisible()); |
323 | 313 |
324 // Entering overview and selecting another window, the previous window remains | 314 // Entering overview and selecting another window, the previous window remains |
325 // fullscreen. | 315 // fullscreen. |
326 // TODO(flackr): Currently the panel remains hidden, but should become visible | 316 // TODO(flackr): Currently the panel remains hidden, but should become visible |
327 // again. | 317 // again. |
328 ToggleOverview(); | 318 ToggleOverview(); |
329 ClickWindow(window2.get()); | 319 ClickWindow(window2.get()); |
330 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 320 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
331 | |
332 // Verify that selecting the panel will make it visible. | |
333 // TODO(flackr): Click on panel rather than cycle to it when | |
334 // clicking on panels is fixed, see http://crbug.com/339834. | |
335 Cycle(WindowSelector::FORWARD); | |
336 Cycle(WindowSelector::FORWARD); | |
337 StopCycling(); | |
338 EXPECT_TRUE(wm::GetWindowState(panel1.get())->IsActive()); | |
339 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | |
340 EXPECT_TRUE(panel1->IsVisible()); | |
341 } | 321 } |
342 | 322 |
343 // Tests that the shelf dimming state is removed while in overview and restored | 323 // Tests that the shelf dimming state is removed while in overview and restored |
344 // on exiting overview. | 324 // on exiting overview. |
345 TEST_F(WindowSelectorTest, OverviewUndimsShelf) { | 325 TEST_F(WindowSelectorTest, OverviewUndimsShelf) { |
346 gfx::Rect bounds(0, 0, 400, 400); | 326 gfx::Rect bounds(0, 0, 400, 400); |
347 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 327 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
348 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 328 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
349 window_state->Maximize(); | 329 window_state->Maximize(); |
350 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); | 330 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); |
351 EXPECT_TRUE(shelf->GetDimsShelf()); | 331 EXPECT_TRUE(shelf->GetDimsShelf()); |
352 ToggleOverview(); | 332 ToggleOverview(); |
353 EXPECT_FALSE(shelf->GetDimsShelf()); | 333 EXPECT_FALSE(shelf->GetDimsShelf()); |
354 ToggleOverview(); | 334 ToggleOverview(); |
355 EXPECT_TRUE(shelf->GetDimsShelf()); | 335 EXPECT_TRUE(shelf->GetDimsShelf()); |
356 } | 336 } |
357 | 337 |
358 // Tests that beginning window selection hides the app list. | 338 // Tests that beginning window selection hides the app list. |
359 TEST_F(WindowSelectorTest, SelectingHidesAppList) { | 339 TEST_F(WindowSelectorTest, SelectingHidesAppList) { |
360 gfx::Rect bounds(0, 0, 400, 400); | 340 gfx::Rect bounds(0, 0, 400, 400); |
361 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 341 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
362 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 342 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
363 Shell::GetInstance()->ToggleAppList(NULL); | 343 Shell::GetInstance()->ToggleAppList(NULL); |
364 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 344 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
365 ToggleOverview(); | 345 ToggleOverview(); |
366 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 346 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
367 ToggleOverview(); | 347 ToggleOverview(); |
368 | |
369 // The app list uses an animation to fade out. If it is toggled on immediately | |
370 // after being removed the old widget is re-used and it does not gain focus. | |
371 // When running under normal circumstances this shouldn't be possible, but | |
372 // it is in a test without letting the message loop run. | |
373 RunAllPendingInMessageLoop(); | |
374 | |
375 Shell::GetInstance()->ToggleAppList(NULL); | |
376 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | |
377 Cycle(WindowSelector::FORWARD); | |
378 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | |
379 StopCycling(); | |
380 } | 348 } |
381 | 349 |
382 // Tests that a minimized window's visibility and layer visibility is correctly | 350 // Tests that a minimized window's visibility and layer visibility is correctly |
383 // changed when entering overview and restored when leaving overview mode. | 351 // changed when entering overview and restored when leaving overview mode. |
384 TEST_F(WindowSelectorTest, MinimizedWindowVisibility) { | 352 TEST_F(WindowSelectorTest, MinimizedWindowVisibility) { |
385 gfx::Rect bounds(0, 0, 400, 400); | 353 gfx::Rect bounds(0, 0, 400, 400); |
386 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 354 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
387 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 355 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
388 window_state->Minimize(); | 356 window_state->Minimize(); |
389 EXPECT_FALSE(window1->IsVisible()); | 357 EXPECT_FALSE(window1->IsVisible()); |
(...skipping 23 matching lines...) Expand all Loading... | |
413 window->SetBounds(gfx::Rect(200, 0, 200, 200)); | 381 window->SetBounds(gfx::Rect(200, 0, 200, 200)); |
414 gfx::Rect new_overview_bounds = | 382 gfx::Rect new_overview_bounds = |
415 ToEnclosingRect(GetTransformedTargetBounds(window.get())); | 383 ToEnclosingRect(GetTransformedTargetBounds(window.get())); |
416 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); | 384 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); |
417 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); | 385 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); |
418 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); | 386 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); |
419 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); | 387 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); |
420 ToggleOverview(); | 388 ToggleOverview(); |
421 } | 389 } |
422 | 390 |
423 // Tests entering overview mode with three windows and cycling through them. | 391 /*// Tests the visibility of panel windows during cycling. |
424 TEST_F(WindowSelectorTest, BasicCycle) { | |
425 gfx::Rect bounds(0, 0, 400, 400); | |
426 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
427 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
428 scoped_ptr<aura::Window> window3(CreateWindow(bounds)); | |
429 wm::ActivateWindow(window3.get()); | |
430 wm::ActivateWindow(window2.get()); | |
431 wm::ActivateWindow(window1.get()); | |
432 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
433 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | |
434 EXPECT_FALSE(wm::IsActiveWindow(window3.get())); | |
435 | |
436 Cycle(WindowSelector::FORWARD); | |
437 EXPECT_TRUE(IsSelecting()); | |
438 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
439 | |
440 Cycle(WindowSelector::FORWARD); | |
441 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
442 | |
443 StopCycling(); | |
444 EXPECT_FALSE(IsSelecting()); | |
445 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | |
446 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | |
447 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
448 } | |
449 | |
450 // Tests that cycling through windows preserves the window stacking order. | |
451 TEST_F(WindowSelectorTest, CyclePreservesStackingOrder) { | |
452 gfx::Rect bounds(0, 0, 400, 400); | |
453 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
454 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
455 scoped_ptr<aura::Window> window3(CreateWindow(bounds)); | |
456 wm::ActivateWindow(window3.get()); | |
457 wm::ActivateWindow(window2.get()); | |
458 wm::ActivateWindow(window1.get()); | |
459 // Window order from top to bottom is 1, 2, 3. | |
460 EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get())); | |
461 EXPECT_TRUE(IsWindowAbove(window2.get(), window3.get())); | |
462 | |
463 // On window 2. | |
464 Cycle(WindowSelector::FORWARD); | |
465 EXPECT_TRUE(IsWindowAbove(window2.get(), window1.get())); | |
466 EXPECT_TRUE(IsWindowAbove(window1.get(), window3.get())); | |
467 | |
468 // On window 3. | |
469 Cycle(WindowSelector::FORWARD); | |
470 EXPECT_TRUE(IsWindowAbove(window3.get(), window1.get())); | |
471 EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get())); | |
472 | |
473 // Back on window 1. | |
474 Cycle(WindowSelector::FORWARD); | |
475 EXPECT_TRUE(IsWindowAbove(window1.get(), window2.get())); | |
476 EXPECT_TRUE(IsWindowAbove(window2.get(), window3.get())); | |
477 StopCycling(); | |
478 } | |
479 | |
480 // Tests that cycling through windows shows and minimizes windows as they | |
481 // are passed. | |
482 TEST_F(WindowSelectorTest, CyclePreservesMinimization) { | |
483 gfx::Rect bounds(0, 0, 400, 400); | |
484 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
485 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
486 wm::ActivateWindow(window2.get()); | |
487 wm::GetWindowState(window2.get())->Minimize(); | |
488 wm::ActivateWindow(window1.get()); | |
489 EXPECT_TRUE(wm::IsWindowMinimized(window2.get())); | |
490 | |
491 // On window 2. | |
492 Cycle(WindowSelector::FORWARD); | |
493 EXPECT_FALSE(wm::IsWindowMinimized(window2.get())); | |
494 | |
495 // Back on window 1. | |
496 Cycle(WindowSelector::FORWARD); | |
497 EXPECT_TRUE(wm::IsWindowMinimized(window2.get())); | |
498 | |
499 StopCycling(); | |
500 EXPECT_TRUE(wm::IsWindowMinimized(window2.get())); | |
501 } | |
502 | |
503 // Tests beginning cycling while in overview mode. | |
504 TEST_F(WindowSelectorTest, OverviewTransitionToCycle) { | |
505 gfx::Rect bounds(0, 0, 400, 400); | |
506 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
507 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
508 wm::ActivateWindow(window2.get()); | |
509 wm::ActivateWindow(window1.get()); | |
510 | |
511 ToggleOverview(); | |
512 Cycle(WindowSelector::FORWARD); | |
513 StopCycling(); | |
514 | |
515 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
516 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | |
517 EXPECT_EQ(window2.get(), GetFocusedWindow()); | |
518 } | |
519 | |
520 // Tests cycles between panel and normal windows. | |
521 TEST_F(WindowSelectorTest, CyclePanels) { | |
522 gfx::Rect bounds(0, 0, 400, 400); | |
523 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
524 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
525 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | |
526 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); | |
527 wm::ActivateWindow(window2.get()); | |
528 wm::ActivateWindow(window1.get()); | |
529 wm::ActivateWindow(panel2.get()); | |
530 wm::ActivateWindow(panel1.get()); | |
531 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); | |
532 | |
533 // Cycling once should select window1 since the panels are grouped into a | |
534 // single selectable item. | |
535 Cycle(WindowSelector::FORWARD); | |
536 StopCycling(); | |
537 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
538 | |
539 // Cycling again should select the most recently used panel. | |
540 Cycle(WindowSelector::FORWARD); | |
541 StopCycling(); | |
542 EXPECT_TRUE(wm::IsActiveWindow(panel1.get())); | |
543 } | |
544 | |
545 // Tests the visibility of panel windows during cycling. | |
546 TEST_F(WindowSelectorTest, CyclePanelVisibility) { | 392 TEST_F(WindowSelectorTest, CyclePanelVisibility) { |
547 gfx::Rect bounds(0, 0, 400, 400); | 393 gfx::Rect bounds(0, 0, 400, 400); |
548 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 394 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
549 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 395 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
550 wm::ActivateWindow(panel1.get()); | 396 wm::ActivateWindow(panel1.get()); |
551 wm::ActivateWindow(window1.get()); | 397 wm::ActivateWindow(window1.get()); |
552 | 398 |
553 Cycle(WindowSelector::FORWARD); | 399 Cycle(WindowSelector::FORWARD); |
554 FireOverviewStartTimer(); | 400 FireOverviewStartTimer(); |
555 EXPECT_EQ(1.0f, panel1->layer()->GetTargetOpacity()); | 401 EXPECT_EQ(1.0f, panel1->layer()->GetTargetOpacity()); |
556 StopCycling(); | 402 StopCycling(); |
557 } | 403 }*/ |
tdanderson
2014/05/01 18:51:39
Fix this.
Nina
2014/05/01 20:41:16
Done.
| |
558 | |
559 // Tests cycles between panel and normal windows. | |
560 TEST_F(WindowSelectorTest, CyclePanelsDestroyed) { | |
561 gfx::Rect bounds(0, 0, 400, 400); | |
562 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
563 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
564 scoped_ptr<aura::Window> window3(CreateWindow(bounds)); | |
565 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | |
566 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); | |
567 wm::ActivateWindow(window3.get()); | |
568 wm::ActivateWindow(panel2.get()); | |
569 wm::ActivateWindow(panel1.get()); | |
570 wm::ActivateWindow(window2.get()); | |
571 wm::ActivateWindow(window1.get()); | |
572 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
573 | |
574 // Cycling once highlights window2. | |
575 Cycle(WindowSelector::FORWARD); | |
576 // All panels are destroyed. | |
577 panel1.reset(); | |
578 panel2.reset(); | |
579 // Cycling again should now select window3. | |
580 Cycle(WindowSelector::FORWARD); | |
581 StopCycling(); | |
582 EXPECT_TRUE(wm::IsActiveWindow(window3.get())); | |
583 } | |
584 | |
585 // Tests cycles between panel and normal windows. | |
586 TEST_F(WindowSelectorTest, CycleMruPanelDestroyed) { | |
587 gfx::Rect bounds(0, 0, 400, 400); | |
588 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
589 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
590 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | |
591 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); | |
592 wm::ActivateWindow(panel2.get()); | |
593 wm::ActivateWindow(panel1.get()); | |
594 wm::ActivateWindow(window2.get()); | |
595 wm::ActivateWindow(window1.get()); | |
596 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
597 | |
598 // Cycling once highlights window2. | |
599 Cycle(WindowSelector::FORWARD); | |
600 // Panel 1 is the next item as the MRU panel, removing it should make panel 2 | |
601 // the next window to be selected. | |
602 panel1.reset(); | |
603 // Cycling again should now select window3. | |
604 Cycle(WindowSelector::FORWARD); | |
605 StopCycling(); | |
606 EXPECT_TRUE(wm::IsActiveWindow(panel2.get())); | |
607 } | |
608 | 404 |
609 // Tests that a newly created window aborts overview. | 405 // Tests that a newly created window aborts overview. |
610 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { | 406 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { |
611 gfx::Rect bounds(0, 0, 400, 400); | 407 gfx::Rect bounds(0, 0, 400, 400); |
612 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 408 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); |
613 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 409 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); |
614 ToggleOverview(); | 410 ToggleOverview(); |
615 EXPECT_TRUE(IsSelecting()); | 411 EXPECT_TRUE(IsSelecting()); |
616 | 412 |
617 // A window being created should exit overview mode. | 413 // A window being created should exit overview mode. |
(...skipping 12 matching lines...) Expand all Loading... | |
630 | 426 |
631 // A window being activated should exit overview mode. | 427 // A window being activated should exit overview mode. |
632 window1->Focus(); | 428 window1->Focus(); |
633 EXPECT_FALSE(IsSelecting()); | 429 EXPECT_FALSE(IsSelecting()); |
634 | 430 |
635 // window1 should be focused after exiting even though window2 was focused on | 431 // window1 should be focused after exiting even though window2 was focused on |
636 // entering overview because we exited due to an activation. | 432 // entering overview because we exited due to an activation. |
637 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 433 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
638 } | 434 } |
639 | 435 |
640 // Verifies that overview mode only begins after a delay when cycling. | |
641 TEST_F(WindowSelectorTest, CycleOverviewDelay) { | |
642 gfx::Rect bounds(0, 0, 400, 400); | |
643 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | |
644 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | |
645 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); | |
646 | |
647 // When cycling first starts, the windows will still be overlapping. | |
648 Cycle(WindowSelector::FORWARD); | |
649 EXPECT_TRUE(IsSelecting()); | |
650 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); | |
651 | |
652 // Once the overview timer fires, the windows should no longer overlap. | |
653 FireOverviewStartTimer(); | |
654 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); | |
655 StopCycling(); | |
656 } | |
657 | |
658 // Tests that exiting overview mode without selecting a window restores focus | 436 // Tests that exiting overview mode without selecting a window restores focus |
659 // to the previously focused window. | 437 // to the previously focused window. |
660 TEST_F(WindowSelectorTest, CancelRestoresFocus) { | 438 TEST_F(WindowSelectorTest, CancelRestoresFocus) { |
661 gfx::Rect bounds(0, 0, 400, 400); | 439 gfx::Rect bounds(0, 0, 400, 400); |
662 scoped_ptr<aura::Window> window(CreateWindow(bounds)); | 440 scoped_ptr<aura::Window> window(CreateWindow(bounds)); |
663 wm::ActivateWindow(window.get()); | 441 wm::ActivateWindow(window.get()); |
664 EXPECT_EQ(window.get(), GetFocusedWindow()); | 442 EXPECT_EQ(window.get(), GetFocusedWindow()); |
665 | 443 |
666 // In overview mode, focus should be removed. | 444 // In overview mode, focus should be removed. |
667 ToggleOverview(); | 445 ToggleOverview(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 ToEnclosingRect(GetTransformedTargetBounds(panel2.get())))); | 602 ToEnclosingRect(GetTransformedTargetBounds(panel2.get())))); |
825 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | 603 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( |
826 ToEnclosingRect(GetTransformedTargetBounds(panel3.get())))); | 604 ToEnclosingRect(GetTransformedTargetBounds(panel3.get())))); |
827 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | 605 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( |
828 ToEnclosingRect(GetTransformedTargetBounds(panel4.get())))); | 606 ToEnclosingRect(GetTransformedTargetBounds(panel4.get())))); |
829 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); | 607 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); |
830 EXPECT_TRUE(WindowsOverlapping(panel3.get(), panel4.get())); | 608 EXPECT_TRUE(WindowsOverlapping(panel3.get(), panel4.get())); |
831 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel3.get())); | 609 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel3.get())); |
832 } | 610 } |
833 | 611 |
834 // Verifies that the single display overview used during alt tab cycling uses | |
835 // the display of the selected window by default. | |
836 TEST_F(WindowSelectorTest, CycleOverviewUsesCurrentDisplay) { | |
837 if (!SupportsMultipleDisplays()) | |
838 return; | |
839 | |
840 UpdateDisplay("400x400,400x400"); | |
841 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
842 | |
843 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100))); | |
844 scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100))); | |
845 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | |
846 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | |
847 wm::ActivateWindow(window2.get()); | |
848 wm::ActivateWindow(window1.get()); | |
849 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow()); | |
850 | |
851 Cycle(WindowSelector::FORWARD); | |
852 FireOverviewStartTimer(); | |
853 | |
854 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
855 ToEnclosingRect(GetTransformedTargetBounds(window1.get())))); | |
856 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
857 ToEnclosingRect(GetTransformedTargetBounds(window2.get())))); | |
858 StopCycling(); | |
859 } | |
860 | |
861 // Verifies that the windows being shown on another display are copied. | |
862 TEST_F(WindowSelectorTest, CycleMultipleDisplaysCopiesWindows) { | |
863 if (!SupportsMultipleDisplays()) | |
864 return; | |
865 | |
866 UpdateDisplay("400x400,400x400"); | |
867 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
868 | |
869 gfx::Rect root1_rect(0, 0, 100, 100); | |
870 gfx::Rect root2_rect(450, 0, 100, 100); | |
871 scoped_ptr<aura::Window> unmoved1(CreateWindow(root2_rect)); | |
872 scoped_ptr<aura::Window> unmoved2(CreateWindow(root2_rect)); | |
873 scoped_ptr<aura::Window> moved1_trans_parent(CreateWindow(root1_rect)); | |
874 scoped_ptr<aura::Window> moved1(CreateWindow(root1_rect)); | |
875 unmoved1->SetName("unmoved1"); | |
876 unmoved2->SetName("unmoved2"); | |
877 moved1->SetName("moved1"); | |
878 moved1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | |
879 ::wm::AddTransientChild(moved1_trans_parent.get(), moved1.get()); | |
880 moved1_trans_parent->SetName("moved1_trans_parent"); | |
881 | |
882 EXPECT_EQ(root_windows[0], moved1->GetRootWindow()); | |
883 EXPECT_EQ(root_windows[0], moved1_trans_parent->GetRootWindow()); | |
884 EXPECT_EQ(root_windows[1], unmoved1->GetRootWindow()); | |
885 EXPECT_EQ(root_windows[1], unmoved2->GetRootWindow()); | |
886 wm::ActivateWindow(unmoved2.get()); | |
887 wm::ActivateWindow(unmoved1.get()); | |
888 | |
889 Cycle(WindowSelector::FORWARD); | |
890 FireOverviewStartTimer(); | |
891 | |
892 // All windows are moved to second root window. | |
893 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
894 ToEnclosingRect(GetTransformedTargetBounds(unmoved1.get())))); | |
895 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
896 ToEnclosingRect(GetTransformedTargetBounds(unmoved2.get())))); | |
897 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
898 ToEnclosingRect(GetTransformedTargetBounds(moved1.get())))); | |
899 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
900 ToEnclosingRect(GetTransformedTargetBounds(moved1_trans_parent.get())))); | |
901 | |
902 // unmoved1 and unmoved2 were already on the correct display and should not | |
903 // have been copied. | |
904 EXPECT_TRUE(!GetCopyWindow(unmoved1.get())); | |
905 EXPECT_TRUE(!GetCopyWindow(unmoved2.get())); | |
906 | |
907 // moved1 and its transient parent moved1_trans_parent should have also been | |
908 // copied for displaying on root_windows[1]. | |
909 aura::Window* copy1 = GetCopyWindow(moved1.get()); | |
910 aura::Window* copy1_trans_parent = GetCopyWindow(moved1_trans_parent.get()); | |
911 ASSERT_FALSE(!copy1); | |
912 ASSERT_FALSE(!copy1_trans_parent); | |
913 | |
914 // Verify that the bounds and transform of the copy match the original window | |
915 // but that it is on the other root window. | |
916 EXPECT_EQ(root_windows[1], copy1->GetRootWindow()); | |
917 EXPECT_EQ(moved1->GetBoundsInScreen().ToString(), | |
918 copy1->GetBoundsInScreen().ToString()); | |
919 EXPECT_EQ(moved1->layer()->GetTargetTransform().ToString(), | |
920 copy1->layer()->GetTargetTransform().ToString()); | |
921 StopCycling(); | |
922 | |
923 // After cycling the copy windows should have been destroyed. | |
924 RunAllPendingInMessageLoop(); | |
925 EXPECT_TRUE(!GetCopyWindow(moved1.get())); | |
926 EXPECT_TRUE(!GetCopyWindow(moved1_trans_parent.get())); | |
927 } | |
928 | |
929 // Tests that beginning to cycle from overview mode moves windows to the | |
930 // active display. | |
931 TEST_F(WindowSelectorTest, MultipleDisplaysOverviewTransitionToCycle) { | |
932 if (!SupportsMultipleDisplays()) | |
933 return; | |
934 | |
935 UpdateDisplay("400x400,400x400"); | |
936 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
937 | |
938 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100))); | |
939 scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100))); | |
940 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | |
941 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | |
942 wm::ActivateWindow(window2.get()); | |
943 wm::ActivateWindow(window1.get()); | |
944 | |
945 ToggleOverview(); | |
946 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( | |
947 ToEnclosingRect(GetTransformedTargetBounds(window1.get())))); | |
948 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains( | |
949 ToEnclosingRect(GetTransformedTargetBounds(window2.get())))); | |
950 | |
951 Cycle(WindowSelector::FORWARD); | |
952 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( | |
953 ToEnclosingRect(GetTransformedTargetBounds(window1.get())))); | |
954 EXPECT_TRUE(root_windows[0]->GetBoundsInScreen().Contains( | |
955 ToEnclosingRect(GetTransformedTargetBounds(window2.get())))); | |
956 StopCycling(); | |
957 } | |
958 | |
959 // Tests that a bounds change during overview is corrected for. | |
960 TEST_F(WindowSelectorTest, BoundsChangeDuringCycleOnOtherDisplay) { | |
961 if (!SupportsMultipleDisplays()) | |
962 return; | |
963 | |
964 UpdateDisplay("400x400,400x400"); | |
965 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
966 | |
967 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 100, 100))); | |
968 scoped_ptr<aura::Window> window2(CreateWindow(gfx::Rect(450, 0, 100, 100))); | |
969 scoped_ptr<aura::Window> window3(CreateWindow(gfx::Rect(450, 0, 100, 100))); | |
970 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | |
971 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | |
972 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); | |
973 wm::ActivateWindow(window1.get()); | |
974 wm::ActivateWindow(window2.get()); | |
975 wm::ActivateWindow(window3.get()); | |
976 | |
977 Cycle(WindowSelector::FORWARD); | |
978 FireOverviewStartTimer(); | |
979 | |
980 gfx::Rect overview_bounds( | |
981 ToEnclosingRect(GetTransformedTargetBounds(window1.get()))); | |
982 EXPECT_TRUE(root_windows[1]->GetBoundsInScreen().Contains(overview_bounds)); | |
983 | |
984 // Change the position and size of window1 (being displayed on the second | |
985 // root window) and it should remain within the same bounds. | |
986 window1->SetBounds(gfx::Rect(100, 0, 200, 200)); | |
987 gfx::Rect new_overview_bounds = | |
988 ToEnclosingRect(GetTransformedTargetBounds(window1.get())); | |
989 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); | |
990 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); | |
991 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); | |
992 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); | |
993 StopCycling(); | |
994 } | |
995 | |
996 // Tests shutting down during overview. | 612 // Tests shutting down during overview. |
997 TEST_F(WindowSelectorTest, Shutdown) { | 613 TEST_F(WindowSelectorTest, Shutdown) { |
998 gfx::Rect bounds(0, 0, 400, 400); | 614 gfx::Rect bounds(0, 0, 400, 400); |
999 // These windows will be deleted when the test exits and the Shell instance | 615 // These windows will be deleted when the test exits and the Shell instance |
1000 // is shut down. | 616 // is shut down. |
1001 aura::Window* window1(CreateWindow(bounds)); | 617 aura::Window* window1(CreateWindow(bounds)); |
1002 aura::Window* window2(CreateWindow(bounds)); | 618 aura::Window* window2(CreateWindow(bounds)); |
1003 aura::Window* window3(CreatePanelWindow(bounds)); | 619 aura::Window* window3(CreatePanelWindow(bounds)); |
1004 aura::Window* window4(CreatePanelWindow(bounds)); | 620 aura::Window* window4(CreatePanelWindow(bounds)); |
1005 | 621 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 UpdateDisplay("600x200/r"); | 787 UpdateDisplay("600x200/r"); |
1172 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); | 788 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); |
1173 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); | 789 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); |
1174 iter != windows.end(); ++iter) { | 790 iter != windows.end(); ++iter) { |
1175 EXPECT_TRUE(root_window->bounds().Contains( | 791 EXPECT_TRUE(root_window->bounds().Contains( |
1176 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); | 792 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); |
1177 } | 793 } |
1178 } | 794 } |
1179 | 795 |
1180 } // namespace ash | 796 } // namespace ash |
OLD | NEW |