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/aura/wm_window_aura.h" |
7 #include "ash/common/accelerators/accelerator_table.h" | 8 #include "ash/common/accelerators/accelerator_table.h" |
8 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
9 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
10 #include "ash/common/ash_switches.h" | 11 #include "ash/common/ash_switches.h" |
11 #include "ash/common/ime_control_delegate.h" | 12 #include "ash/common/ime_control_delegate.h" |
12 #include "ash/common/session/session_state_delegate.h" | 13 #include "ash/common/session/session_state_delegate.h" |
13 #include "ash/common/system/brightness_control_delegate.h" | 14 #include "ash/common/system/brightness_control_delegate.h" |
14 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 15 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
15 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
16 #include "ash/common/test/ash_test.h" | 17 #include "ash/common/test/ash_test.h" |
17 #include "ash/common/wm/panels/panel_layout_manager.h" | 18 #include "ash/common/wm/panels/panel_layout_manager.h" |
18 #include "ash/common/wm/window_positioning_utils.h" | 19 #include "ash/common/wm/window_positioning_utils.h" |
19 #include "ash/common/wm/window_state.h" | 20 #include "ash/common/wm/window_state.h" |
20 #include "ash/common/wm/wm_event.h" | 21 #include "ash/common/wm/wm_event.h" |
21 #include "ash/common/wm_lookup.h" | 22 #include "ash/common/wm_lookup.h" |
22 #include "ash/common/wm_shell.h" | 23 #include "ash/common/wm_shell.h" |
23 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" | 24 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" |
24 #include "ash/mus/bridge/wm_shell_mus_test_api.h" | 25 #include "ash/mus/bridge/wm_shell_mus_test_api.h" |
25 #include "ash/mus/bridge/wm_window_mus.h" | |
26 #include "ash/mus/property_util.h" | 26 #include "ash/mus/property_util.h" |
27 #include "ash/mus/test/wm_test_base.h" | 27 #include "ash/mus/test/wm_test_base.h" |
28 #include "ash/public/cpp/shell_window_ids.h" | 28 #include "ash/public/cpp/shell_window_ids.h" |
29 #include "ash/root_window_controller.h" | 29 #include "ash/root_window_controller.h" |
30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
31 #include "base/test/user_action_tester.cc" | 31 #include "base/test/user_action_tester.cc" |
32 #include "services/ui/public/interfaces/window_manager.mojom.h" | 32 #include "services/ui/public/interfaces/window_manager.mojom.h" |
33 #include "ui/aura/client/aura_constants.h" | 33 #include "ui/aura/client/aura_constants.h" |
34 #include "ui/aura/window.h" | 34 #include "ui/aura/window.h" |
35 #include "ui/events/event.h" | 35 #include "ui/events/event.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 TestTarget target; | 428 TestTarget target; |
429 GetController()->Register(accelerator_a, &target); | 429 GetController()->Register(accelerator_a, &target); |
430 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); | 430 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); |
431 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); | 431 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); |
432 GetController()->UnregisterAll(&target); | 432 GetController()->UnregisterAll(&target); |
433 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); | 433 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); |
434 } | 434 } |
435 | 435 |
436 TEST_F(AcceleratorControllerTest, WindowSnap) { | 436 TEST_F(AcceleratorControllerTest, WindowSnap) { |
437 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 437 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
438 WmWindow* window = mus::WmWindowMus::Get(aura_window); | 438 WmWindow* window = WmWindowAura::Get(aura_window); |
439 wm::WindowState* window_state = window->GetWindowState(); | 439 wm::WindowState* window_state = window->GetWindowState(); |
440 | 440 |
441 window_state->Activate(); | 441 window_state->Activate(); |
442 | 442 |
443 { | 443 { |
444 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 444 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
445 gfx::Rect expected_bounds = | 445 gfx::Rect expected_bounds = |
446 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); | 446 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
447 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 447 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
448 } | 448 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 { | 484 { |
485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
486 EXPECT_TRUE(window_state->IsMinimized()); | 486 EXPECT_TRUE(window_state->IsMinimized()); |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 // Tests that when window docking is disabled, only snapping windows works. | 490 // Tests that when window docking is disabled, only snapping windows works. |
491 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { | 491 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { |
492 ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); | 492 ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); |
493 WmWindow* window = | 493 WmWindow* window = |
494 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 494 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
495 wm::WindowState* window_state = window->GetWindowState(); | 495 wm::WindowState* window_state = window->GetWindowState(); |
496 window_state->Activate(); | 496 window_state->Activate(); |
497 | 497 |
498 // Snap right. | 498 // Snap right. |
499 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 499 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
500 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); | 500 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
501 gfx::Rect expected_bounds = | 501 gfx::Rect expected_bounds = |
502 wm::GetDefaultRightSnappedWindowBoundsInParent(window); | 502 wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
503 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 503 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
504 EXPECT_TRUE(window_state->IsSnapped()); | 504 EXPECT_TRUE(window_state->IsSnapped()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } | 538 } |
539 | 539 |
540 private: | 540 private: |
541 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); | 541 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); |
542 }; | 542 }; |
543 | 543 |
544 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 544 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
545 WindowSnapLeftDockLeftRestore) { | 545 WindowSnapLeftDockLeftRestore) { |
546 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 546 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
547 WmWindow* window1 = | 547 WmWindow* window1 = |
548 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 548 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
549 wm::WindowState* window1_state = window1->GetWindowState(); | 549 wm::WindowState* window1_state = window1->GetWindowState(); |
550 window1_state->Activate(); | 550 window1_state->Activate(); |
551 | 551 |
552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
553 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 553 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
554 gfx::Rect expected_bounds = | 554 gfx::Rect expected_bounds = |
555 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | 555 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); |
556 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 556 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
557 EXPECT_TRUE(window1_state->IsSnapped()); | 557 EXPECT_TRUE(window1_state->IsSnapped()); |
558 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 558 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
559 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 559 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
560 EXPECT_TRUE(window1_state->IsDocked()); | 560 EXPECT_TRUE(window1_state->IsDocked()); |
561 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 561 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
562 EXPECT_FALSE(window1_state->IsDocked()); | 562 EXPECT_FALSE(window1_state->IsDocked()); |
563 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | 563 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); |
564 } | 564 } |
565 | 565 |
566 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 566 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
567 WindowSnapRightDockRightRestore) { | 567 WindowSnapRightDockRightRestore) { |
568 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 568 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
569 WmWindow* window1 = | 569 WmWindow* window1 = |
570 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 570 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
571 | 571 |
572 wm::WindowState* window1_state = window1->GetWindowState(); | 572 wm::WindowState* window1_state = window1->GetWindowState(); |
573 window1_state->Activate(); | 573 window1_state->Activate(); |
574 | 574 |
575 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 575 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
576 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 576 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
577 gfx::Rect expected_bounds = | 577 gfx::Rect expected_bounds = |
578 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | 578 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); |
579 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 579 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
580 EXPECT_TRUE(window1_state->IsSnapped()); | 580 EXPECT_TRUE(window1_state->IsSnapped()); |
581 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 581 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
582 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 582 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
583 EXPECT_TRUE(window1_state->IsDocked()); | 583 EXPECT_TRUE(window1_state->IsDocked()); |
584 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 584 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
585 EXPECT_FALSE(window1_state->IsDocked()); | 585 EXPECT_FALSE(window1_state->IsDocked()); |
586 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | 586 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); |
587 } | 587 } |
588 | 588 |
589 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 589 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
590 WindowSnapLeftDockLeftSnapRight) { | 590 WindowSnapLeftDockLeftSnapRight) { |
591 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 591 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
592 WmWindow* window1 = | 592 WmWindow* window1 = |
593 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 593 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
594 | 594 |
595 wm::WindowState* window1_state = window1->GetWindowState(); | 595 wm::WindowState* window1_state = window1->GetWindowState(); |
596 window1_state->Activate(); | 596 window1_state->Activate(); |
597 | 597 |
598 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 598 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
599 gfx::Rect expected_bounds = | 599 gfx::Rect expected_bounds = |
600 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | 600 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); |
601 gfx::Rect expected_bounds2 = | 601 gfx::Rect expected_bounds2 = |
602 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | 602 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); |
603 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 603 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
604 EXPECT_TRUE(window1_state->IsSnapped()); | 604 EXPECT_TRUE(window1_state->IsSnapped()); |
605 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 605 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
606 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 606 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
607 EXPECT_TRUE(window1_state->IsDocked()); | 607 EXPECT_TRUE(window1_state->IsDocked()); |
608 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 608 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
609 EXPECT_FALSE(window1_state->IsDocked()); | 609 EXPECT_FALSE(window1_state->IsDocked()); |
610 EXPECT_TRUE(window1_state->IsSnapped()); | 610 EXPECT_TRUE(window1_state->IsSnapped()); |
611 EXPECT_EQ(expected_bounds2.ToString(), window1->GetBounds().ToString()); | 611 EXPECT_EQ(expected_bounds2.ToString(), window1->GetBounds().ToString()); |
612 } | 612 } |
613 | 613 |
614 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 614 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
615 WindowDockLeftMinimizeWindowWithRestore) { | 615 WindowDockLeftMinimizeWindowWithRestore) { |
616 WindowOwner window_owner( | 616 WindowOwner window_owner( |
617 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 617 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
618 WindowOwner window1_owner( | 618 WindowOwner window1_owner( |
619 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 619 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
620 WmWindow* window1 = window1_owner.window(); | 620 WmWindow* window1 = window1_owner.window(); |
621 | 621 |
622 wm::WindowState* window1_state = window1->GetWindowState(); | 622 wm::WindowState* window1_state = window1->GetWindowState(); |
623 window1_state->Activate(); | 623 window1_state->Activate(); |
624 | 624 |
625 WindowOwner window2_owner( | 625 WindowOwner window2_owner( |
626 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 626 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
627 WmWindow* window2 = window2_owner.window(); | 627 WmWindow* window2 = window2_owner.window(); |
628 | 628 |
629 wm::WindowState* window2_state = window2->GetWindowState(); | 629 wm::WindowState* window2_state = window2->GetWindowState(); |
630 | 630 |
631 WindowOwner window3_owner( | 631 WindowOwner window3_owner( |
632 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 632 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
633 WmWindow* window3 = window3_owner.window(); | 633 WmWindow* window3 = window3_owner.window(); |
634 | 634 |
635 wm::WindowState* window3_state = window3->GetWindowState(); | 635 wm::WindowState* window3_state = window3->GetWindowState(); |
636 window3_state->Activate(); | 636 window3_state->Activate(); |
637 | 637 |
638 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 638 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
639 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 639 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
640 gfx::Rect window3_docked_bounds = window3->GetBounds(); | 640 gfx::Rect window3_docked_bounds = window3->GetBounds(); |
641 | 641 |
642 window2_state->Activate(); | 642 window2_state->Activate(); |
(...skipping 17 matching lines...) Expand all Loading... |
660 EXPECT_FALSE(window2_state->IsDocked()); | 660 EXPECT_FALSE(window2_state->IsDocked()); |
661 EXPECT_TRUE(window3_state->IsDocked()); | 661 EXPECT_TRUE(window3_state->IsDocked()); |
662 EXPECT_EQ(window3_docked_bounds.ToString(), window3->GetBounds().ToString()); | 662 EXPECT_EQ(window3_docked_bounds.ToString(), window3->GetBounds().ToString()); |
663 } | 663 } |
664 | 664 |
665 // TODO: Needs CreatePanel(): http://crbug.com/632209. | 665 // TODO: Needs CreatePanel(): http://crbug.com/632209. |
666 /* | 666 /* |
667 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 667 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
668 WindowPanelDockLeftDockRightRestore) { | 668 WindowPanelDockLeftDockRightRestore) { |
669 WmWndow* window0 = | 669 WmWndow* window0 = |
670 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 670 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
671 | 671 |
672 std::unique_ptr<aura::Window> window(CreatePanel()); | 672 std::unique_ptr<aura::Window> window(CreatePanel()); |
673 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 673 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
674 window_state->Activate(); | 674 window_state->Activate(); |
675 | 675 |
676 gfx::Rect window_restore_bounds2 = window->bounds(); | 676 gfx::Rect window_restore_bounds2 = window->bounds(); |
677 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 677 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
678 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( | 678 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
679 WmWindowAura::Get(window.get())); | 679 WmWindowAura::Get(window.get())); |
680 gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); | 680 gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); |
681 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); | 681 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); |
682 EXPECT_FALSE(window_state->IsSnapped()); | 682 EXPECT_FALSE(window_state->IsSnapped()); |
683 EXPECT_FALSE(window_state->IsNormalOrSnapped()); | 683 EXPECT_FALSE(window_state->IsNormalOrSnapped()); |
684 EXPECT_TRUE(window_state->IsDocked()); | 684 EXPECT_TRUE(window_state->IsDocked()); |
685 window_state->Restore(); | 685 window_state->Restore(); |
686 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 686 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
687 EXPECT_TRUE(window_state->IsDocked()); | 687 EXPECT_TRUE(window_state->IsDocked()); |
688 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 688 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
689 EXPECT_FALSE(window_state->IsDocked()); | 689 EXPECT_FALSE(window_state->IsDocked()); |
690 EXPECT_EQ(window_restore_bounds.ToString(), | 690 EXPECT_EQ(window_restore_bounds.ToString(), |
691 window_restore_bounds2.ToString()); | 691 window_restore_bounds2.ToString()); |
692 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); | 692 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); |
693 } | 693 } |
694 */ | 694 */ |
695 | 695 |
696 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { | 696 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { |
697 WindowOwner window_owner( | 697 WindowOwner window_owner( |
698 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 698 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
699 WmWindow* window = window_owner.window(); | 699 WmWindow* window = window_owner.window(); |
700 wm::WindowState* window_state = window->GetWindowState(); | 700 wm::WindowState* window_state = window->GetWindowState(); |
701 window_state->Activate(); | 701 window_state->Activate(); |
702 | 702 |
703 // Center the window using accelerator. | 703 // Center the window using accelerator. |
704 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | 704 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
705 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); | 705 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); |
706 gfx::Rect bounds = window->GetBoundsInScreen(); | 706 gfx::Rect bounds = window->GetBoundsInScreen(); |
707 EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), | 707 EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), |
708 1); | 708 1); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { | 795 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { |
796 const AcceleratorData accelerators[] = { | 796 const AcceleratorData accelerators[] = { |
797 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, | 797 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, |
798 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, | 798 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, |
799 }; | 799 }; |
800 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); | 800 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); |
801 | 801 |
802 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 802 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
803 params.bounds = gfx::Rect(5, 5, 20, 20); | 803 params.bounds = gfx::Rect(5, 5, 20, 20); |
804 views::Widget* widget = new views::Widget; | 804 views::Widget* widget = new views::Widget; |
805 mus::WmWindowMus::Get(GetPrimaryRootWindow()) | 805 WmWindowAura::Get(GetPrimaryRootWindow()) |
806 ->GetRootWindowController() | 806 ->GetRootWindowController() |
807 ->ConfigureWidgetInitParamsForContainer( | 807 ->ConfigureWidgetInitParamsForContainer( |
808 widget, kShellWindowId_DefaultContainer, ¶ms); | 808 widget, kShellWindowId_DefaultContainer, ¶ms); |
809 widget->Init(params); | 809 widget->Init(params); |
810 widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey, | 810 widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey, |
811 ui::mojom::kResizeBehaviorCanMaximize); | 811 ui::mojom::kResizeBehaviorCanMaximize); |
812 widget->Show(); | 812 widget->Show(); |
813 widget->Activate(); | 813 widget->Activate(); |
814 | 814 |
815 wm::WindowState* window_state = | 815 wm::WindowState* window_state = |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 } | 1137 } |
1138 | 1138 |
1139 private: | 1139 private: |
1140 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); | 1140 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); |
1141 }; | 1141 }; |
1142 | 1142 |
1143 } // namespace | 1143 } // namespace |
1144 | 1144 |
1145 // TODO: needs LockStateController ported: http://crbug.com/632189. | 1145 // TODO: needs LockStateController ported: http://crbug.com/632189. |
1146 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { | 1146 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { |
1147 WmWindow* w1 = mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect())); | 1147 WmWindow* w1 = WmWindowAura::Get(CreateTestWindow(gfx::Rect())); |
1148 WmWindow* w2 = mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect())); | 1148 WmWindow* w2 = WmWindowAura::Get(CreateTestWindow(gfx::Rect())); |
1149 wm::ActivateWindow(w1); | 1149 wm::ActivateWindow(w1); |
1150 | 1150 |
1151 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); | 1151 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); |
1152 wm::WindowState* w1_state = w1->GetWindowState(); | 1152 wm::WindowState* w1_state = w1->GetWindowState(); |
1153 w1_state->OnWMEvent(&fullscreen); | 1153 w1_state->OnWMEvent(&fullscreen); |
1154 ASSERT_TRUE(w1_state->IsFullscreen()); | 1154 ASSERT_TRUE(w1_state->IsFullscreen()); |
1155 | 1155 |
1156 ui::test::EventGenerator& generator = GetEventGenerator(); | 1156 ui::test::EventGenerator& generator = GetEventGenerator(); |
1157 #if defined(OS_CHROMEOS) | 1157 #if defined(OS_CHROMEOS) |
1158 // Power key (reserved) should always be handled. | 1158 // Power key (reserved) should always be handled. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1234 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1235 for (const auto& action : actionsAllowedAtModalWindow) { | 1235 for (const auto& action : actionsAllowedAtModalWindow) { |
1236 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || | 1236 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || |
1237 all_debug_actions.find(action) != all_debug_actions.end() || | 1237 all_debug_actions.find(action) != all_debug_actions.end() || |
1238 all_dev_actions.find(action) != all_dev_actions.end()) | 1238 all_dev_actions.find(action) != all_dev_actions.end()) |
1239 << " action from kActionsAllowedAtModalWindow" | 1239 << " action from kActionsAllowedAtModalWindow" |
1240 << " not found in kAcceleratorData, kDebugAcceleratorData or" | 1240 << " not found in kAcceleratorData, kDebugAcceleratorData or" |
1241 << " kDeveloperAcceleratorData action: " << action; | 1241 << " kDeveloperAcceleratorData action: " << action; |
1242 } | 1242 } |
1243 WmWindow* window = | 1243 WmWindow* window = |
1244 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 1244 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
1245 window->Activate(); | 1245 window->Activate(); |
1246 WmShell::Get()->SimulateModalWindowOpenForTesting(true); | 1246 WmShell::Get()->SimulateModalWindowOpenForTesting(true); |
1247 for (const auto& action : all_actions) { | 1247 for (const auto& action : all_actions) { |
1248 if (actionsAllowedAtModalWindow.find(action) == | 1248 if (actionsAllowedAtModalWindow.find(action) == |
1249 actionsAllowedAtModalWindow.end()) { | 1249 actionsAllowedAtModalWindow.end()) { |
1250 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) | 1250 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) |
1251 << " for action (disallowed at modal window): " << action; | 1251 << " for action (disallowed at modal window): " << action; |
1252 } | 1252 } |
1253 } | 1253 } |
1254 // Testing of top row (F5-F10) accelerators that should still work | 1254 // Testing of top row (F5-F10) accelerators that should still work |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1333 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1333 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1334 EXPECT_TRUE( | 1334 EXPECT_TRUE( |
1335 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1335 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
1336 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1336 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1337 } | 1337 } |
1338 | 1338 |
1339 // Make sure we don't alert if we do have a window. | 1339 // Make sure we don't alert if we do have a window. |
1340 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1340 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1341 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 1341 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
1342 mus::WmWindowMus::Get(aura_window)->Activate(); | 1342 WmWindowAura::Get(aura_window)->Activate(); |
1343 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1343 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1344 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1344 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
1345 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1345 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1346 delete aura_window; | 1346 delete aura_window; |
1347 } | 1347 } |
1348 | 1348 |
1349 // Don't alert if we have a minimized window either. | 1349 // Don't alert if we have a minimized window either. |
1350 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1350 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1351 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 1351 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
1352 mus::WmWindowMus::Get(aura_window)->Activate(); | 1352 WmWindowAura::Get(aura_window)->Activate(); |
1353 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 1353 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
1354 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1354 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1355 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1355 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
1356 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1356 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1357 delete aura_window; | 1357 delete aura_window; |
1358 } | 1358 } |
1359 } | 1359 } |
1360 | 1360 |
1361 #if defined(OS_CHROMEOS) | 1361 #if defined(OS_CHROMEOS) |
1362 namespace { | 1362 namespace { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 EXPECT_TRUE(IsMessageCenterEmpty()); | 1465 EXPECT_TRUE(IsMessageCenterEmpty()); |
1466 | 1466 |
1467 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1467 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1468 // screen before we proceed testing the rest of accelerators. | 1468 // screen before we proceed testing the rest of accelerators. |
1469 ResetStateIfNeeded(); | 1469 ResetStateIfNeeded(); |
1470 } | 1470 } |
1471 } | 1471 } |
1472 #endif // defined(OS_CHROMEOS) | 1472 #endif // defined(OS_CHROMEOS) |
1473 | 1473 |
1474 } // namespace ash | 1474 } // namespace ash |
OLD | NEW |