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

Side by Side Diff: ash/accelerators/accelerator_interactive_uitest_chromeos.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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/shell_observer.h" 7 #include "ash/common/shell_observer.h"
8 #include "ash/common/system/chromeos/network/network_observer.h" 8 #include "ash/common/system/chromeos/network/network_observer.h"
9 #include "ash/common/system/tray/system_tray_delegate.h" 9 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/common/system/tray/system_tray_notifier.h" 10 #include "ash/common/system/tray/system_tray_notifier.h"
11 #include "ash/common/test/test_volume_control_delegate.h"
12 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
14 #include "ash/shell.h" 13 #include "ash/shell.h"
15 #include "ash/test/ash_interactive_ui_test_base.h" 14 #include "ash/test/ash_interactive_ui_test_base.h"
16 #include "ash/test/test_screenshot_delegate.h" 15 #include "ash/test/test_screenshot_delegate.h"
17 #include "ash/wm/window_state_aura.h" 16 #include "ash/wm/window_state_aura.h"
18 #include "ash/wm/window_util.h" 17 #include "ash/wm/window_util.h"
19 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/test/user_action_tester.cc"
20 #include "chromeos/network/network_handler.h" 20 #include "chromeos/network/network_handler.h"
21 #include "ui/base/test/ui_controls.h" 21 #include "ui/base/test/ui_controls.h"
22 22
23 namespace ash { 23 namespace ash {
24 namespace test { 24 namespace test {
25 25
26 namespace { 26 namespace {
27 27
28 // A network observer to watch for the toggle wifi events. 28 // A network observer to watch for the toggle wifi events.
29 class TestNetworkObserver : public NetworkObserver { 29 class TestNetworkObserver : public NetworkObserver {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_EQ(0, screenshot_delegate->handle_take_screenshot_count()); 158 EXPECT_EQ(0, screenshot_delegate->handle_take_screenshot_count());
159 SendKeyPressSync(ui::VKEY_MEDIA_LAUNCH_APP1, true, false, false); 159 SendKeyPressSync(ui::VKEY_MEDIA_LAUNCH_APP1, true, false, false);
160 EXPECT_EQ(1, screenshot_delegate->handle_take_screenshot_count()); 160 EXPECT_EQ(1, screenshot_delegate->handle_take_screenshot_count());
161 SendKeyPressSync(ui::VKEY_PRINT, false, false, false); 161 SendKeyPressSync(ui::VKEY_PRINT, false, false, false);
162 EXPECT_EQ(2, screenshot_delegate->handle_take_screenshot_count()); 162 EXPECT_EQ(2, screenshot_delegate->handle_take_screenshot_count());
163 SendKeyPressSync(ui::VKEY_MEDIA_LAUNCH_APP1, true, true, false); 163 SendKeyPressSync(ui::VKEY_MEDIA_LAUNCH_APP1, true, true, false);
164 EXPECT_EQ(2, screenshot_delegate->handle_take_screenshot_count()); 164 EXPECT_EQ(2, screenshot_delegate->handle_take_screenshot_count());
165 // Press ESC to go out of the partial screenshot mode. 165 // Press ESC to go out of the partial screenshot mode.
166 SendKeyPressSync(ui::VKEY_ESCAPE, false, false, false); 166 SendKeyPressSync(ui::VKEY_ESCAPE, false, false, false);
167 167
168 // Test VOLUME_MUTE, VOLUME_DOWN, and VOLUME_UP. 168 // Test VOLUME_MUTE.
169 TestVolumeControlDelegate* volume_delegate = new TestVolumeControlDelegate; 169 base::UserActionTester user_action_tester;
170 WmShell::Get()->system_tray_delegate()->SetVolumeControlDelegate( 170 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
171 std::unique_ptr<VolumeControlDelegate>(volume_delegate));
172 // VOLUME_MUTE.
173 EXPECT_EQ(0, volume_delegate->handle_volume_mute_count());
174 SendKeyPressSync(ui::VKEY_VOLUME_MUTE, false, false, false); 171 SendKeyPressSync(ui::VKEY_VOLUME_MUTE, false, false, false);
175 EXPECT_EQ(1, volume_delegate->handle_volume_mute_count()); 172 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeMute_F8"));
176 // VOLUME_DOWN. 173 // Test VOLUME_DOWN.
177 EXPECT_EQ(0, volume_delegate->handle_volume_down_count()); 174 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
178 SendKeyPressSync(ui::VKEY_VOLUME_DOWN, false, false, false); 175 SendKeyPressSync(ui::VKEY_VOLUME_DOWN, false, false, false);
179 EXPECT_EQ(1, volume_delegate->handle_volume_down_count()); 176 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeDown_F9"));
180 // VOLUME_UP. 177 // Test VOLUME_UP.
181 EXPECT_EQ(0, volume_delegate->handle_volume_up_count()); 178 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
182 SendKeyPressSync(ui::VKEY_VOLUME_UP, false, false, false); 179 SendKeyPressSync(ui::VKEY_VOLUME_UP, false, false, false);
183 EXPECT_EQ(1, volume_delegate->handle_volume_up_count()); 180 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10"));
184 181
185 // Test TOGGLE_WIFI. 182 // Test TOGGLE_WIFI.
186 TestNetworkObserver network_observer; 183 TestNetworkObserver network_observer;
187 WmShell::Get()->system_tray_notifier()->AddNetworkObserver(&network_observer); 184 WmShell::Get()->system_tray_notifier()->AddNetworkObserver(&network_observer);
188 185
189 EXPECT_FALSE(network_observer.wifi_enabled_status()); 186 EXPECT_FALSE(network_observer.wifi_enabled_status());
190 SendKeyPressSync(ui::VKEY_WLAN, false, false, false); 187 SendKeyPressSync(ui::VKEY_WLAN, false, false, false);
191 EXPECT_TRUE(network_observer.wifi_enabled_status()); 188 EXPECT_TRUE(network_observer.wifi_enabled_status());
192 SendKeyPressSync(ui::VKEY_WLAN, false, false, false); 189 SendKeyPressSync(ui::VKEY_WLAN, false, false, false);
193 EXPECT_FALSE(network_observer.wifi_enabled_status()); 190 EXPECT_FALSE(network_observer.wifi_enabled_status());
194 191
195 WmShell::Get()->system_tray_notifier()->RemoveNetworkObserver( 192 WmShell::Get()->system_tray_notifier()->RemoveNetworkObserver(
196 &network_observer); 193 &network_observer);
197 } 194 }
198 195
199 // Tests the app list accelerator. 196 // Tests the app list accelerator.
200 TEST_F(AcceleratorInteractiveUITest, MAYBE_ToggleAppList) { 197 TEST_F(AcceleratorInteractiveUITest, MAYBE_ToggleAppList) {
201 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); 198 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
202 SendKeyPressSync(ui::VKEY_LWIN, false, false, false); 199 SendKeyPressSync(ui::VKEY_LWIN, false, false, false);
203 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); 200 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility());
204 SendKeyPressSync(ui::VKEY_LWIN, false, false, false); 201 SendKeyPressSync(ui::VKEY_LWIN, false, false, false);
205 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); 202 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
206 } 203 }
207 204
208 } // namespace test 205 } // namespace test
209 } // namespace ash 206 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller_unittest.cc ('k') | ash/common/accelerators/accelerator_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698