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

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

Issue 251193005: Enabled volume buttons when TouchView is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Jon's comments from Patch Set 2 Created 6 years, 7 months 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
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/test/volume_control_delegate_stub.h » ('J')
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
6 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
7 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
8 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
9 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
10 #include "ash/ime_control_delegate.h" 11 #include "ash/ime_control_delegate.h"
11 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
14 #include "ash/system/brightness_control_delegate.h" 15 #include "ash/system/brightness_control_delegate.h"
15 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 16 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
16 #include "ash/system/tray/system_tray_delegate.h" 17 #include "ash/system/tray/system_tray_delegate.h"
17 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
18 #include "ash/test/display_manager_test_api.h" 19 #include "ash/test/display_manager_test_api.h"
19 #include "ash/test/test_screenshot_delegate.h" 20 #include "ash/test/test_screenshot_delegate.h"
20 #include "ash/test/test_shell_delegate.h" 21 #include "ash/test/test_shell_delegate.h"
22 #include "ash/test/volume_control_delegate_stub.h"
21 #include "ash/volume_control_delegate.h" 23 #include "ash/volume_control_delegate.h"
22 #include "ash/wm/window_state.h" 24 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 25 #include "ash/wm/window_util.h"
24 #include "base/command_line.h" 26 #include "base/command_line.h"
25 #include "ui/aura/test/test_window_delegate.h" 27 #include "ui/aura/test/test_window_delegate.h"
26 #include "ui/aura/test/test_windows.h" 28 #include "ui/aura/test/test_windows.h"
27 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
28 #include "ui/events/event.h" 30 #include "ui/events/event.h"
29 #include "ui/events/event_processor.h" 31 #include "ui/events/event_processor.h"
30 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 }; 64 };
63 65
64 class ReleaseAccelerator : public ui::Accelerator { 66 class ReleaseAccelerator : public ui::Accelerator {
65 public: 67 public:
66 ReleaseAccelerator(ui::KeyboardCode keycode, int modifiers) 68 ReleaseAccelerator(ui::KeyboardCode keycode, int modifiers)
67 : ui::Accelerator(keycode, modifiers) { 69 : ui::Accelerator(keycode, modifiers) {
68 set_type(ui::ET_KEY_RELEASED); 70 set_type(ui::ET_KEY_RELEASED);
69 } 71 }
70 }; 72 };
71 73
72 class DummyVolumeControlDelegate : public VolumeControlDelegate {
73 public:
74 explicit DummyVolumeControlDelegate(bool consume)
75 : consume_(consume),
76 handle_volume_mute_count_(0),
77 handle_volume_down_count_(0),
78 handle_volume_up_count_(0) {
79 }
80 virtual ~DummyVolumeControlDelegate() {}
81
82 virtual bool HandleVolumeMute(const ui::Accelerator& accelerator) OVERRIDE {
83 ++handle_volume_mute_count_;
84 last_accelerator_ = accelerator;
85 return consume_;
86 }
87 virtual bool HandleVolumeDown(const ui::Accelerator& accelerator) OVERRIDE {
88 ++handle_volume_down_count_;
89 last_accelerator_ = accelerator;
90 return consume_;
91 }
92 virtual bool HandleVolumeUp(const ui::Accelerator& accelerator) OVERRIDE {
93 ++handle_volume_up_count_;
94 last_accelerator_ = accelerator;
95 return consume_;
96 }
97
98 int handle_volume_mute_count() const {
99 return handle_volume_mute_count_;
100 }
101 int handle_volume_down_count() const {
102 return handle_volume_down_count_;
103 }
104 int handle_volume_up_count() const {
105 return handle_volume_up_count_;
106 }
107 const ui::Accelerator& last_accelerator() const {
108 return last_accelerator_;
109 }
110
111 private:
112 const bool consume_;
113 int handle_volume_mute_count_;
114 int handle_volume_down_count_;
115 int handle_volume_up_count_;
116 ui::Accelerator last_accelerator_;
117
118 DISALLOW_COPY_AND_ASSIGN(DummyVolumeControlDelegate);
119 };
120
121 class DummyBrightnessControlDelegate : public BrightnessControlDelegate { 74 class DummyBrightnessControlDelegate : public BrightnessControlDelegate {
122 public: 75 public:
123 explicit DummyBrightnessControlDelegate(bool consume) 76 explicit DummyBrightnessControlDelegate(bool consume)
124 : consume_(consume), 77 : consume_(consume),
125 handle_brightness_down_count_(0), 78 handle_brightness_down_count_(0),
126 handle_brightness_up_count_(0) { 79 handle_brightness_up_count_(0) {
127 } 80 }
128 virtual ~DummyBrightnessControlDelegate() {} 81 virtual ~DummyBrightnessControlDelegate() {}
129 82
130 virtual bool HandleBrightnessDown( 83 virtual bool HandleBrightnessDown(
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 EXPECT_TRUE(ProcessWithContext( 660 EXPECT_TRUE(ProcessWithContext(
708 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, 661 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1,
709 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 662 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
710 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 663 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
711 } 664 }
712 #endif 665 #endif
713 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 666 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
714 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 667 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
715 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 668 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
716 { 669 {
717 DummyVolumeControlDelegate* delegate = 670 VolumeControlDelegateStub* delegate =
718 new DummyVolumeControlDelegate(false); 671 new VolumeControlDelegateStub(false);
719 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( 672 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
720 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 673 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
721 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 674 EXPECT_EQ(0, delegate->handle_volume_mute_count());
722 EXPECT_FALSE(ProcessWithContext(volume_mute)); 675 EXPECT_FALSE(ProcessWithContext(volume_mute));
723 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 676 EXPECT_EQ(1, delegate->handle_volume_mute_count());
724 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 677 EXPECT_EQ(volume_mute, delegate->last_accelerator());
725 EXPECT_EQ(0, delegate->handle_volume_down_count()); 678 EXPECT_EQ(0, delegate->handle_volume_down_count());
726 EXPECT_FALSE(ProcessWithContext(volume_down)); 679 EXPECT_FALSE(ProcessWithContext(volume_down));
727 EXPECT_EQ(1, delegate->handle_volume_down_count()); 680 EXPECT_EQ(1, delegate->handle_volume_down_count());
728 EXPECT_EQ(volume_down, delegate->last_accelerator()); 681 EXPECT_EQ(volume_down, delegate->last_accelerator());
729 EXPECT_EQ(0, delegate->handle_volume_up_count()); 682 EXPECT_EQ(0, delegate->handle_volume_up_count());
730 EXPECT_FALSE(ProcessWithContext(volume_up)); 683 EXPECT_FALSE(ProcessWithContext(volume_up));
731 EXPECT_EQ(1, delegate->handle_volume_up_count()); 684 EXPECT_EQ(1, delegate->handle_volume_up_count());
732 EXPECT_EQ(volume_up, delegate->last_accelerator()); 685 EXPECT_EQ(volume_up, delegate->last_accelerator());
733 } 686 }
734 { 687 {
735 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true); 688 VolumeControlDelegateStub* delegate = new VolumeControlDelegateStub(true);
736 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( 689 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
737 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 690 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
738 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 691 EXPECT_EQ(0, delegate->handle_volume_mute_count());
739 EXPECT_TRUE(ProcessWithContext(volume_mute)); 692 EXPECT_TRUE(ProcessWithContext(volume_mute));
740 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 693 EXPECT_EQ(1, delegate->handle_volume_mute_count());
741 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 694 EXPECT_EQ(volume_mute, delegate->last_accelerator());
742 EXPECT_EQ(0, delegate->handle_volume_down_count()); 695 EXPECT_EQ(0, delegate->handle_volume_down_count());
743 EXPECT_TRUE(ProcessWithContext(volume_down)); 696 EXPECT_TRUE(ProcessWithContext(volume_down));
744 EXPECT_EQ(1, delegate->handle_volume_down_count()); 697 EXPECT_EQ(1, delegate->handle_volume_down_count());
745 EXPECT_EQ(volume_down, delegate->last_accelerator()); 698 EXPECT_EQ(volume_down, delegate->last_accelerator());
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 1136 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1184 } 1137 }
1185 // Volume 1138 // Volume
1186 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 1139 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
1187 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 1140 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
1188 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 1141 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
1189 { 1142 {
1190 EXPECT_TRUE(ProcessWithContext(volume_mute)); 1143 EXPECT_TRUE(ProcessWithContext(volume_mute));
1191 EXPECT_TRUE(ProcessWithContext(volume_down)); 1144 EXPECT_TRUE(ProcessWithContext(volume_down));
1192 EXPECT_TRUE(ProcessWithContext(volume_up)); 1145 EXPECT_TRUE(ProcessWithContext(volume_up));
1193 DummyVolumeControlDelegate* delegate = 1146 VolumeControlDelegateStub* delegate =
1194 new DummyVolumeControlDelegate(false); 1147 new VolumeControlDelegateStub(false);
1195 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( 1148 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
1196 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 1149 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
1197 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 1150 EXPECT_EQ(0, delegate->handle_volume_mute_count());
1198 EXPECT_FALSE(ProcessWithContext(volume_mute)); 1151 EXPECT_FALSE(ProcessWithContext(volume_mute));
1199 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 1152 EXPECT_EQ(1, delegate->handle_volume_mute_count());
1200 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 1153 EXPECT_EQ(volume_mute, delegate->last_accelerator());
1201 EXPECT_EQ(0, delegate->handle_volume_down_count()); 1154 EXPECT_EQ(0, delegate->handle_volume_down_count());
1202 EXPECT_FALSE(ProcessWithContext(volume_down)); 1155 EXPECT_FALSE(ProcessWithContext(volume_down));
1203 EXPECT_EQ(1, delegate->handle_volume_down_count()); 1156 EXPECT_EQ(1, delegate->handle_volume_down_count());
1204 EXPECT_EQ(volume_down, delegate->last_accelerator()); 1157 EXPECT_EQ(volume_down, delegate->last_accelerator());
1205 EXPECT_EQ(0, delegate->handle_volume_up_count()); 1158 EXPECT_EQ(0, delegate->handle_volume_up_count());
1206 EXPECT_FALSE(ProcessWithContext(volume_up)); 1159 EXPECT_FALSE(ProcessWithContext(volume_up));
1207 EXPECT_EQ(1, delegate->handle_volume_up_count()); 1160 EXPECT_EQ(1, delegate->handle_volume_up_count());
1208 EXPECT_EQ(volume_up, delegate->last_accelerator()); 1161 EXPECT_EQ(volume_up, delegate->last_accelerator());
1209 } 1162 }
1210 { 1163 {
1211 DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(true); 1164 VolumeControlDelegateStub* delegate = new VolumeControlDelegateStub(true);
1212 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( 1165 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate(
1213 scoped_ptr<VolumeControlDelegate>(delegate).Pass()); 1166 scoped_ptr<VolumeControlDelegate>(delegate).Pass());
1214 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 1167 EXPECT_EQ(0, delegate->handle_volume_mute_count());
1215 EXPECT_TRUE(ProcessWithContext(volume_mute)); 1168 EXPECT_TRUE(ProcessWithContext(volume_mute));
1216 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 1169 EXPECT_EQ(1, delegate->handle_volume_mute_count());
1217 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 1170 EXPECT_EQ(volume_mute, delegate->last_accelerator());
1218 EXPECT_EQ(0, delegate->handle_volume_down_count()); 1171 EXPECT_EQ(0, delegate->handle_volume_down_count());
1219 EXPECT_TRUE(ProcessWithContext(volume_down)); 1172 EXPECT_TRUE(ProcessWithContext(volume_down));
1220 EXPECT_EQ(1, delegate->handle_volume_down_count()); 1173 EXPECT_EQ(1, delegate->handle_volume_down_count());
1221 EXPECT_EQ(volume_down, delegate->last_accelerator()); 1174 EXPECT_EQ(volume_down, delegate->last_accelerator());
(...skipping 30 matching lines...) Expand all
1252 // Don't alert if we have a minimized window either. 1205 // Don't alert if we have a minimized window either.
1253 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); 1206 GetController()->PerformAction(WINDOW_MINIMIZE, dummy);
1254 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1207 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
1255 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1208 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1256 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); 1209 GetController()->PerformAction(kActionsNeedingWindow[i], dummy);
1257 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE); 1210 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE);
1258 } 1211 }
1259 } 1212 }
1260 1213
1261 } // namespace ash 1214 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/ash.gyp » ('j') | ash/test/volume_control_delegate_stub.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698