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

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

Issue 2427913003: Use mojo volume interfaces for mash and classic ash. (Closed)
Patch Set: Split volume and system events observers; only hook up volume. Created 4 years, 2 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 | « ash/common/test/test_volume_control_delegate.cc ('k') | ash/public/interfaces/BUILD.gn » ('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/common/accelerators/accelerator_controller.h" 5 #include "ash/common/accelerators/accelerator_controller.h"
6 6
7 #include "ash/common/accelerators/accelerator_table.h" 7 #include "ash/common/accelerators/accelerator_table.h"
8 #include "ash/common/accessibility_delegate.h" 8 #include "ash/common/accessibility_delegate.h"
9 #include "ash/common/accessibility_types.h" 9 #include "ash/common/accessibility_types.h"
10 #include "ash/common/ime_control_delegate.h" 10 #include "ash/common/ime_control_delegate.h"
11 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/system/brightness_control_delegate.h" 12 #include "ash/common/system/brightness_control_delegate.h"
13 #include "ash/common/system/keyboard_brightness_control_delegate.h" 13 #include "ash/common/system/keyboard_brightness_control_delegate.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/system/volume_control_delegate.h"
16 #include "ash/common/test/ash_test.h" 15 #include "ash/common/test/ash_test.h"
17 #include "ash/common/test/test_volume_control_delegate.h"
18 #include "ash/common/wm/panels/panel_layout_manager.h" 16 #include "ash/common/wm/panels/panel_layout_manager.h"
19 #include "ash/common/wm/window_positioning_utils.h" 17 #include "ash/common/wm/window_positioning_utils.h"
20 #include "ash/common/wm/window_state.h" 18 #include "ash/common/wm/window_state.h"
21 #include "ash/common/wm/wm_event.h" 19 #include "ash/common/wm/wm_event.h"
22 #include "ash/common/wm_lookup.h" 20 #include "ash/common/wm_lookup.h"
23 #include "ash/common/wm_root_window_controller.h" 21 #include "ash/common/wm_root_window_controller.h"
24 #include "ash/common/wm_shell.h" 22 #include "ash/common/wm_shell.h"
25 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" 23 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h"
26 #include "ash/mus/bridge/wm_shell_mus_test_api.h" 24 #include "ash/mus/bridge/wm_shell_mus_test_api.h"
27 #include "ash/mus/bridge/wm_window_mus.h" 25 #include "ash/mus/bridge/wm_window_mus.h"
28 #include "ash/mus/property_util.h" 26 #include "ash/mus/property_util.h"
29 #include "ash/mus/test/wm_test_base.h" 27 #include "ash/mus/test/wm_test_base.h"
30 #include "ash/public/cpp/shell_window_ids.h" 28 #include "ash/public/cpp/shell_window_ids.h"
29 #include "base/test/user_action_tester.cc"
31 #include "ui/events/event.h" 30 #include "ui/events/event.h"
32 #include "ui/events/event_processor.h" 31 #include "ui/events/event_processor.h"
33 #include "ui/events/test/event_generator.h" 32 #include "ui/events/test/event_generator.h"
34 #include "ui/message_center/message_center.h" 33 #include "ui/message_center/message_center.h"
35 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
36 35
37 #if defined(USE_X11) 36 #if defined(USE_X11)
38 #include <X11/Xlib.h> 37 #include <X11/Xlib.h>
39 #include "ui/events/test/events_test_utils_x11.h" 38 #include "ui/events/test/events_test_utils_x11.h"
40 #endif 39 #endif
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 801 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
803 EXPECT_TRUE(ProcessInController(ui::Accelerator( 802 EXPECT_TRUE(ProcessInController(ui::Accelerator(
804 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 803 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
805 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 804 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
806 } 805 }
807 */ 806 */
808 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 807 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
809 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 808 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
810 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 809 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
811 { 810 {
812 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; 811 base::UserActionTester user_action_tester;
813 WmShell::Get()->system_tray_delegate()->SetVolumeControlDelegate( 812 ui::AcceleratorHistory* history = GetController()->accelerator_history();
814 std::unique_ptr<VolumeControlDelegate>(delegate)); 813
815 EXPECT_EQ(0, delegate->handle_volume_mute_count()); 814 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
816 EXPECT_TRUE(ProcessInController(volume_mute)); 815 EXPECT_TRUE(ProcessInController(volume_mute));
817 EXPECT_EQ(1, delegate->handle_volume_mute_count()); 816 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
818 EXPECT_EQ(volume_mute, delegate->last_accelerator()); 817 EXPECT_EQ(volume_mute, history->current_accelerator());
819 EXPECT_EQ(0, delegate->handle_volume_down_count()); 818
819 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
820 EXPECT_TRUE(ProcessInController(volume_down)); 820 EXPECT_TRUE(ProcessInController(volume_down));
821 EXPECT_EQ(1, delegate->handle_volume_down_count()); 821 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
822 EXPECT_EQ(volume_down, delegate->last_accelerator()); 822 EXPECT_EQ(volume_down, history->current_accelerator());
823 EXPECT_EQ(0, delegate->handle_volume_up_count()); 823
824 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
824 EXPECT_TRUE(ProcessInController(volume_up)); 825 EXPECT_TRUE(ProcessInController(volume_up));
825 EXPECT_EQ(1, delegate->handle_volume_up_count()); 826 EXPECT_EQ(volume_up, history->current_accelerator());
826 EXPECT_EQ(volume_up, delegate->last_accelerator()); 827 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
827 } 828 }
828 // Brightness 829 // Brightness
829 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows. 830 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows.
830 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); 831 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
831 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); 832 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
832 { 833 {
833 DummyBrightnessControlDelegate* delegate = 834 DummyBrightnessControlDelegate* delegate =
834 new DummyBrightnessControlDelegate; 835 new DummyBrightnessControlDelegate;
835 SetBrightnessControlDelegate( 836 SetBrightnessControlDelegate(
836 std::unique_ptr<BrightnessControlDelegate>(delegate)); 837 std::unique_ptr<BrightnessControlDelegate>(delegate));
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 1233 EXPECT_EQ(0, delegate->handle_brightness_up_count());
1233 EXPECT_TRUE(ProcessInController(brightness_up)); 1234 EXPECT_TRUE(ProcessInController(brightness_up));
1234 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 1235 EXPECT_EQ(1, delegate->handle_brightness_up_count());
1235 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 1236 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1236 } 1237 }
1237 // Volume 1238 // Volume
1238 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); 1239 const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE);
1239 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); 1240 const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
1240 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); 1241 const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE);
1241 { 1242 {
1243 base::UserActionTester user_action_tester;
1244 ui::AcceleratorHistory* history = GetController()->accelerator_history();
1245
1246 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
1242 EXPECT_TRUE(ProcessInController(volume_mute)); 1247 EXPECT_TRUE(ProcessInController(volume_mute));
1248 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
1249 EXPECT_EQ(volume_mute, history->current_accelerator());
1250
1251 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
1243 EXPECT_TRUE(ProcessInController(volume_down)); 1252 EXPECT_TRUE(ProcessInController(volume_down));
1253 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
1254 EXPECT_EQ(volume_down, history->current_accelerator());
1255
1256 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
1244 EXPECT_TRUE(ProcessInController(volume_up)); 1257 EXPECT_TRUE(ProcessInController(volume_up));
1245 TestVolumeControlDelegate* delegate = new TestVolumeControlDelegate; 1258 EXPECT_EQ(volume_up, history->current_accelerator());
1246 WmShell::Get()->system_tray_delegate()->SetVolumeControlDelegate( 1259 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
1247 std::unique_ptr<VolumeControlDelegate>(delegate));
1248 EXPECT_EQ(0, delegate->handle_volume_mute_count());
1249 EXPECT_TRUE(ProcessInController(volume_mute));
1250 EXPECT_EQ(1, delegate->handle_volume_mute_count());
1251 EXPECT_EQ(volume_mute, delegate->last_accelerator());
1252 EXPECT_EQ(0, delegate->handle_volume_down_count());
1253 EXPECT_TRUE(ProcessInController(volume_down));
1254 EXPECT_EQ(1, delegate->handle_volume_down_count());
1255 EXPECT_EQ(volume_down, delegate->last_accelerator());
1256 EXPECT_EQ(0, delegate->handle_volume_up_count());
1257 EXPECT_TRUE(ProcessInController(volume_up));
1258 EXPECT_EQ(1, delegate->handle_volume_up_count());
1259 EXPECT_EQ(volume_up, delegate->last_accelerator());
1260 } 1260 }
1261 } 1261 }
1262 #endif 1262 #endif
1263 1263
1264 // TODO: reenable. Disabled because shelf asynchronously created: 1264 // TODO: reenable. Disabled because shelf asynchronously created:
1265 // http://crbug.com/632192. 1265 // http://crbug.com/632192.
1266 TEST_F(AcceleratorControllerTest, DISABLED_DisallowedWithNoWindow) { 1266 TEST_F(AcceleratorControllerTest, DISABLED_DisallowedWithNoWindow) {
1267 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 1267 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
1268 1268
1269 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1269 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 EXPECT_TRUE(IsMessageCenterEmpty()); 1402 EXPECT_TRUE(IsMessageCenterEmpty());
1403 1403
1404 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1404 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1405 // screen before we proceed testing the rest of accelerators. 1405 // screen before we proceed testing the rest of accelerators.
1406 ResetStateIfNeeded(); 1406 ResetStateIfNeeded();
1407 } 1407 }
1408 } 1408 }
1409 #endif // defined(OS_CHROMEOS) 1409 #endif // defined(OS_CHROMEOS)
1410 1410
1411 } // namespace ash 1411 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/test/test_volume_control_delegate.cc ('k') | ash/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698