Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 11417144: Use rewriting to make ChromeOS keyboard F<number> keys produce extended keycodes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding3 Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/accelerators/accelerator_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ash/accelerators/accelerator_table.h" 6 #include "ash/accelerators/accelerator_table.h"
7 #include "ash/caps_lock_delegate.h" 7 #include "ash/caps_lock_delegate.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/ime_control_delegate.h" 9 #include "ash/ime_control_delegate.h"
10 #include "ash/screenshot_delegate.h" 10 #include "ash/screenshot_delegate.h"
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { 592 TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
593 // CycleBackward 593 // CycleBackward
594 EXPECT_TRUE(ProcessWithContext( 594 EXPECT_TRUE(ProcessWithContext(
595 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); 595 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)));
596 // CycleForward 596 // CycleForward
597 EXPECT_TRUE(ProcessWithContext( 597 EXPECT_TRUE(ProcessWithContext(
598 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); 598 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN)));
599 #if defined(OS_CHROMEOS) 599 #if defined(OS_CHROMEOS)
600 // CycleBackward 600 // CycleBackward
601 EXPECT_TRUE(ProcessWithContext( 601 EXPECT_TRUE(ProcessWithContext(
602 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN))); 602 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN)));
603 // CycleForward 603 // CycleForward
604 EXPECT_TRUE(ProcessWithContext( 604 EXPECT_TRUE(ProcessWithContext(
605 ui::Accelerator(ui::VKEY_F5, ui::EF_NONE))); 605 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE)));
606 606
607 // Take screenshot / partial screenshot 607 // Take screenshot / partial screenshot
608 // True should always be returned regardless of the existence of the delegate. 608 // True should always be returned regardless of the existence of the delegate.
609 { 609 {
610 EXPECT_TRUE(ProcessWithContext( 610 EXPECT_TRUE(ProcessWithContext(
611 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); 611 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN)));
612 EXPECT_TRUE(ProcessWithContext( 612 EXPECT_TRUE(ProcessWithContext(
613 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); 613 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE)));
614 EXPECT_TRUE(ProcessWithContext( 614 EXPECT_TRUE(ProcessWithContext(
615 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 615 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1,
616 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
616 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate; 617 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
617 GetController()->SetScreenshotDelegate( 618 GetController()->SetScreenshotDelegate(
618 scoped_ptr<ScreenshotDelegate>(delegate).Pass()); 619 scoped_ptr<ScreenshotDelegate>(delegate).Pass());
619 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); 620 EXPECT_EQ(0, delegate->handle_take_screenshot_count());
620 EXPECT_TRUE(ProcessWithContext( 621 EXPECT_TRUE(ProcessWithContext(
621 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); 622 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN)));
622 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); 623 EXPECT_EQ(1, delegate->handle_take_screenshot_count());
623 EXPECT_TRUE(ProcessWithContext( 624 EXPECT_TRUE(ProcessWithContext(
624 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); 625 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE)));
625 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 626 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
626 EXPECT_TRUE(ProcessWithContext( 627 EXPECT_TRUE(ProcessWithContext(
627 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 628 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1,
629 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
628 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 630 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
629 } 631 }
630 #endif 632 #endif
631 // DisableCapsLock 633 // DisableCapsLock
632 { 634 {
633 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate(); 635 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate();
634 delegate->SetCapsLockEnabled(true); 636 delegate->SetCapsLockEnabled(true);
635 EXPECT_TRUE(delegate->IsCapsLockEnabled()); 637 EXPECT_TRUE(delegate->IsCapsLockEnabled());
636 // Handled only on key release. 638 // Handled only on key release.
637 EXPECT_FALSE(ProcessWithContext( 639 EXPECT_FALSE(ProcessWithContext(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate(); 686 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate();
685 delegate->SetCapsLockEnabled(true); 687 delegate->SetCapsLockEnabled(true);
686 EXPECT_TRUE(delegate->IsCapsLockEnabled()); 688 EXPECT_TRUE(delegate->IsCapsLockEnabled());
687 EXPECT_TRUE(ProcessWithContext( 689 EXPECT_TRUE(ProcessWithContext(
688 ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN))); 690 ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)));
689 EXPECT_FALSE(delegate->IsCapsLockEnabled()); 691 EXPECT_FALSE(delegate->IsCapsLockEnabled());
690 EXPECT_TRUE(ProcessWithContext( 692 EXPECT_TRUE(ProcessWithContext(
691 ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN))); 693 ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)));
692 EXPECT_TRUE(delegate->IsCapsLockEnabled()); 694 EXPECT_TRUE(delegate->IsCapsLockEnabled());
693 } 695 }
694 #if defined(OS_CHROMEOS)
695 // Volume
696 const ui::Accelerator f8(ui::VKEY_F8, ui::EF_NONE);
697 const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE);
698 const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE);
699 {
700 EXPECT_TRUE(ProcessWithContext(f8));
701 EXPECT_TRUE(ProcessWithContext(f9));
702 EXPECT_TRUE(ProcessWithContext(f10));
703 DummyVolumeControlDelegate* delegate =
704 new DummyVolumeControlDelegate(false);
705 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
706 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
707 EXPECT_EQ(0, delegate->handle_volume_mute_count());
708 EXPECT_FALSE(ProcessWithContext(f8));
709 EXPECT_EQ(1, delegate->handle_volume_mute_count());
710 EXPECT_EQ(f8, delegate->last_accelerator());
711 EXPECT_EQ(0, delegate->handle_volume_down_count());
712 EXPECT_FALSE(ProcessWithContext(f9));
713 EXPECT_EQ(1, delegate->handle_volume_down_count());
714 EXPECT_EQ(f9, delegate->last_accelerator());
715 EXPECT_EQ(0, delegate->handle_volume_up_count());
716 EXPECT_FALSE(ProcessWithContext(f10));
717 EXPECT_EQ(1, delegate->handle_volume_up_count());
718 EXPECT_EQ(f10, delegate->last_accelerator());
719 }
720 {
721 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
722 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
723 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
724 EXPECT_EQ(0, delegate->handle_volume_mute_count());
725 EXPECT_TRUE(ProcessWithContext(f8));
726 EXPECT_EQ(1, delegate->handle_volume_mute_count());
727 EXPECT_EQ(f8, delegate->last_accelerator());
728 EXPECT_EQ(0, delegate->handle_volume_down_count());
729 EXPECT_TRUE(ProcessWithContext(f9));
730 EXPECT_EQ(1, delegate->handle_volume_down_count());
731 EXPECT_EQ(f9, delegate->last_accelerator());
732 EXPECT_EQ(0, delegate->handle_volume_up_count());
733 EXPECT_TRUE(ProcessWithContext(f10));
734 EXPECT_EQ(1, delegate->handle_volume_up_count());
735 EXPECT_EQ(f10, delegate->last_accelerator());
736 }
737 #endif
738 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 696 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
739 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 697 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
740 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 698 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
741 { 699 {
742 DummyVolumeControlDelegate* delegate = 700 DummyVolumeControlDelegate* delegate =
743 new DummyVolumeControlDelegate(false); 701 new DummyVolumeControlDelegate(false);
744 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( 702 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
745 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 703 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
746 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 704 EXPECT_EQ(0, delegate->handle_volume_mute_count());
747 EXPECT_FALSE(ProcessWithContext(volume_mute)); 705 EXPECT_FALSE(ProcessWithContext(volume_mute));
(...skipping 20 matching lines...) Expand all
768 EXPECT_TRUE(ProcessWithContext(volume_down)); 726 EXPECT_TRUE(ProcessWithContext(volume_down));
769 EXPECT_EQ(1, delegate->handle_volume_down_count()); 727 EXPECT_EQ(1, delegate->handle_volume_down_count());
770 EXPECT_EQ(volume_down, delegate->last_accelerator()); 728 EXPECT_EQ(volume_down, delegate->last_accelerator());
771 EXPECT_EQ(0, delegate->handle_volume_up_count()); 729 EXPECT_EQ(0, delegate->handle_volume_up_count());
772 EXPECT_TRUE(ProcessWithContext(volume_up)); 730 EXPECT_TRUE(ProcessWithContext(volume_up));
773 EXPECT_EQ(1, delegate->handle_volume_up_count()); 731 EXPECT_EQ(1, delegate->handle_volume_up_count());
774 EXPECT_EQ(volume_up, delegate->last_accelerator()); 732 EXPECT_EQ(volume_up, delegate->last_accelerator());
775 } 733 }
776 #if defined(OS_CHROMEOS) 734 #if defined(OS_CHROMEOS)
777 // Brightness 735 // Brightness
778 const ui::Accelerator f6(ui::VKEY_F6, ui::EF_NONE); 736 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows.
779 const ui::Accelerator f7(ui::VKEY_F7, ui::EF_NONE); 737 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
738 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
780 { 739 {
781 EXPECT_FALSE(ProcessWithContext(f6)); 740 EXPECT_FALSE(ProcessWithContext(brightness_down));
782 EXPECT_FALSE(ProcessWithContext(f7)); 741 EXPECT_FALSE(ProcessWithContext(brightness_up));
783 DummyBrightnessControlDelegate* delegate = 742 DummyBrightnessControlDelegate* delegate =
784 new DummyBrightnessControlDelegate(true); 743 new DummyBrightnessControlDelegate(true);
785 GetController()->SetBrightnessControlDelegate( 744 GetController()->SetBrightnessControlDelegate(
786 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 745 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
787 EXPECT_FALSE(ProcessWithContext(f6)); 746 EXPECT_FALSE(ProcessWithContext(brightness_down));
788 EXPECT_FALSE(ProcessWithContext(f7)); 747 EXPECT_FALSE(ProcessWithContext(brightness_up));
789 } 748 }
790 // Enable internal display. 749 // Enable internal display.
791 EnableInternalDisplay(); 750 EnableInternalDisplay();
792 { 751 {
793 EXPECT_FALSE(ProcessWithContext(f6));
794 EXPECT_FALSE(ProcessWithContext(f7));
795 DummyBrightnessControlDelegate* delegate = 752 DummyBrightnessControlDelegate* delegate =
796 new DummyBrightnessControlDelegate(false); 753 new DummyBrightnessControlDelegate(false);
797 GetController()->SetBrightnessControlDelegate( 754 GetController()->SetBrightnessControlDelegate(
798 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
799 EXPECT_EQ(0, delegate->handle_brightness_down_count());
800 EXPECT_FALSE(ProcessWithContext(f6));
801 EXPECT_EQ(1, delegate->handle_brightness_down_count());
802 EXPECT_EQ(f6, delegate->last_accelerator());
803 EXPECT_EQ(0, delegate->handle_brightness_up_count());
804 EXPECT_FALSE(ProcessWithContext(f7));
805 EXPECT_EQ(1, delegate->handle_brightness_up_count());
806 EXPECT_EQ(f7, delegate->last_accelerator());
807 }
808 {
809 DummyBrightnessControlDelegate* delegate =
810 new DummyBrightnessControlDelegate(true);
811 GetController()->SetBrightnessControlDelegate(
812 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
813 EXPECT_EQ(0, delegate->handle_brightness_down_count());
814 EXPECT_TRUE(ProcessWithContext(f6));
815 EXPECT_EQ(1, delegate->handle_brightness_down_count());
816 EXPECT_EQ(f6, delegate->last_accelerator());
817 EXPECT_EQ(0, delegate->handle_brightness_up_count());
818 EXPECT_TRUE(ProcessWithContext(f7));
819 EXPECT_EQ(1, delegate->handle_brightness_up_count());
820 EXPECT_EQ(f7, delegate->last_accelerator());
821 }
822 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows.
823 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
824 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
825 {
826 DummyBrightnessControlDelegate* delegate =
827 new DummyBrightnessControlDelegate(false);
828 GetController()->SetBrightnessControlDelegate(
829 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 755 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
830 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 756 EXPECT_EQ(0, delegate->handle_brightness_down_count());
831 EXPECT_FALSE(ProcessWithContext(brightness_down)); 757 EXPECT_FALSE(ProcessWithContext(brightness_down));
832 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 758 EXPECT_EQ(1, delegate->handle_brightness_down_count());
833 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 759 EXPECT_EQ(brightness_down, delegate->last_accelerator());
834 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 760 EXPECT_EQ(0, delegate->handle_brightness_up_count());
835 EXPECT_FALSE(ProcessWithContext(brightness_up)); 761 EXPECT_FALSE(ProcessWithContext(brightness_up));
836 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 762 EXPECT_EQ(1, delegate->handle_brightness_up_count());
837 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 763 EXPECT_EQ(brightness_up, delegate->last_accelerator());
838 } 764 }
839 { 765 {
840 DummyBrightnessControlDelegate* delegate = 766 DummyBrightnessControlDelegate* delegate =
841 new DummyBrightnessControlDelegate(true); 767 new DummyBrightnessControlDelegate(true);
842 GetController()->SetBrightnessControlDelegate( 768 GetController()->SetBrightnessControlDelegate(
843 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 769 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
844 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 770 EXPECT_EQ(0, delegate->handle_brightness_down_count());
845 EXPECT_TRUE(ProcessWithContext(brightness_down)); 771 EXPECT_TRUE(ProcessWithContext(brightness_down));
846 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 772 EXPECT_EQ(1, delegate->handle_brightness_down_count());
847 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 773 EXPECT_EQ(brightness_down, delegate->last_accelerator());
848 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 774 EXPECT_EQ(0, delegate->handle_brightness_up_count());
849 EXPECT_TRUE(ProcessWithContext(brightness_up)); 775 EXPECT_TRUE(ProcessWithContext(brightness_up));
850 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 776 EXPECT_EQ(1, delegate->handle_brightness_up_count());
851 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 777 EXPECT_EQ(brightness_up, delegate->last_accelerator());
852 } 778 }
853 779
854 // Keyboard brightness 780 // Keyboard brightness
855 const ui::Accelerator alt_f6(ui::VKEY_F6, ui::EF_ALT_DOWN); 781 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN,
856 const ui::Accelerator alt_f7(ui::VKEY_F7, ui::EF_ALT_DOWN); 782 ui::EF_ALT_DOWN);
783 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP,
784 ui::EF_ALT_DOWN);
857 { 785 {
858 EXPECT_TRUE(ProcessWithContext(alt_f6)); 786 EXPECT_TRUE(ProcessWithContext(alt_brightness_down));
859 EXPECT_TRUE(ProcessWithContext(alt_f7)); 787 EXPECT_TRUE(ProcessWithContext(alt_brightness_up));
860 DummyKeyboardBrightnessControlDelegate* delegate = 788 DummyKeyboardBrightnessControlDelegate* delegate =
861 new DummyKeyboardBrightnessControlDelegate(false); 789 new DummyKeyboardBrightnessControlDelegate(false);
862 GetController()->SetKeyboardBrightnessControlDelegate( 790 GetController()->SetKeyboardBrightnessControlDelegate(
863 scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass()); 791 scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass());
864 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); 792 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count());
865 EXPECT_FALSE(ProcessWithContext(alt_f6)); 793 EXPECT_FALSE(ProcessWithContext(alt_brightness_down));
866 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); 794 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count());
867 EXPECT_EQ(alt_f6, delegate->last_accelerator()); 795 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator());
868 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); 796 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count());
869 EXPECT_FALSE(ProcessWithContext(alt_f7)); 797 EXPECT_FALSE(ProcessWithContext(alt_brightness_up));
870 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); 798 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count());
871 EXPECT_EQ(alt_f7, delegate->last_accelerator()); 799 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator());
872 } 800 }
873 { 801 {
874 DummyKeyboardBrightnessControlDelegate* delegate = 802 DummyKeyboardBrightnessControlDelegate* delegate =
875 new DummyKeyboardBrightnessControlDelegate(true); 803 new DummyKeyboardBrightnessControlDelegate(true);
876 GetController()->SetKeyboardBrightnessControlDelegate( 804 GetController()->SetKeyboardBrightnessControlDelegate(
877 scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass()); 805 scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass());
878 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); 806 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count());
879 EXPECT_TRUE(ProcessWithContext(alt_f6)); 807 EXPECT_TRUE(ProcessWithContext(alt_brightness_down));
880 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); 808 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count());
881 EXPECT_EQ(alt_f6, delegate->last_accelerator()); 809 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator());
882 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); 810 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count());
883 EXPECT_TRUE(ProcessWithContext(alt_f7)); 811 EXPECT_TRUE(ProcessWithContext(alt_brightness_up));
884 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); 812 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count());
885 EXPECT_EQ(alt_f7, delegate->last_accelerator()); 813 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator());
886 } 814 }
887 #endif 815 #endif
888 816
889 #if !defined(NDEBUG) 817 #if !defined(NDEBUG)
890 // RotateScreen 818 // RotateScreen
891 EXPECT_TRUE(ProcessWithContext( 819 EXPECT_TRUE(ProcessWithContext(
892 ui::Accelerator(ui::VKEY_HOME, ui::EF_CONTROL_DOWN))); 820 ui::Accelerator(ui::VKEY_HOME, ui::EF_CONTROL_DOWN)));
893 // ToggleDesktopBackgroundMode 821 // ToggleDesktopBackgroundMode
894 EXPECT_TRUE(ProcessWithContext( 822 EXPECT_TRUE(ProcessWithContext(
895 ui::Accelerator(ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))); 823 ui::Accelerator(ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)));
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 EXPECT_TRUE(GetController()->PerformAction(*it, dummy)) 1145 EXPECT_TRUE(GetController()->PerformAction(*it, dummy))
1218 << " for action (disallowed at modal window): " << *it; 1146 << " for action (disallowed at modal window): " << *it;
1219 } 1147 }
1220 } 1148 }
1221 // Testing of top row (F5-F10) accelerators that should still work 1149 // Testing of top row (F5-F10) accelerators that should still work
1222 // when a modal window is open 1150 // when a modal window is open
1223 // 1151 //
1224 // Screenshot 1152 // Screenshot
1225 { 1153 {
1226 EXPECT_TRUE(ProcessWithContext( 1154 EXPECT_TRUE(ProcessWithContext(
1227 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); 1155 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN)));
1228 EXPECT_TRUE(ProcessWithContext( 1156 EXPECT_TRUE(ProcessWithContext(
1229 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); 1157 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE)));
1230 EXPECT_TRUE(ProcessWithContext( 1158 EXPECT_TRUE(ProcessWithContext(
1231 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 1159 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1,
1160 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
1232 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate; 1161 DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
1233 GetController()->SetScreenshotDelegate( 1162 GetController()->SetScreenshotDelegate(
1234 scoped_ptr<ScreenshotDelegate>(delegate).Pass()); 1163 scoped_ptr<ScreenshotDelegate>(delegate).Pass());
1235 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); 1164 EXPECT_EQ(0, delegate->handle_take_screenshot_count());
1236 EXPECT_TRUE(ProcessWithContext( 1165 EXPECT_TRUE(ProcessWithContext(
1237 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); 1166 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN)));
1238 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); 1167 EXPECT_EQ(1, delegate->handle_take_screenshot_count());
1239 EXPECT_TRUE(ProcessWithContext( 1168 EXPECT_TRUE(ProcessWithContext(
1240 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); 1169 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE)));
1241 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 1170 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
1242 EXPECT_TRUE(ProcessWithContext( 1171 EXPECT_TRUE(ProcessWithContext(
1243 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 1172 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1,
1173 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
1244 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 1174 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
1245 } 1175 }
1246 // Brightness 1176 // Brightness
1247 const ui::Accelerator f6(ui::VKEY_F6, ui::EF_NONE); 1177 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
1248 const ui::Accelerator f7(ui::VKEY_F7, ui::EF_NONE); 1178 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
1249 { 1179 {
1250 EXPECT_FALSE(ProcessWithContext(f6)); 1180 EXPECT_FALSE(ProcessWithContext(brightness_down));
1251 EXPECT_FALSE(ProcessWithContext(f7)); 1181 EXPECT_FALSE(ProcessWithContext(brightness_up));
1252 DummyBrightnessControlDelegate* delegate = 1182 DummyBrightnessControlDelegate* delegate =
1253 new DummyBrightnessControlDelegate(true); 1183 new DummyBrightnessControlDelegate(true);
1254 GetController()->SetBrightnessControlDelegate( 1184 GetController()->SetBrightnessControlDelegate(
1255 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 1185 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
1256 EXPECT_FALSE(ProcessWithContext(f6)); 1186 EXPECT_FALSE(ProcessWithContext(brightness_down));
1257 EXPECT_FALSE(ProcessWithContext(f7)); 1187 EXPECT_FALSE(ProcessWithContext(brightness_up));
1258 } 1188 }
1259 EnableInternalDisplay(); 1189 EnableInternalDisplay();
1260 { 1190 {
1261 EXPECT_FALSE(ProcessWithContext(f6)); 1191 EXPECT_FALSE(ProcessWithContext(brightness_down));
1262 EXPECT_FALSE(ProcessWithContext(f7)); 1192 EXPECT_FALSE(ProcessWithContext(brightness_up));
1263 DummyBrightnessControlDelegate* delegate = 1193 DummyBrightnessControlDelegate* delegate =
1264 new DummyBrightnessControlDelegate(false); 1194 new DummyBrightnessControlDelegate(false);
1265 GetController()->SetBrightnessControlDelegate( 1195 GetController()->SetBrightnessControlDelegate(
1266 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 1196 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
1267 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 1197 EXPECT_EQ(0, delegate->handle_brightness_down_count());
1268 EXPECT_FALSE(ProcessWithContext(f6)); 1198 EXPECT_FALSE(ProcessWithContext(brightness_down));
1269 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 1199 EXPECT_EQ(1, delegate->handle_brightness_down_count());
1270 EXPECT_EQ(f6, delegate->last_accelerator()); 1200 EXPECT_EQ(brightness_down, delegate->last_accelerator());
1271 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 1201 EXPECT_EQ(0, delegate->handle_brightness_up_count());
1272 EXPECT_FALSE(ProcessWithContext(f7)); 1202 EXPECT_FALSE(ProcessWithContext(brightness_up));
1273 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 1203 EXPECT_EQ(1, delegate->handle_brightness_up_count());
1274 EXPECT_EQ(f7, delegate->last_accelerator()); 1204 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1275 } 1205 }
1276 { 1206 {
1277 DummyBrightnessControlDelegate* delegate = 1207 DummyBrightnessControlDelegate* delegate =
1278 new DummyBrightnessControlDelegate(true); 1208 new DummyBrightnessControlDelegate(true);
1279 GetController()->SetBrightnessControlDelegate( 1209 GetController()->SetBrightnessControlDelegate(
1280 scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); 1210 scoped_ptr<BrightnessControlDelegate>(delegate).Pass());
1281 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 1211 EXPECT_EQ(0, delegate->handle_brightness_down_count());
1282 EXPECT_TRUE(ProcessWithContext(f6)); 1212 EXPECT_TRUE(ProcessWithContext(brightness_down));
1283 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 1213 EXPECT_EQ(1, delegate->handle_brightness_down_count());
1284 EXPECT_EQ(f6, delegate->last_accelerator()); 1214 EXPECT_EQ(brightness_down, delegate->last_accelerator());
1285 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 1215 EXPECT_EQ(0, delegate->handle_brightness_up_count());
1286 EXPECT_TRUE(ProcessWithContext(f7)); 1216 EXPECT_TRUE(ProcessWithContext(brightness_up));
1287 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 1217 EXPECT_EQ(1, delegate->handle_brightness_up_count());
1288 EXPECT_EQ(f7, delegate->last_accelerator()); 1218 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1289 } 1219 }
1290 // Volume 1220 // Volume
1291 const ui::Accelerator f8(ui::VKEY_F8, ui::EF_NONE); 1221 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
1292 const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE); 1222 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
1293 const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE); 1223 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
1294 { 1224 {
1295 EXPECT_TRUE(ProcessWithContext(f8)); 1225 EXPECT_TRUE(ProcessWithContext(volume_mute));
1296 EXPECT_TRUE(ProcessWithContext(f9)); 1226 EXPECT_TRUE(ProcessWithContext(volume_down));
1297 EXPECT_TRUE(ProcessWithContext(f10)); 1227 EXPECT_TRUE(ProcessWithContext(volume_up));
1298 DummyVolumeControlDelegate* delegate = 1228 DummyVolumeControlDelegate* delegate =
1299 new DummyVolumeControlDelegate(false); 1229 new DummyVolumeControlDelegate(false);
1300 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( 1230 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
1301 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 1231 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
1302 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 1232 EXPECT_EQ(0, delegate->handle_volume_mute_count());
1303 EXPECT_FALSE(ProcessWithContext(f8)); 1233 EXPECT_FALSE(ProcessWithContext(volume_mute));
1304 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 1234 EXPECT_EQ(1, delegate->handle_volume_mute_count());
1305 EXPECT_EQ(f8, delegate->last_accelerator()); 1235 EXPECT_EQ(volume_mute, delegate->last_accelerator());
1306 EXPECT_EQ(0, delegate->handle_volume_down_count()); 1236 EXPECT_EQ(0, delegate->handle_volume_down_count());
1307 EXPECT_FALSE(ProcessWithContext(f9)); 1237 EXPECT_FALSE(ProcessWithContext(volume_down));
1308 EXPECT_EQ(1, delegate->handle_volume_down_count()); 1238 EXPECT_EQ(1, delegate->handle_volume_down_count());
1309 EXPECT_EQ(f9, delegate->last_accelerator()); 1239 EXPECT_EQ(volume_down, delegate->last_accelerator());
1310 EXPECT_EQ(0, delegate->handle_volume_up_count()); 1240 EXPECT_EQ(0, delegate->handle_volume_up_count());
1311 EXPECT_FALSE(ProcessWithContext(f10)); 1241 EXPECT_FALSE(ProcessWithContext(volume_up));
1312 EXPECT_EQ(1, delegate->handle_volume_up_count()); 1242 EXPECT_EQ(1, delegate->handle_volume_up_count());
1313 EXPECT_EQ(f10, delegate->last_accelerator()); 1243 EXPECT_EQ(volume_up, delegate->last_accelerator());
1314 } 1244 }
1315 { 1245 {
1316 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true); 1246 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true);
1317 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( 1247 ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate(
1318 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 1248 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
1319 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 1249 EXPECT_EQ(0, delegate->handle_volume_mute_count());
1320 EXPECT_TRUE(ProcessWithContext(f8)); 1250 EXPECT_TRUE(ProcessWithContext(volume_mute));
1321 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 1251 EXPECT_EQ(1, delegate->handle_volume_mute_count());
1322 EXPECT_EQ(f8, delegate->last_accelerator()); 1252 EXPECT_EQ(volume_mute, delegate->last_accelerator());
1323 EXPECT_EQ(0, delegate->handle_volume_down_count()); 1253 EXPECT_EQ(0, delegate->handle_volume_down_count());
1324 EXPECT_TRUE(ProcessWithContext(f9)); 1254 EXPECT_TRUE(ProcessWithContext(volume_down));
1325 EXPECT_EQ(1, delegate->handle_volume_down_count()); 1255 EXPECT_EQ(1, delegate->handle_volume_down_count());
1326 EXPECT_EQ(f9, delegate->last_accelerator()); 1256 EXPECT_EQ(volume_down, delegate->last_accelerator());
1327 EXPECT_EQ(0, delegate->handle_volume_up_count()); 1257 EXPECT_EQ(0, delegate->handle_volume_up_count());
1328 EXPECT_TRUE(ProcessWithContext(f10)); 1258 EXPECT_TRUE(ProcessWithContext(volume_up));
1329 EXPECT_EQ(1, delegate->handle_volume_up_count()); 1259 EXPECT_EQ(1, delegate->handle_volume_up_count());
1330 EXPECT_EQ(f10, delegate->last_accelerator()); 1260 EXPECT_EQ(volume_up, delegate->last_accelerator());
1331 } 1261 }
1332 } 1262 }
1333 #endif 1263 #endif
1334 1264
1335 } // namespace ash 1265 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/accelerators/accelerator_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698