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