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

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

Issue 2131733002: mash: Migrate [Keyboard]Brightness code to ash/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 5 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
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
7 #include "ash/accelerators/accelerator_table.h" 7 #include "ash/accelerators/accelerator_table.h"
8 #include "ash/aura/wm_window_aura.h" 8 #include "ash/aura/wm_window_aura.h"
9 #include "ash/common/accessibility_delegate.h" 9 #include "ash/common/accessibility_delegate.h"
10 #include "ash/common/accessibility_types.h" 10 #include "ash/common/accessibility_types.h"
11 #include "ash/common/ash_switches.h" 11 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/system/brightness_control_delegate.h"
14 #include "ash/common/system/keyboard_brightness_control_delegate.h"
13 #include "ash/common/system/tray/system_tray_delegate.h" 15 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/system/volume_control_delegate.h" 16 #include "ash/common/system/volume_control_delegate.h"
15 #include "ash/common/wm/panels/panel_layout_manager.h" 17 #include "ash/common/wm/panels/panel_layout_manager.h"
16 #include "ash/common/wm/window_positioning_utils.h" 18 #include "ash/common/wm/window_positioning_utils.h"
17 #include "ash/common/wm/window_state.h" 19 #include "ash/common/wm/window_state.h"
18 #include "ash/common/wm/wm_event.h" 20 #include "ash/common/wm/wm_event.h"
19 #include "ash/common/wm_shell.h" 21 #include "ash/common/wm_shell.h"
20 #include "ash/display/display_manager.h" 22 #include "ash/display/display_manager.h"
21 #include "ash/ime_control_delegate.h" 23 #include "ash/ime_control_delegate.h"
22 #include "ash/screen_util.h"
23 #include "ash/shell.h" 24 #include "ash/shell.h"
24 #include "ash/system/brightness_control_delegate.h"
25 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
26 #include "ash/test/ash_test_base.h" 25 #include "ash/test/ash_test_base.h"
27 #include "ash/test/display_manager_test_api.h" 26 #include "ash/test/display_manager_test_api.h"
28 #include "ash/test/test_screenshot_delegate.h" 27 #include "ash/test/test_screenshot_delegate.h"
29 #include "ash/test/test_session_state_animator.h" 28 #include "ash/test/test_session_state_animator.h"
30 #include "ash/test/test_shelf_delegate.h" 29 #include "ash/test/test_shelf_delegate.h"
31 #include "ash/test/test_shell_delegate.h"
32 #include "ash/test/test_volume_control_delegate.h" 30 #include "ash/test/test_volume_control_delegate.h"
33 #include "ash/wm/lock_state_controller.h" 31 #include "ash/wm/lock_state_controller.h"
34 #include "ash/wm/window_state_aura.h" 32 #include "ash/wm/window_state_aura.h"
35 #include "ash/wm/window_util.h" 33 #include "ash/wm/window_util.h"
36 #include "base/command_line.h"
37 #include "ui/aura/client/aura_constants.h" 34 #include "ui/aura/client/aura_constants.h"
38 #include "ui/aura/test/test_window_delegate.h" 35 #include "ui/aura/test/test_window_delegate.h"
39 #include "ui/aura/test/test_windows.h" 36 #include "ui/aura/test/test_windows.h"
40 #include "ui/aura/window.h" 37 #include "ui/aura/window.h"
41 #include "ui/display/screen.h" 38 #include "ui/display/screen.h"
42 #include "ui/events/event.h" 39 #include "ui/events/event.h"
43 #include "ui/events/event_processor.h" 40 #include "ui/events/event_processor.h"
44 #include "ui/events/test/event_generator.h" 41 #include "ui/events/test/event_generator.h"
45 #include "ui/message_center/message_center.h" 42 #include "ui/message_center/message_center.h"
46 #include "ui/views/widget/widget.h" 43 #include "ui/views/widget/widget.h"
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 EXPECT_EQ(1, delegate->handle_volume_up_count()); 849 EXPECT_EQ(1, delegate->handle_volume_up_count());
853 EXPECT_EQ(volume_up, delegate->last_accelerator()); 850 EXPECT_EQ(volume_up, delegate->last_accelerator());
854 } 851 }
855 // Brightness 852 // Brightness
856 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows. 853 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows.
857 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); 854 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
858 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); 855 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
859 { 856 {
860 DummyBrightnessControlDelegate* delegate = 857 DummyBrightnessControlDelegate* delegate =
861 new DummyBrightnessControlDelegate; 858 new DummyBrightnessControlDelegate;
862 GetController()->SetBrightnessControlDelegate( 859 WmShell::Get()->SetBrightnessControlDelegate(
msw 2016/07/08 01:40:48 If we want to get really minimal, I could remove t
James Cook 2016/07/08 16:29:34 Yeah, I like that idea.
msw 2016/07/08 17:18:58 I made AcceleratorControllerTest a friend class wi
863 std::unique_ptr<BrightnessControlDelegate>(delegate)); 860 std::unique_ptr<BrightnessControlDelegate>(delegate));
864 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 861 EXPECT_EQ(0, delegate->handle_brightness_down_count());
865 EXPECT_TRUE(ProcessInController(brightness_down)); 862 EXPECT_TRUE(ProcessInController(brightness_down));
866 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 863 EXPECT_EQ(1, delegate->handle_brightness_down_count());
867 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 864 EXPECT_EQ(brightness_down, delegate->last_accelerator());
868 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 865 EXPECT_EQ(0, delegate->handle_brightness_up_count());
869 EXPECT_TRUE(ProcessInController(brightness_up)); 866 EXPECT_TRUE(ProcessInController(brightness_up));
870 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 867 EXPECT_EQ(1, delegate->handle_brightness_up_count());
871 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 868 EXPECT_EQ(brightness_up, delegate->last_accelerator());
872 } 869 }
873 870
874 // Keyboard brightness 871 // Keyboard brightness
875 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN, 872 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN,
876 ui::EF_ALT_DOWN); 873 ui::EF_ALT_DOWN);
877 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP, 874 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP,
878 ui::EF_ALT_DOWN); 875 ui::EF_ALT_DOWN);
879 { 876 {
880 EXPECT_TRUE(ProcessInController(alt_brightness_down)); 877 EXPECT_TRUE(ProcessInController(alt_brightness_down));
881 EXPECT_TRUE(ProcessInController(alt_brightness_up)); 878 EXPECT_TRUE(ProcessInController(alt_brightness_up));
882 DummyKeyboardBrightnessControlDelegate* delegate = 879 DummyKeyboardBrightnessControlDelegate* delegate =
883 new DummyKeyboardBrightnessControlDelegate; 880 new DummyKeyboardBrightnessControlDelegate;
884 GetController()->SetKeyboardBrightnessControlDelegate( 881 WmShell::Get()->SetKeyboardBrightnessControlDelegate(
885 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); 882 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate));
886 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); 883 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count());
887 EXPECT_TRUE(ProcessInController(alt_brightness_down)); 884 EXPECT_TRUE(ProcessInController(alt_brightness_down));
888 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); 885 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count());
889 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); 886 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator());
890 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); 887 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count());
891 EXPECT_TRUE(ProcessInController(alt_brightness_up)); 888 EXPECT_TRUE(ProcessInController(alt_brightness_up));
892 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); 889 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count());
893 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); 890 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator());
894 } 891 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 EXPECT_TRUE(ProcessInController(ui::Accelerator( 1227 EXPECT_TRUE(ProcessInController(ui::Accelerator(
1231 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 1228 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
1232 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 1229 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
1233 } 1230 }
1234 // Brightness 1231 // Brightness
1235 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); 1232 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE);
1236 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); 1233 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
1237 { 1234 {
1238 DummyBrightnessControlDelegate* delegate = 1235 DummyBrightnessControlDelegate* delegate =
1239 new DummyBrightnessControlDelegate; 1236 new DummyBrightnessControlDelegate;
1240 GetController()->SetBrightnessControlDelegate( 1237 WmShell::Get()->SetBrightnessControlDelegate(
1241 std::unique_ptr<BrightnessControlDelegate>(delegate)); 1238 std::unique_ptr<BrightnessControlDelegate>(delegate));
1242 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 1239 EXPECT_EQ(0, delegate->handle_brightness_down_count());
1243 EXPECT_TRUE(ProcessInController(brightness_down)); 1240 EXPECT_TRUE(ProcessInController(brightness_down));
1244 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 1241 EXPECT_EQ(1, delegate->handle_brightness_down_count());
1245 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 1242 EXPECT_EQ(brightness_down, delegate->last_accelerator());
1246 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 1243 EXPECT_EQ(0, delegate->handle_brightness_up_count());
1247 EXPECT_TRUE(ProcessInController(brightness_up)); 1244 EXPECT_TRUE(ProcessInController(brightness_up));
1248 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 1245 EXPECT_EQ(1, delegate->handle_brightness_up_count());
1249 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 1246 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1250 } 1247 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 EXPECT_TRUE(IsMessageCenterEmpty()); 1401 EXPECT_TRUE(IsMessageCenterEmpty());
1405 1402
1406 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1403 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1407 // screen before we proceed testing the rest of accelerators. 1404 // screen before we proceed testing the rest of accelerators.
1408 ResetStateIfNeeded(); 1405 ResetStateIfNeeded();
1409 } 1406 }
1410 } 1407 }
1411 #endif // defined(OS_CHROMEOS) 1408 #endif // defined(OS_CHROMEOS)
1412 1409
1413 } // namespace ash 1410 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('j') | ash/common/wm_shell.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698