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

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: Address comments. 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
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('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 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(5, 5, 20, 20)); 256 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(5, 5, 20, 20));
260 test::TestShelfDelegate* shelf_delegate = 257 test::TestShelfDelegate* shelf_delegate =
261 test::TestShelfDelegate::instance(); 258 test::TestShelfDelegate::instance();
262 shelf_delegate->AddShelfItem(window); 259 shelf_delegate->AddShelfItem(window);
263 PanelLayoutManager* manager = 260 PanelLayoutManager* manager =
264 PanelLayoutManager::Get(WmWindowAura::Get(window)); 261 PanelLayoutManager::Get(WmWindowAura::Get(window));
265 manager->Relayout(); 262 manager->Relayout();
266 return window; 263 return window;
267 } 264 }
268 265
266 void SetBrightnessControlDelegate(
267 std::unique_ptr<BrightnessControlDelegate> delegate) {
268 WmShell::Get()->brightness_control_delegate_ = std::move(delegate);
269 }
270
271 void SetKeyboardBrightnessControlDelegate(
272 std::unique_ptr<KeyboardBrightnessControlDelegate> delegate) {
273 WmShell::Get()->keyboard_brightness_control_delegate_ = std::move(delegate);
274 }
275
269 private: 276 private:
270 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest); 277 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest);
271 }; 278 };
272 279
273 AcceleratorController* AcceleratorControllerTest::GetController() { 280 AcceleratorController* AcceleratorControllerTest::GetController() {
274 return Shell::GetInstance()->accelerator_controller(); 281 return Shell::GetInstance()->accelerator_controller();
275 } 282 }
276 283
277 #if !defined(OS_WIN) 284 #if !defined(OS_WIN)
278 // Double press of exit shortcut => exiting 285 // Double press of exit shortcut => exiting
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 EXPECT_EQ(1, delegate->handle_volume_up_count()); 859 EXPECT_EQ(1, delegate->handle_volume_up_count());
853 EXPECT_EQ(volume_up, delegate->last_accelerator()); 860 EXPECT_EQ(volume_up, delegate->last_accelerator());
854 } 861 }
855 // Brightness 862 // Brightness
856 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows. 863 // ui::VKEY_BRIGHTNESS_DOWN/UP are not defined on Windows.
857 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); 864 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); 865 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
859 { 866 {
860 DummyBrightnessControlDelegate* delegate = 867 DummyBrightnessControlDelegate* delegate =
861 new DummyBrightnessControlDelegate; 868 new DummyBrightnessControlDelegate;
862 GetController()->SetBrightnessControlDelegate( 869 SetBrightnessControlDelegate(
863 std::unique_ptr<BrightnessControlDelegate>(delegate)); 870 std::unique_ptr<BrightnessControlDelegate>(delegate));
864 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 871 EXPECT_EQ(0, delegate->handle_brightness_down_count());
865 EXPECT_TRUE(ProcessInController(brightness_down)); 872 EXPECT_TRUE(ProcessInController(brightness_down));
866 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 873 EXPECT_EQ(1, delegate->handle_brightness_down_count());
867 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 874 EXPECT_EQ(brightness_down, delegate->last_accelerator());
868 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 875 EXPECT_EQ(0, delegate->handle_brightness_up_count());
869 EXPECT_TRUE(ProcessInController(brightness_up)); 876 EXPECT_TRUE(ProcessInController(brightness_up));
870 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 877 EXPECT_EQ(1, delegate->handle_brightness_up_count());
871 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 878 EXPECT_EQ(brightness_up, delegate->last_accelerator());
872 } 879 }
873 880
874 // Keyboard brightness 881 // Keyboard brightness
875 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN, 882 const ui::Accelerator alt_brightness_down(ui::VKEY_BRIGHTNESS_DOWN,
876 ui::EF_ALT_DOWN); 883 ui::EF_ALT_DOWN);
877 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP, 884 const ui::Accelerator alt_brightness_up(ui::VKEY_BRIGHTNESS_UP,
878 ui::EF_ALT_DOWN); 885 ui::EF_ALT_DOWN);
879 { 886 {
880 EXPECT_TRUE(ProcessInController(alt_brightness_down)); 887 EXPECT_TRUE(ProcessInController(alt_brightness_down));
881 EXPECT_TRUE(ProcessInController(alt_brightness_up)); 888 EXPECT_TRUE(ProcessInController(alt_brightness_up));
882 DummyKeyboardBrightnessControlDelegate* delegate = 889 DummyKeyboardBrightnessControlDelegate* delegate =
883 new DummyKeyboardBrightnessControlDelegate; 890 new DummyKeyboardBrightnessControlDelegate;
884 GetController()->SetKeyboardBrightnessControlDelegate( 891 SetKeyboardBrightnessControlDelegate(
885 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); 892 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate));
886 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); 893 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count());
887 EXPECT_TRUE(ProcessInController(alt_brightness_down)); 894 EXPECT_TRUE(ProcessInController(alt_brightness_down));
888 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); 895 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count());
889 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); 896 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator());
890 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); 897 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count());
891 EXPECT_TRUE(ProcessInController(alt_brightness_up)); 898 EXPECT_TRUE(ProcessInController(alt_brightness_up));
892 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); 899 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count());
893 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); 900 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator());
894 } 901 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 EXPECT_TRUE(ProcessInController(ui::Accelerator( 1237 EXPECT_TRUE(ProcessInController(ui::Accelerator(
1231 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); 1238 ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN)));
1232 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); 1239 EXPECT_EQ(2, delegate->handle_take_screenshot_count());
1233 } 1240 }
1234 // Brightness 1241 // Brightness
1235 const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); 1242 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); 1243 const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE);
1237 { 1244 {
1238 DummyBrightnessControlDelegate* delegate = 1245 DummyBrightnessControlDelegate* delegate =
1239 new DummyBrightnessControlDelegate; 1246 new DummyBrightnessControlDelegate;
1240 GetController()->SetBrightnessControlDelegate( 1247 SetBrightnessControlDelegate(
1241 std::unique_ptr<BrightnessControlDelegate>(delegate)); 1248 std::unique_ptr<BrightnessControlDelegate>(delegate));
1242 EXPECT_EQ(0, delegate->handle_brightness_down_count()); 1249 EXPECT_EQ(0, delegate->handle_brightness_down_count());
1243 EXPECT_TRUE(ProcessInController(brightness_down)); 1250 EXPECT_TRUE(ProcessInController(brightness_down));
1244 EXPECT_EQ(1, delegate->handle_brightness_down_count()); 1251 EXPECT_EQ(1, delegate->handle_brightness_down_count());
1245 EXPECT_EQ(brightness_down, delegate->last_accelerator()); 1252 EXPECT_EQ(brightness_down, delegate->last_accelerator());
1246 EXPECT_EQ(0, delegate->handle_brightness_up_count()); 1253 EXPECT_EQ(0, delegate->handle_brightness_up_count());
1247 EXPECT_TRUE(ProcessInController(brightness_up)); 1254 EXPECT_TRUE(ProcessInController(brightness_up));
1248 EXPECT_EQ(1, delegate->handle_brightness_up_count()); 1255 EXPECT_EQ(1, delegate->handle_brightness_up_count());
1249 EXPECT_EQ(brightness_up, delegate->last_accelerator()); 1256 EXPECT_EQ(brightness_up, delegate->last_accelerator());
1250 } 1257 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 EXPECT_TRUE(IsMessageCenterEmpty()); 1411 EXPECT_TRUE(IsMessageCenterEmpty());
1405 1412
1406 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1413 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1407 // screen before we proceed testing the rest of accelerators. 1414 // screen before we proceed testing the rest of accelerators.
1408 ResetStateIfNeeded(); 1415 ResetStateIfNeeded();
1409 } 1416 }
1410 } 1417 }
1411 #endif // defined(OS_CHROMEOS) 1418 #endif // defined(OS_CHROMEOS)
1412 1419
1413 } // namespace ash 1420 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698