| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_table.h" | 7 #include "ash/common/accelerators/accelerator_table.h" |
| 8 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
| 9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 } | 441 } |
| 442 | 442 |
| 443 TEST_F(AcceleratorControllerTest, WindowSnap) { | 443 TEST_F(AcceleratorControllerTest, WindowSnap) { |
| 444 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 444 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 445 WmWindow* window = WmWindow::Get(aura_window); | 445 WmWindow* window = WmWindow::Get(aura_window); |
| 446 wm::WindowState* window_state = window->GetWindowState(); | 446 wm::WindowState* window_state = window->GetWindowState(); |
| 447 | 447 |
| 448 window_state->Activate(); | 448 window_state->Activate(); |
| 449 | 449 |
| 450 { | 450 { |
| 451 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 451 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| 452 gfx::Rect expected_bounds = | 452 gfx::Rect expected_bounds = |
| 453 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); | 453 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
| 454 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 454 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 455 } | 455 } |
| 456 { | 456 { |
| 457 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 457 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| 458 gfx::Rect expected_bounds = | 458 gfx::Rect expected_bounds = |
| 459 wm::GetDefaultRightSnappedWindowBoundsInParent(window); | 459 wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| 460 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 460 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 461 } | 461 } |
| 462 { | 462 { |
| 463 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); | 463 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
| 464 | 464 |
| 465 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); | 465 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| 466 EXPECT_TRUE(window_state->IsMaximized()); | 466 EXPECT_TRUE(window_state->IsMaximized()); |
| 467 EXPECT_NE(normal_bounds.ToString(), window->GetBounds().ToString()); | 467 EXPECT_NE(normal_bounds.ToString(), window->GetBounds().ToString()); |
| 468 | 468 |
| 469 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); | 469 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| 470 EXPECT_FALSE(window_state->IsMaximized()); | 470 EXPECT_FALSE(window_state->IsMaximized()); |
| 471 // Window gets restored to its restore bounds since side-maximized state | 471 // Window gets restored to its restore bounds since side-maximized state |
| 472 // is treated as a "maximized" state. | 472 // is treated as a "maximized" state. |
| 473 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); | 473 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| 474 | 474 |
| 475 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); | 475 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| 476 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 476 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| 477 EXPECT_FALSE(window_state->IsMaximized()); | 477 EXPECT_FALSE(window_state->IsMaximized()); |
| 478 | 478 |
| 479 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); | 479 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| 480 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 480 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| 481 EXPECT_FALSE(window_state->IsMaximized()); | 481 EXPECT_FALSE(window_state->IsMaximized()); |
| 482 | 482 |
| 483 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); | 483 GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| 484 EXPECT_TRUE(window_state->IsMaximized()); | 484 EXPECT_TRUE(window_state->IsMaximized()); |
| 485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| 486 EXPECT_FALSE(window_state->IsMaximized()); | 486 EXPECT_FALSE(window_state->IsMaximized()); |
| 487 EXPECT_TRUE(window_state->IsMinimized()); | 487 EXPECT_TRUE(window_state->IsMinimized()); |
| 488 window_state->Restore(); | 488 window_state->Restore(); |
| 489 window_state->Activate(); | 489 window_state->Activate(); |
| 490 } | 490 } |
| 491 { | 491 { |
| 492 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 492 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| 493 EXPECT_TRUE(window_state->IsMinimized()); | 493 EXPECT_TRUE(window_state->IsMinimized()); |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 | 496 |
| 497 // Tests that when window docking is disabled, only snapping windows works. | 497 // Tests that window snapping works. |
| 498 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { | 498 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { |
| 499 ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); | |
| 500 WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 499 WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 501 wm::WindowState* window_state = window->GetWindowState(); | 500 wm::WindowState* window_state = window->GetWindowState(); |
| 502 window_state->Activate(); | 501 window_state->Activate(); |
| 503 | 502 |
| 504 // Snap right. | 503 // Snap right. |
| 505 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 504 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| 506 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); | 505 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
| 507 gfx::Rect expected_bounds = | 506 gfx::Rect expected_bounds = |
| 508 wm::GetDefaultRightSnappedWindowBoundsInParent(window); | 507 wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| 509 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 508 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 510 EXPECT_TRUE(window_state->IsSnapped()); | 509 EXPECT_TRUE(window_state->IsSnapped()); |
| 511 // Snap right again ->> becomes normal. | 510 // Snap right again ->> becomes normal. |
| 512 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 511 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| 513 EXPECT_TRUE(window_state->IsNormalStateType()); | 512 EXPECT_TRUE(window_state->IsNormalStateType()); |
| 514 EXPECT_FALSE(window_state->IsDocked()); | |
| 515 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); | 513 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| 516 // Snap right. | 514 // Snap right. |
| 517 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 515 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| 518 EXPECT_TRUE(window_state->IsSnapped()); | 516 EXPECT_TRUE(window_state->IsSnapped()); |
| 519 EXPECT_FALSE(window_state->IsDocked()); | |
| 520 // Snap left. | 517 // Snap left. |
| 521 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 518 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| 522 EXPECT_TRUE(window_state->IsSnapped()); | 519 EXPECT_TRUE(window_state->IsSnapped()); |
| 523 EXPECT_FALSE(window_state->IsDocked()); | |
| 524 expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(window); | 520 expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
| 525 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 521 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 526 // Snap left again ->> becomes normal. | 522 // Snap left again ->> becomes normal. |
| 527 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 523 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| 528 EXPECT_TRUE(window_state->IsNormalStateType()); | 524 EXPECT_TRUE(window_state->IsNormalStateType()); |
| 529 EXPECT_FALSE(window_state->IsDocked()); | |
| 530 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); | 525 EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| 531 } | 526 } |
| 532 | 527 |
| 533 // Test class used for testing docked windows. | |
| 534 class EnabledDockedWindowsAcceleratorControllerTest | |
| 535 : public AcceleratorControllerTest { | |
| 536 public: | |
| 537 EnabledDockedWindowsAcceleratorControllerTest() = default; | |
| 538 ~EnabledDockedWindowsAcceleratorControllerTest() override = default; | |
| 539 | |
| 540 void SetUp() override { | |
| 541 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 542 ash::switches::kAshEnableDockedWindows); | |
| 543 AcceleratorControllerTest::SetUp(); | |
| 544 } | |
| 545 | |
| 546 private: | |
| 547 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); | |
| 548 }; | |
| 549 | |
| 550 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | |
| 551 WindowSnapLeftDockLeftRestore) { | |
| 552 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | |
| 553 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 554 wm::WindowState* window1_state = window1->GetWindowState(); | |
| 555 window1_state->Activate(); | |
| 556 | |
| 557 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 558 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | |
| 559 gfx::Rect expected_bounds = | |
| 560 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | |
| 561 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | |
| 562 EXPECT_TRUE(window1_state->IsSnapped()); | |
| 563 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 564 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | |
| 565 EXPECT_TRUE(window1_state->IsDocked()); | |
| 566 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 567 EXPECT_FALSE(window1_state->IsDocked()); | |
| 568 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | |
| 569 } | |
| 570 | |
| 571 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | |
| 572 WindowSnapRightDockRightRestore) { | |
| 573 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | |
| 574 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 575 | |
| 576 wm::WindowState* window1_state = window1->GetWindowState(); | |
| 577 window1_state->Activate(); | |
| 578 | |
| 579 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 580 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | |
| 581 gfx::Rect expected_bounds = | |
| 582 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | |
| 583 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | |
| 584 EXPECT_TRUE(window1_state->IsSnapped()); | |
| 585 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 586 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | |
| 587 EXPECT_TRUE(window1_state->IsDocked()); | |
| 588 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 589 EXPECT_FALSE(window1_state->IsDocked()); | |
| 590 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | |
| 591 } | |
| 592 | |
| 593 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | |
| 594 WindowSnapLeftDockLeftSnapRight) { | |
| 595 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | |
| 596 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 597 | |
| 598 wm::WindowState* window1_state = window1->GetWindowState(); | |
| 599 window1_state->Activate(); | |
| 600 | |
| 601 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 602 gfx::Rect expected_bounds = | |
| 603 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | |
| 604 gfx::Rect expected_bounds2 = | |
| 605 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | |
| 606 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | |
| 607 EXPECT_TRUE(window1_state->IsSnapped()); | |
| 608 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 609 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | |
| 610 EXPECT_TRUE(window1_state->IsDocked()); | |
| 611 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 612 EXPECT_FALSE(window1_state->IsDocked()); | |
| 613 EXPECT_TRUE(window1_state->IsSnapped()); | |
| 614 EXPECT_EQ(expected_bounds2.ToString(), window1->GetBounds().ToString()); | |
| 615 } | |
| 616 | |
| 617 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | |
| 618 WindowDockLeftMinimizeWindowWithRestore) { | |
| 619 WindowOwner window_owner( | |
| 620 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | |
| 621 WindowOwner window1_owner( | |
| 622 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | |
| 623 WmWindow* window1 = window1_owner.window(); | |
| 624 | |
| 625 wm::WindowState* window1_state = window1->GetWindowState(); | |
| 626 window1_state->Activate(); | |
| 627 | |
| 628 WindowOwner window2_owner( | |
| 629 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | |
| 630 WmWindow* window2 = window2_owner.window(); | |
| 631 | |
| 632 wm::WindowState* window2_state = window2->GetWindowState(); | |
| 633 | |
| 634 WindowOwner window3_owner( | |
| 635 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | |
| 636 WmWindow* window3 = window3_owner.window(); | |
| 637 | |
| 638 wm::WindowState* window3_state = window3->GetWindowState(); | |
| 639 window3_state->Activate(); | |
| 640 | |
| 641 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 642 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 643 gfx::Rect window3_docked_bounds = window3->GetBounds(); | |
| 644 | |
| 645 window2_state->Activate(); | |
| 646 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 647 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 648 window1_state->Activate(); | |
| 649 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 650 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 651 | |
| 652 EXPECT_TRUE(window3_state->IsDocked()); | |
| 653 EXPECT_TRUE(window2_state->IsDocked()); | |
| 654 EXPECT_TRUE(window1_state->IsDocked()); | |
| 655 EXPECT_TRUE(window3_state->IsMinimized()); | |
| 656 | |
| 657 window1_state->Activate(); | |
| 658 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 659 window2_state->Activate(); | |
| 660 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 661 window3_state->Unminimize(); | |
| 662 EXPECT_FALSE(window1_state->IsDocked()); | |
| 663 EXPECT_FALSE(window2_state->IsDocked()); | |
| 664 EXPECT_TRUE(window3_state->IsDocked()); | |
| 665 EXPECT_EQ(window3_docked_bounds.ToString(), window3->GetBounds().ToString()); | |
| 666 } | |
| 667 | |
| 668 // TODO: Needs CreatePanel(): http://crbug.com/632209. | |
| 669 /* | |
| 670 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | |
| 671 WindowPanelDockLeftDockRightRestore) { | |
| 672 WmWndow* window0 = | |
| 673 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 674 | |
| 675 std::unique_ptr<aura::Window> window(CreatePanel()); | |
| 676 wm::WindowState* window_state = wm::GetWindowState(window.get()); | |
| 677 window_state->Activate(); | |
| 678 | |
| 679 gfx::Rect window_restore_bounds2 = window->bounds(); | |
| 680 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | |
| 681 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( | |
| 682 WmWindow::Get(window.get())); | |
| 683 gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); | |
| 684 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); | |
| 685 EXPECT_FALSE(window_state->IsSnapped()); | |
| 686 EXPECT_FALSE(window_state->IsNormalOrSnapped()); | |
| 687 EXPECT_TRUE(window_state->IsDocked()); | |
| 688 window_state->Restore(); | |
| 689 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 690 EXPECT_TRUE(window_state->IsDocked()); | |
| 691 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | |
| 692 EXPECT_FALSE(window_state->IsDocked()); | |
| 693 EXPECT_EQ(window_restore_bounds.ToString(), | |
| 694 window_restore_bounds2.ToString()); | |
| 695 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); | |
| 696 } | |
| 697 */ | |
| 698 | |
| 699 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { | |
| 700 WindowOwner window_owner( | |
| 701 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | |
| 702 WmWindow* window = window_owner.window(); | |
| 703 wm::WindowState* window_state = window->GetWindowState(); | |
| 704 window_state->Activate(); | |
| 705 | |
| 706 // Center the window using accelerator. | |
| 707 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | |
| 708 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); | |
| 709 gfx::Rect bounds = window->GetBoundsInScreen(); | |
| 710 EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), | |
| 711 1); | |
| 712 EXPECT_NEAR(bounds.y() - work_area.y(), work_area.bottom() - bounds.bottom(), | |
| 713 1); | |
| 714 | |
| 715 // Add the window to docked container and try to center it. | |
| 716 window->SetBounds(gfx::Rect(0, 0, 20, 20)); | |
| 717 const wm::WMEvent event(wm::WM_EVENT_DOCK); | |
| 718 window->GetWindowState()->OnWMEvent(&event); | |
| 719 EXPECT_EQ(kShellWindowId_DockedContainer, | |
| 720 window->GetParent()->GetShellWindowId()); | |
| 721 | |
| 722 gfx::Rect docked_bounds = window->GetBoundsInScreen(); | |
| 723 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | |
| 724 // It should not get centered and should remain docked. | |
| 725 EXPECT_EQ(kShellWindowId_DockedContainer, | |
| 726 window->GetParent()->GetShellWindowId()); | |
| 727 EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString()); | |
| 728 } | |
| 729 | |
| 730 // This is commented out for two reasons: | 528 // This is commented out for two reasons: |
| 731 // . http://crbug.com/630683: ash doesn't see all key events. | 529 // . http://crbug.com/630683: ash doesn't see all key events. |
| 732 // . http://crbug.com/615033: EventGenerator doesn't work with ash. That can be | 530 // . http://crbug.com/615033: EventGenerator doesn't work with ash. That can be |
| 733 // worked around for the test, but no point until we decide on the first one. | 531 // worked around for the test, but no point until we decide on the first one. |
| 734 /* | 532 /* |
| 735 TEST_F(AcceleratorControllerTest, AutoRepeat) { | 533 TEST_F(AcceleratorControllerTest, AutoRepeat) { |
| 736 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 534 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| 737 accelerator_a.set_type(ui::ET_KEY_PRESSED); | 535 accelerator_a.set_type(ui::ET_KEY_PRESSED); |
| 738 TestTarget target_a; | 536 TestTarget target_a; |
| 739 GetController()->Register(accelerator_a, &target_a); | 537 GetController()->Register(accelerator_a, &target_a); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 // Expect no notifications from the new accelerators. | 1243 // Expect no notifications from the new accelerators. |
| 1446 EXPECT_TRUE(IsMessageCenterEmpty()); | 1244 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1447 | 1245 |
| 1448 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1246 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1449 // screen before we proceed testing the rest of accelerators. | 1247 // screen before we proceed testing the rest of accelerators. |
| 1450 ResetStateIfNeeded(); | 1248 ResetStateIfNeeded(); |
| 1451 } | 1249 } |
| 1452 } | 1250 } |
| 1453 | 1251 |
| 1454 } // namespace ash | 1252 } // namespace ash |
| OLD | NEW |