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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_table.h" | 7 #include "ash/accelerators/accelerator_table.h" |
8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, ui::EF_SHIFT_DOWN); | 433 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, ui::EF_SHIFT_DOWN); |
434 TestTarget target; | 434 TestTarget target; |
435 GetController()->Register(accelerator_a, &target); | 435 GetController()->Register(accelerator_a, &target); |
436 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); | 436 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); |
437 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); | 437 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); |
438 GetController()->UnregisterAll(&target); | 438 GetController()->UnregisterAll(&target); |
439 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); | 439 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); |
440 } | 440 } |
441 | 441 |
442 TEST_F(AcceleratorControllerTest, WindowSnap) { | 442 TEST_F(AcceleratorControllerTest, WindowSnap) { |
443 scoped_ptr<aura::Window> window( | 443 std::unique_ptr<aura::Window> window( |
444 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 444 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
445 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 445 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
446 | 446 |
447 window_state->Activate(); | 447 window_state->Activate(); |
448 | 448 |
449 { | 449 { |
450 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 450 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
451 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( | 451 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
452 window.get()); | 452 window.get()); |
453 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); | 453 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 window_state->Restore(); | 487 window_state->Restore(); |
488 window_state->Activate(); | 488 window_state->Activate(); |
489 } | 489 } |
490 { | 490 { |
491 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 491 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
492 EXPECT_TRUE(window_state->IsMinimized()); | 492 EXPECT_TRUE(window_state->IsMinimized()); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftRestore) { | 496 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftRestore) { |
497 scoped_ptr<aura::Window> window0( | 497 std::unique_ptr<aura::Window> window0( |
498 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 498 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
499 scoped_ptr<aura::Window> window1( | 499 std::unique_ptr<aura::Window> window1( |
500 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 500 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
501 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 501 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
502 window1_state->Activate(); | 502 window1_state->Activate(); |
503 | 503 |
504 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 504 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
505 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 505 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
506 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( | 506 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
507 window1.get()); | 507 window1.get()); |
508 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); | 508 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
509 EXPECT_TRUE(window1_state->IsSnapped()); | 509 EXPECT_TRUE(window1_state->IsSnapped()); |
510 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 510 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
511 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 511 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
512 EXPECT_TRUE(window1_state->IsDocked()); | 512 EXPECT_TRUE(window1_state->IsDocked()); |
513 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 513 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
514 EXPECT_FALSE(window1_state->IsDocked()); | 514 EXPECT_FALSE(window1_state->IsDocked()); |
515 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); | 515 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); |
516 } | 516 } |
517 | 517 |
518 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) { | 518 TEST_F(AcceleratorControllerTest, WindowSnapRightDockRightRestore) { |
519 scoped_ptr<aura::Window> window0( | 519 std::unique_ptr<aura::Window> window0( |
520 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 520 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
521 scoped_ptr<aura::Window> window1( | 521 std::unique_ptr<aura::Window> window1( |
522 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 522 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
523 | 523 |
524 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 524 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
525 window1_state->Activate(); | 525 window1_state->Activate(); |
526 | 526 |
527 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 527 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
528 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 528 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
529 gfx::Rect expected_bounds = | 529 gfx::Rect expected_bounds = |
530 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); | 530 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); |
531 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); | 531 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
532 EXPECT_TRUE(window1_state->IsSnapped()); | 532 EXPECT_TRUE(window1_state->IsSnapped()); |
533 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 533 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
534 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 534 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
535 EXPECT_TRUE(window1_state->IsDocked()); | 535 EXPECT_TRUE(window1_state->IsDocked()); |
536 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 536 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
537 EXPECT_FALSE(window1_state->IsDocked()); | 537 EXPECT_FALSE(window1_state->IsDocked()); |
538 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); | 538 EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); |
539 } | 539 } |
540 | 540 |
541 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) { | 541 TEST_F(AcceleratorControllerTest, WindowSnapLeftDockLeftSnapRight) { |
542 scoped_ptr<aura::Window> window0( | 542 std::unique_ptr<aura::Window> window0( |
543 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 543 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
544 scoped_ptr<aura::Window> window1( | 544 std::unique_ptr<aura::Window> window1( |
545 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 545 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
546 | 546 |
547 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 547 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
548 window1_state->Activate(); | 548 window1_state->Activate(); |
549 | 549 |
550 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 550 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
551 gfx::Rect expected_bounds = | 551 gfx::Rect expected_bounds = |
552 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1.get()); | 552 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1.get()); |
553 gfx::Rect expected_bounds2 = | 553 gfx::Rect expected_bounds2 = |
554 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); | 554 wm::GetDefaultRightSnappedWindowBoundsInParent(window1.get()); |
555 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); | 555 EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
556 EXPECT_TRUE(window1_state->IsSnapped()); | 556 EXPECT_TRUE(window1_state->IsSnapped()); |
557 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 557 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
558 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 558 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
559 EXPECT_TRUE(window1_state->IsDocked()); | 559 EXPECT_TRUE(window1_state->IsDocked()); |
560 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 560 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
561 EXPECT_FALSE(window1_state->IsDocked()); | 561 EXPECT_FALSE(window1_state->IsDocked()); |
562 EXPECT_TRUE(window1_state->IsSnapped()); | 562 EXPECT_TRUE(window1_state->IsSnapped()); |
563 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString()); | 563 EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString()); |
564 } | 564 } |
565 | 565 |
566 TEST_F(AcceleratorControllerTest, WindowDockLeftMinimizeWindowWithRestore) { | 566 TEST_F(AcceleratorControllerTest, WindowDockLeftMinimizeWindowWithRestore) { |
567 scoped_ptr<aura::Window> window0( | 567 std::unique_ptr<aura::Window> window0( |
568 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 568 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
569 scoped_ptr<aura::Window> window1( | 569 std::unique_ptr<aura::Window> window1( |
570 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 570 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
571 | 571 |
572 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); | 572 wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
573 window1_state->Activate(); | 573 window1_state->Activate(); |
574 | 574 |
575 scoped_ptr<aura::Window> window2( | 575 std::unique_ptr<aura::Window> window2( |
576 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 576 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
577 | 577 |
578 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); | 578 wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
579 | 579 |
580 scoped_ptr<aura::Window> window3( | 580 std::unique_ptr<aura::Window> window3( |
581 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 581 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
582 | 582 |
583 wm::WindowState* window3_state = wm::GetWindowState(window3.get()); | 583 wm::WindowState* window3_state = wm::GetWindowState(window3.get()); |
584 window3_state->Activate(); | 584 window3_state->Activate(); |
585 | 585 |
586 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 586 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
587 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 587 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
588 gfx::Rect window3_docked_bounds = window3->bounds(); | 588 gfx::Rect window3_docked_bounds = window3->bounds(); |
589 | 589 |
590 window2_state->Activate(); | 590 window2_state->Activate(); |
591 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 591 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
(...skipping 12 matching lines...) Expand all Loading... |
604 window2_state->Activate(); | 604 window2_state->Activate(); |
605 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 605 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
606 window3_state->Unminimize(); | 606 window3_state->Unminimize(); |
607 EXPECT_FALSE(window1_state->IsDocked()); | 607 EXPECT_FALSE(window1_state->IsDocked()); |
608 EXPECT_FALSE(window2_state->IsDocked()); | 608 EXPECT_FALSE(window2_state->IsDocked()); |
609 EXPECT_TRUE(window3_state->IsDocked()); | 609 EXPECT_TRUE(window3_state->IsDocked()); |
610 EXPECT_EQ(window3_docked_bounds.ToString(), window3->bounds().ToString()); | 610 EXPECT_EQ(window3_docked_bounds.ToString(), window3->bounds().ToString()); |
611 } | 611 } |
612 | 612 |
613 TEST_F(AcceleratorControllerTest, WindowPanelDockLeftDockRightRestore) { | 613 TEST_F(AcceleratorControllerTest, WindowPanelDockLeftDockRightRestore) { |
614 scoped_ptr<aura::Window> window0( | 614 std::unique_ptr<aura::Window> window0( |
615 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 615 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
616 | 616 |
617 scoped_ptr<aura::Window> window(CreatePanel()); | 617 std::unique_ptr<aura::Window> window(CreatePanel()); |
618 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 618 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
619 window_state->Activate(); | 619 window_state->Activate(); |
620 | 620 |
621 gfx::Rect window_restore_bounds2 = window->bounds(); | 621 gfx::Rect window_restore_bounds2 = window->bounds(); |
622 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 622 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
623 gfx::Rect expected_bounds = | 623 gfx::Rect expected_bounds = |
624 wm::GetDefaultLeftSnappedWindowBoundsInParent(window.get()); | 624 wm::GetDefaultLeftSnappedWindowBoundsInParent(window.get()); |
625 gfx::Rect window_restore_bounds = | 625 gfx::Rect window_restore_bounds = |
626 window_state->GetRestoreBoundsInScreen(); | 626 window_state->GetRestoreBoundsInScreen(); |
627 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); | 627 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); |
628 EXPECT_FALSE(window_state->IsSnapped()); | 628 EXPECT_FALSE(window_state->IsSnapped()); |
629 EXPECT_FALSE(window_state->IsNormalOrSnapped()); | 629 EXPECT_FALSE(window_state->IsNormalOrSnapped()); |
630 EXPECT_TRUE(window_state->IsDocked()); | 630 EXPECT_TRUE(window_state->IsDocked()); |
631 window_state->Restore(); | 631 window_state->Restore(); |
632 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 632 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
633 EXPECT_TRUE(window_state->IsDocked()); | 633 EXPECT_TRUE(window_state->IsDocked()); |
634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
635 EXPECT_FALSE(window_state->IsDocked()); | 635 EXPECT_FALSE(window_state->IsDocked()); |
636 EXPECT_EQ(window_restore_bounds.ToString(), | 636 EXPECT_EQ(window_restore_bounds.ToString(), |
637 window_restore_bounds2.ToString()); | 637 window_restore_bounds2.ToString()); |
638 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); | 638 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); |
639 } | 639 } |
640 | 640 |
641 TEST_F(AcceleratorControllerTest, CenterWindowAccelerator) { | 641 TEST_F(AcceleratorControllerTest, CenterWindowAccelerator) { |
642 scoped_ptr<aura::Window> window( | 642 std::unique_ptr<aura::Window> window( |
643 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 643 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
644 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 644 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
645 window_state->Activate(); | 645 window_state->Activate(); |
646 | 646 |
647 // Center the window using accelerator. | 647 // Center the window using accelerator. |
648 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | 648 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
649 gfx::Rect work_area = gfx::Screen::GetScreen() | 649 gfx::Rect work_area = gfx::Screen::GetScreen() |
650 ->GetDisplayNearestWindow(window.get()) | 650 ->GetDisplayNearestWindow(window.get()) |
651 .work_area(); | 651 .work_area(); |
652 gfx::Rect bounds = window->GetBoundsInScreen(); | 652 gfx::Rect bounds = window->GetBoundsInScreen(); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 EXPECT_TRUE(ProcessInController(ui::Accelerator( | 858 EXPECT_TRUE(ProcessInController(ui::Accelerator( |
859 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 859 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
860 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); | 860 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
861 } | 861 } |
862 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); | 862 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); |
863 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); | 863 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
864 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); | 864 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); |
865 { | 865 { |
866 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; | 866 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; |
867 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( | 867 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( |
868 scoped_ptr<VolumeControlDelegate>(delegate)); | 868 std::unique_ptr<VolumeControlDelegate>(delegate)); |
869 EXPECT_EQ(0, delegate->handle_volume_mute_count()); | 869 EXPECT_EQ(0, delegate->handle_volume_mute_count()); |
870 EXPECT_TRUE(ProcessInController(volume_mute)); | 870 EXPECT_TRUE(ProcessInController(volume_mute)); |
871 EXPECT_EQ(1, delegate->handle_volume_mute_count()); | 871 EXPECT_EQ(1, delegate->handle_volume_mute_count()); |
872 EXPECT_EQ(volume_mute, delegate->last_accelerator()); | 872 EXPECT_EQ(volume_mute, delegate->last_accelerator()); |
873 EXPECT_EQ(0, delegate->handle_volume_down_count()); | 873 EXPECT_EQ(0, delegate->handle_volume_down_count()); |
874 EXPECT_TRUE(ProcessInController(volume_down)); | 874 EXPECT_TRUE(ProcessInController(volume_down)); |
875 EXPECT_EQ(1, delegate->handle_volume_down_count()); | 875 EXPECT_EQ(1, delegate->handle_volume_down_count()); |
876 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 876 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
877 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 877 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
878 EXPECT_TRUE(ProcessInController(volume_up)); | 878 EXPECT_TRUE(ProcessInController(volume_up)); |
879 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 879 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
880 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 880 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
881 } | 881 } |
882 // Brightness | 882 // Brightness |
883 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows. | 883 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows. |
884 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); | 884 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); |
885 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); | 885 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); |
886 { | 886 { |
887 DummyBrightnessControlDelegate* delegate = | 887 DummyBrightnessControlDelegate* delegate = |
888 new DummyBrightnessControlDelegate; | 888 new DummyBrightnessControlDelegate; |
889 GetController()->SetBrightnessControlDelegate( | 889 GetController()->SetBrightnessControlDelegate( |
890 scoped_ptr<BrightnessControlDelegate>(delegate)); | 890 std::unique_ptr<BrightnessControlDelegate>(delegate)); |
891 EXPECT_EQ(0, delegate->handle_brightness_down_count()); | 891 EXPECT_EQ(0, delegate->handle_brightness_down_count()); |
892 EXPECT_TRUE(ProcessInController(brightness_down)); | 892 EXPECT_TRUE(ProcessInController(brightness_down)); |
893 EXPECT_EQ(1, delegate->handle_brightness_down_count()); | 893 EXPECT_EQ(1, delegate->handle_brightness_down_count()); |
894 EXPECT_EQ(brightness_down, delegate->last_accelerator()); | 894 EXPECT_EQ(brightness_down, delegate->last_accelerator()); |
895 EXPECT_EQ(0, delegate->handle_brightness_up_count()); | 895 EXPECT_EQ(0, delegate->handle_brightness_up_count()); |
896 EXPECT_TRUE(ProcessInController(brightness_up)); | 896 EXPECT_TRUE(ProcessInController(brightness_up)); |
897 EXPECT_EQ(1, delegate->handle_brightness_up_count()); | 897 EXPECT_EQ(1, delegate->handle_brightness_up_count()); |
898 EXPECT_EQ(brightness_up, delegate->last_accelerator()); | 898 EXPECT_EQ(brightness_up, delegate->last_accelerator()); |
899 } | 899 } |
900 | 900 |
901 // Keyboard brightness | 901 // Keyboard brightness |
902 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN, | 902 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN, |
903 ui::EF_ALT_DOWN); | 903 ui::EF_ALT_DOWN); |
904 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP, | 904 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP, |
905 ui::EF_ALT_DOWN); | 905 ui::EF_ALT_DOWN); |
906 { | 906 { |
907 EXPECT_TRUE(ProcessInController(alt_brightness_down)); | 907 EXPECT_TRUE(ProcessInController(alt_brightness_down)); |
908 EXPECT_TRUE(ProcessInController(alt_brightness_up)); | 908 EXPECT_TRUE(ProcessInController(alt_brightness_up)); |
909 DummyKeyboardBrightnessControlDelegate* delegate = | 909 DummyKeyboardBrightnessControlDelegate* delegate = |
910 new DummyKeyboardBrightnessControlDelegate; | 910 new DummyKeyboardBrightnessControlDelegate; |
911 GetController()->SetKeyboardBrightnessControlDelegate( | 911 GetController()->SetKeyboardBrightnessControlDelegate( |
912 scoped_ptr<KeyboardBrightnessControlDelegate>(delegate)); | 912 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); |
913 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); | 913 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); |
914 EXPECT_TRUE(ProcessInController(alt_brightness_down)); | 914 EXPECT_TRUE(ProcessInController(alt_brightness_down)); |
915 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); | 915 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); |
916 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); | 916 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); |
917 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); | 917 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); |
918 EXPECT_TRUE(ProcessInController(alt_brightness_up)); | 918 EXPECT_TRUE(ProcessInController(alt_brightness_up)); |
919 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); | 919 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); |
920 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); | 920 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); |
921 } | 921 } |
922 #endif | 922 #endif |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); | 1044 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); |
1045 EXPECT_FALSE(ProcessInController(control_space_down)); | 1045 EXPECT_FALSE(ProcessInController(control_space_down)); |
1046 EXPECT_FALSE(ProcessInController(control_space_up)); | 1046 EXPECT_FALSE(ProcessInController(control_space_up)); |
1047 EXPECT_FALSE(ProcessInController(convert)); | 1047 EXPECT_FALSE(ProcessInController(convert)); |
1048 EXPECT_FALSE(ProcessInController(non_convert)); | 1048 EXPECT_FALSE(ProcessInController(non_convert)); |
1049 EXPECT_FALSE(ProcessInController(wide_half_1)); | 1049 EXPECT_FALSE(ProcessInController(wide_half_1)); |
1050 EXPECT_FALSE(ProcessInController(wide_half_2)); | 1050 EXPECT_FALSE(ProcessInController(wide_half_2)); |
1051 EXPECT_FALSE(ProcessInController(hangul)); | 1051 EXPECT_FALSE(ProcessInController(hangul)); |
1052 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1052 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
1053 GetController()->SetImeControlDelegate( | 1053 GetController()->SetImeControlDelegate( |
1054 scoped_ptr<ImeControlDelegate>(delegate)); | 1054 std::unique_ptr<ImeControlDelegate>(delegate)); |
1055 EXPECT_EQ(0, delegate->handle_previous_ime_count()); | 1055 EXPECT_EQ(0, delegate->handle_previous_ime_count()); |
1056 EXPECT_TRUE(ProcessInController(control_space_down)); | 1056 EXPECT_TRUE(ProcessInController(control_space_down)); |
1057 EXPECT_EQ(1, delegate->handle_previous_ime_count()); | 1057 EXPECT_EQ(1, delegate->handle_previous_ime_count()); |
1058 EXPECT_TRUE(ProcessInController(control_space_up)); | 1058 EXPECT_TRUE(ProcessInController(control_space_up)); |
1059 EXPECT_EQ(1, delegate->handle_previous_ime_count()); | 1059 EXPECT_EQ(1, delegate->handle_previous_ime_count()); |
1060 EXPECT_EQ(0, delegate->handle_switch_ime_count()); | 1060 EXPECT_EQ(0, delegate->handle_switch_ime_count()); |
1061 EXPECT_TRUE(ProcessInController(convert)); | 1061 EXPECT_TRUE(ProcessInController(convert)); |
1062 EXPECT_EQ(1, delegate->handle_switch_ime_count()); | 1062 EXPECT_EQ(1, delegate->handle_switch_ime_count()); |
1063 EXPECT_TRUE(ProcessInController(non_convert)); | 1063 EXPECT_TRUE(ProcessInController(non_convert)); |
1064 EXPECT_EQ(2, delegate->handle_switch_ime_count()); | 1064 EXPECT_EQ(2, delegate->handle_switch_ime_count()); |
1065 EXPECT_TRUE(ProcessInController(wide_half_1)); | 1065 EXPECT_TRUE(ProcessInController(wide_half_1)); |
1066 EXPECT_EQ(3, delegate->handle_switch_ime_count()); | 1066 EXPECT_EQ(3, delegate->handle_switch_ime_count()); |
1067 EXPECT_TRUE(ProcessInController(wide_half_2)); | 1067 EXPECT_TRUE(ProcessInController(wide_half_2)); |
1068 EXPECT_EQ(4, delegate->handle_switch_ime_count()); | 1068 EXPECT_EQ(4, delegate->handle_switch_ime_count()); |
1069 EXPECT_TRUE(ProcessInController(hangul)); | 1069 EXPECT_TRUE(ProcessInController(hangul)); |
1070 EXPECT_EQ(5, delegate->handle_switch_ime_count()); | 1070 EXPECT_EQ(5, delegate->handle_switch_ime_count()); |
1071 } | 1071 } |
1072 | 1072 |
1073 // Test IME shortcuts that are triggered on key release. | 1073 // Test IME shortcuts that are triggered on key release. |
1074 { | 1074 { |
1075 const ui::Accelerator shift_alt_press(ui::VKEY_MENU, | 1075 const ui::Accelerator shift_alt_press(ui::VKEY_MENU, |
1076 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1076 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1077 const ReleaseAccelerator shift_alt(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); | 1077 const ReleaseAccelerator shift_alt(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); |
1078 const ui::Accelerator alt_shift_press(ui::VKEY_SHIFT, | 1078 const ui::Accelerator alt_shift_press(ui::VKEY_SHIFT, |
1079 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1079 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1080 const ReleaseAccelerator alt_shift(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); | 1080 const ReleaseAccelerator alt_shift(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); |
1081 | 1081 |
1082 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1082 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
1083 GetController()->SetImeControlDelegate( | 1083 GetController()->SetImeControlDelegate( |
1084 scoped_ptr<ImeControlDelegate>(delegate)); | 1084 std::unique_ptr<ImeControlDelegate>(delegate)); |
1085 EXPECT_EQ(0, delegate->handle_next_ime_count()); | 1085 EXPECT_EQ(0, delegate->handle_next_ime_count()); |
1086 EXPECT_FALSE(ProcessInController(shift_alt_press)); | 1086 EXPECT_FALSE(ProcessInController(shift_alt_press)); |
1087 EXPECT_TRUE(ProcessInController(shift_alt)); | 1087 EXPECT_TRUE(ProcessInController(shift_alt)); |
1088 EXPECT_EQ(1, delegate->handle_next_ime_count()); | 1088 EXPECT_EQ(1, delegate->handle_next_ime_count()); |
1089 EXPECT_FALSE(ProcessInController(alt_shift_press)); | 1089 EXPECT_FALSE(ProcessInController(alt_shift_press)); |
1090 EXPECT_TRUE(ProcessInController(alt_shift)); | 1090 EXPECT_TRUE(ProcessInController(alt_shift)); |
1091 EXPECT_EQ(2, delegate->handle_next_ime_count()); | 1091 EXPECT_EQ(2, delegate->handle_next_ime_count()); |
1092 | 1092 |
1093 // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is | 1093 // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is |
1094 // released. | 1094 // released. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 #if defined(OS_CHROMEOS) | 1136 #if defined(OS_CHROMEOS) |
1137 // Test IME shortcuts again with unnormalized accelerators (Chrome OS only). | 1137 // Test IME shortcuts again with unnormalized accelerators (Chrome OS only). |
1138 { | 1138 { |
1139 const ui::Accelerator shift_alt_press(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); | 1139 const ui::Accelerator shift_alt_press(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); |
1140 const ReleaseAccelerator shift_alt(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); | 1140 const ReleaseAccelerator shift_alt(ui::VKEY_MENU, ui::EF_SHIFT_DOWN); |
1141 const ui::Accelerator alt_shift_press(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); | 1141 const ui::Accelerator alt_shift_press(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); |
1142 const ReleaseAccelerator alt_shift(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); | 1142 const ReleaseAccelerator alt_shift(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); |
1143 | 1143 |
1144 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1144 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
1145 GetController()->SetImeControlDelegate( | 1145 GetController()->SetImeControlDelegate( |
1146 scoped_ptr<ImeControlDelegate>(delegate)); | 1146 std::unique_ptr<ImeControlDelegate>(delegate)); |
1147 EXPECT_EQ(0, delegate->handle_next_ime_count()); | 1147 EXPECT_EQ(0, delegate->handle_next_ime_count()); |
1148 EXPECT_FALSE(ProcessInController(shift_alt_press)); | 1148 EXPECT_FALSE(ProcessInController(shift_alt_press)); |
1149 EXPECT_TRUE(ProcessInController(shift_alt)); | 1149 EXPECT_TRUE(ProcessInController(shift_alt)); |
1150 EXPECT_EQ(1, delegate->handle_next_ime_count()); | 1150 EXPECT_EQ(1, delegate->handle_next_ime_count()); |
1151 EXPECT_FALSE(ProcessInController(alt_shift_press)); | 1151 EXPECT_FALSE(ProcessInController(alt_shift_press)); |
1152 EXPECT_TRUE(ProcessInController(alt_shift)); | 1152 EXPECT_TRUE(ProcessInController(alt_shift)); |
1153 EXPECT_EQ(2, delegate->handle_next_ime_count()); | 1153 EXPECT_EQ(2, delegate->handle_next_ime_count()); |
1154 | 1154 |
1155 // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is | 1155 // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is |
1156 // released. | 1156 // released. |
(...skipping 25 matching lines...) Expand all Loading... |
1182 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1182 ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1183 EXPECT_FALSE(ProcessInController(shift_alt_space_press)); | 1183 EXPECT_FALSE(ProcessInController(shift_alt_space_press)); |
1184 } | 1184 } |
1185 | 1185 |
1186 // Makes sure that the next IME accelerators doesn't conflict with other | 1186 // Makes sure that the next IME accelerators doesn't conflict with other |
1187 // accelerators that contain Alt+Shift when the wrong sequence is pressed. | 1187 // accelerators that contain Alt+Shift when the wrong sequence is pressed. |
1188 // crbug.com/527154. | 1188 // crbug.com/527154. |
1189 TEST_F(AcceleratorControllerTest, ImeGlobalAcceleratorsNoConflict) { | 1189 TEST_F(AcceleratorControllerTest, ImeGlobalAcceleratorsNoConflict) { |
1190 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1190 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
1191 GetController()->SetImeControlDelegate( | 1191 GetController()->SetImeControlDelegate( |
1192 scoped_ptr<ImeControlDelegate>(delegate)); | 1192 std::unique_ptr<ImeControlDelegate>(delegate)); |
1193 ui::test::EventGenerator& generator = GetEventGenerator(); | 1193 ui::test::EventGenerator& generator = GetEventGenerator(); |
1194 | 1194 |
1195 // Correct sequence of a conflicting accelerator must not trigger next IME. | 1195 // Correct sequence of a conflicting accelerator must not trigger next IME. |
1196 // Alt (press) + Shift (press) + S (press) + S (release) + Shift (release) + | 1196 // Alt (press) + Shift (press) + S (press) + S (release) + Shift (release) + |
1197 // Alt (release). | 1197 // Alt (release). |
1198 generator.PressKey(ui::VKEY_MENU, ui::EF_ALT_DOWN); | 1198 generator.PressKey(ui::VKEY_MENU, ui::EF_ALT_DOWN); |
1199 generator.PressKey(ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1199 generator.PressKey(ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1200 generator.PressKey(ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1200 generator.PressKey(ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1201 generator.ReleaseKey(ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1201 generator.ReleaseKey(ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
1202 generator.ReleaseKey(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); | 1202 generator.ReleaseKey(ui::VKEY_SHIFT, ui::EF_ALT_DOWN); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1352 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1353 for (std::set<AcceleratorAction>::const_iterator it = | 1353 for (std::set<AcceleratorAction>::const_iterator it = |
1354 actionsAllowedAtModalWindow.begin(); | 1354 actionsAllowedAtModalWindow.begin(); |
1355 it != actionsAllowedAtModalWindow.end(); ++it) { | 1355 it != actionsAllowedAtModalWindow.end(); ++it) { |
1356 EXPECT_TRUE(all_actions.find(*it) != all_actions.end() || | 1356 EXPECT_TRUE(all_actions.find(*it) != all_actions.end() || |
1357 all_debug_actions.find(*it) != all_debug_actions.end()) | 1357 all_debug_actions.find(*it) != all_debug_actions.end()) |
1358 << " action from kActionsAllowedAtModalWindow" | 1358 << " action from kActionsAllowedAtModalWindow" |
1359 << " not found in kAcceleratorData or kDebugAcceleratorData. " | 1359 << " not found in kAcceleratorData or kDebugAcceleratorData. " |
1360 << "action: " << *it; | 1360 << "action: " << *it; |
1361 } | 1361 } |
1362 scoped_ptr<aura::Window> window( | 1362 std::unique_ptr<aura::Window> window( |
1363 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1363 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1364 wm::ActivateWindow(window.get()); | 1364 wm::ActivateWindow(window.get()); |
1365 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); | 1365 Shell::GetInstance()->SimulateModalWindowOpenForTesting(true); |
1366 for (std::set<AcceleratorAction>::const_iterator it = all_actions.begin(); | 1366 for (std::set<AcceleratorAction>::const_iterator it = all_actions.begin(); |
1367 it != all_actions.end(); ++it) { | 1367 it != all_actions.end(); ++it) { |
1368 if (actionsAllowedAtModalWindow.find(*it) == | 1368 if (actionsAllowedAtModalWindow.find(*it) == |
1369 actionsAllowedAtModalWindow.end()) { | 1369 actionsAllowedAtModalWindow.end()) { |
1370 EXPECT_TRUE(GetController()->PerformActionIfEnabled(*it)) | 1370 EXPECT_TRUE(GetController()->PerformActionIfEnabled(*it)) |
1371 << " for action (disallowed at modal window): " << *it; | 1371 << " for action (disallowed at modal window): " << *it; |
1372 } | 1372 } |
(...skipping 25 matching lines...) Expand all Loading... |
1398 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 1398 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
1399 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); | 1399 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
1400 } | 1400 } |
1401 // Brightness | 1401 // Brightness |
1402 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); | 1402 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); |
1403 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); | 1403 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); |
1404 { | 1404 { |
1405 DummyBrightnessControlDelegate* delegate = | 1405 DummyBrightnessControlDelegate* delegate = |
1406 new DummyBrightnessControlDelegate; | 1406 new DummyBrightnessControlDelegate; |
1407 GetController()->SetBrightnessControlDelegate( | 1407 GetController()->SetBrightnessControlDelegate( |
1408 scoped_ptr<BrightnessControlDelegate>(delegate)); | 1408 std::unique_ptr<BrightnessControlDelegate>(delegate)); |
1409 EXPECT_EQ(0, delegate->handle_brightness_down_count()); | 1409 EXPECT_EQ(0, delegate->handle_brightness_down_count()); |
1410 EXPECT_TRUE(ProcessInController(brightness_down)); | 1410 EXPECT_TRUE(ProcessInController(brightness_down)); |
1411 EXPECT_EQ(1, delegate->handle_brightness_down_count()); | 1411 EXPECT_EQ(1, delegate->handle_brightness_down_count()); |
1412 EXPECT_EQ(brightness_down, delegate->last_accelerator()); | 1412 EXPECT_EQ(brightness_down, delegate->last_accelerator()); |
1413 EXPECT_EQ(0, delegate->handle_brightness_up_count()); | 1413 EXPECT_EQ(0, delegate->handle_brightness_up_count()); |
1414 EXPECT_TRUE(ProcessInController(brightness_up)); | 1414 EXPECT_TRUE(ProcessInController(brightness_up)); |
1415 EXPECT_EQ(1, delegate->handle_brightness_up_count()); | 1415 EXPECT_EQ(1, delegate->handle_brightness_up_count()); |
1416 EXPECT_EQ(brightness_up, delegate->last_accelerator()); | 1416 EXPECT_EQ(brightness_up, delegate->last_accelerator()); |
1417 } | 1417 } |
1418 // Volume | 1418 // Volume |
1419 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); | 1419 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); |
1420 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); | 1420 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
1421 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); | 1421 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); |
1422 { | 1422 { |
1423 EXPECT_TRUE(ProcessInController(volume_mute)); | 1423 EXPECT_TRUE(ProcessInController(volume_mute)); |
1424 EXPECT_TRUE(ProcessInController(volume_down)); | 1424 EXPECT_TRUE(ProcessInController(volume_down)); |
1425 EXPECT_TRUE(ProcessInController(volume_up)); | 1425 EXPECT_TRUE(ProcessInController(volume_up)); |
1426 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; | 1426 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; |
1427 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( | 1427 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( |
1428 scoped_ptr<VolumeControlDelegate>(delegate)); | 1428 std::unique_ptr<VolumeControlDelegate>(delegate)); |
1429 EXPECT_EQ(0, delegate->handle_volume_mute_count()); | 1429 EXPECT_EQ(0, delegate->handle_volume_mute_count()); |
1430 EXPECT_TRUE(ProcessInController(volume_mute)); | 1430 EXPECT_TRUE(ProcessInController(volume_mute)); |
1431 EXPECT_EQ(1, delegate->handle_volume_mute_count()); | 1431 EXPECT_EQ(1, delegate->handle_volume_mute_count()); |
1432 EXPECT_EQ(volume_mute, delegate->last_accelerator()); | 1432 EXPECT_EQ(volume_mute, delegate->last_accelerator()); |
1433 EXPECT_EQ(0, delegate->handle_volume_down_count()); | 1433 EXPECT_EQ(0, delegate->handle_volume_down_count()); |
1434 EXPECT_TRUE(ProcessInController(volume_down)); | 1434 EXPECT_TRUE(ProcessInController(volume_down)); |
1435 EXPECT_EQ(1, delegate->handle_volume_down_count()); | 1435 EXPECT_EQ(1, delegate->handle_volume_down_count()); |
1436 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1436 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
1437 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1437 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1438 EXPECT_TRUE(ProcessInController(volume_up)); | 1438 EXPECT_TRUE(ProcessInController(volume_up)); |
1439 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1439 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1440 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1440 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1441 } | 1441 } |
1442 } | 1442 } |
1443 #endif | 1443 #endif |
1444 | 1444 |
1445 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { | 1445 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
1446 AccessibilityDelegate* delegate = | 1446 AccessibilityDelegate* delegate = |
1447 ash::Shell::GetInstance()->accessibility_delegate(); | 1447 ash::Shell::GetInstance()->accessibility_delegate(); |
1448 | 1448 |
1449 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1449 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1450 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); | 1450 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); |
1451 EXPECT_TRUE( | 1451 EXPECT_TRUE( |
1452 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1452 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
1453 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), | 1453 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), |
1454 ui::A11Y_ALERT_WINDOW_NEEDED); | 1454 ui::A11Y_ALERT_WINDOW_NEEDED); |
1455 } | 1455 } |
1456 | 1456 |
1457 // Make sure we don't alert if we do have a window. | 1457 // Make sure we don't alert if we do have a window. |
1458 scoped_ptr<aura::Window> window; | 1458 std::unique_ptr<aura::Window> window; |
1459 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1459 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1460 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1460 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1461 wm::ActivateWindow(window.get()); | 1461 wm::ActivateWindow(window.get()); |
1462 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); | 1462 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); |
1463 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1463 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
1464 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 1464 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
1465 ui::A11Y_ALERT_WINDOW_NEEDED); | 1465 ui::A11Y_ALERT_WINDOW_NEEDED); |
1466 } | 1466 } |
1467 | 1467 |
1468 // Don't alert if we have a minimized window either. | 1468 // Don't alert if we have a minimized window either. |
(...skipping 16 matching lines...) Expand all Loading... |
1485 public: | 1485 public: |
1486 DeprecatedAcceleratorTester() {} | 1486 DeprecatedAcceleratorTester() {} |
1487 ~DeprecatedAcceleratorTester() override {} | 1487 ~DeprecatedAcceleratorTester() override {} |
1488 | 1488 |
1489 void SetUp() override { | 1489 void SetUp() override { |
1490 AcceleratorControllerTest::SetUp(); | 1490 AcceleratorControllerTest::SetUp(); |
1491 | 1491 |
1492 // For testing the deprecated and new IME shortcuts. | 1492 // For testing the deprecated and new IME shortcuts. |
1493 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1493 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
1494 GetController()->SetImeControlDelegate( | 1494 GetController()->SetImeControlDelegate( |
1495 scoped_ptr<ImeControlDelegate>(delegate)); | 1495 std::unique_ptr<ImeControlDelegate>(delegate)); |
1496 } | 1496 } |
1497 | 1497 |
1498 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const { | 1498 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const { |
1499 ui::Accelerator result(data.keycode, data.modifiers); | 1499 ui::Accelerator result(data.keycode, data.modifiers); |
1500 result.set_type(data.trigger_on_press ? ui::ET_KEY_PRESSED | 1500 result.set_type(data.trigger_on_press ? ui::ET_KEY_PRESSED |
1501 : ui::ET_KEY_RELEASED); | 1501 : ui::ET_KEY_RELEASED); |
1502 return result; | 1502 return result; |
1503 } | 1503 } |
1504 | 1504 |
1505 void ResetStateIfNeeded() { | 1505 void ResetStateIfNeeded() { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 EXPECT_TRUE(IsMessageCenterEmpty()); | 1576 EXPECT_TRUE(IsMessageCenterEmpty()); |
1577 | 1577 |
1578 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1578 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1579 // screen before we proceed testing the rest of accelerators. | 1579 // screen before we proceed testing the rest of accelerators. |
1580 ResetStateIfNeeded(); | 1580 ResetStateIfNeeded(); |
1581 } | 1581 } |
1582 } | 1582 } |
1583 #endif // defined(OS_CHROMEOS) | 1583 #endif // defined(OS_CHROMEOS) |
1584 | 1584 |
1585 } // namespace ash | 1585 } // namespace ash |
OLD | NEW |