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

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

Issue 2098023002: mash: Migrate remaining tray observers and notify functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 6 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/accelerators/accelerator_controller.h" 5 #include "ash/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/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"
9 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
11 #include "ash/shell.h" 13 #include "ash/shell.h"
12 #include "ash/system/chromeos/network/network_observer.h"
13 #include "ash/system/tray/system_tray_notifier.h"
14 #include "ash/test/ash_interactive_ui_test_base.h" 14 #include "ash/test/ash_interactive_ui_test_base.h"
15 #include "ash/test/test_screenshot_delegate.h" 15 #include "ash/test/test_screenshot_delegate.h"
16 #include "ash/test/test_volume_control_delegate.h" 16 #include "ash/test/test_volume_control_delegate.h"
17 #include "ash/wm/window_state_aura.h" 17 #include "ash/wm/window_state_aura.h"
18 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
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 {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 AshInteractiveUITestBase::TearDown(); 72 AshInteractiveUITestBase::TearDown();
73 } 73 }
74 74
75 // Sends a key press event and waits synchronously until it's completely 75 // Sends a key press event and waits synchronously until it's completely
76 // processed. 76 // processed.
77 void SendKeyPressSync(ui::KeyboardCode key, 77 void SendKeyPressSync(ui::KeyboardCode key,
78 bool control, 78 bool control,
79 bool shift, 79 bool shift,
80 bool alt) { 80 bool alt) {
81 base::RunLoop loop; 81 base::RunLoop loop;
82 ui_controls::SendKeyPressNotifyWhenDone(root_window(), key, control, shift, 82 ui_controls::SendKeyPressNotifyWhenDone(Shell::GetPrimaryRootWindow(), key,
83 alt, false, loop.QuitClosure()); 83 control, shift, alt, false,
84 loop.QuitClosure());
84 loop.Run(); 85 loop.Run();
85 } 86 }
86 87
87 // ash::ShellObserver: 88 // ash::ShellObserver:
88 void OnOverviewModeStarting() override { is_in_overview_mode_ = true; } 89 void OnOverviewModeStarting() override { is_in_overview_mode_ = true; }
89 void OnOverviewModeEnded() override { is_in_overview_mode_ = false; } 90 void OnOverviewModeEnded() override { is_in_overview_mode_ = false; }
90 91
91 Shell* shell() const { return Shell::GetInstance(); }
92 aura::Window* root_window() const { return Shell::GetPrimaryRootWindow(); }
93
94 protected: 92 protected:
95 bool is_in_overview_mode_; 93 bool is_in_overview_mode_;
96 94
97 private: 95 private:
98 DISALLOW_COPY_AND_ASSIGN(AcceleratorInteractiveUITest); 96 DISALLOW_COPY_AND_ASSIGN(AcceleratorInteractiveUITest);
99 }; 97 };
100 98
101 //////////////////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////////////
102 100
103 #if defined(OFFICIAL_BUILD) 101 #if defined(OFFICIAL_BUILD)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_EQ(0, volume_delegate->handle_volume_down_count()); 177 EXPECT_EQ(0, volume_delegate->handle_volume_down_count());
180 SendKeyPressSync(ui::VKEY_VOLUME_DOWN, false, false, false); 178 SendKeyPressSync(ui::VKEY_VOLUME_DOWN, false, false, false);
181 EXPECT_EQ(1, volume_delegate->handle_volume_down_count()); 179 EXPECT_EQ(1, volume_delegate->handle_volume_down_count());
182 // VOLUME_UP. 180 // VOLUME_UP.
183 EXPECT_EQ(0, volume_delegate->handle_volume_up_count()); 181 EXPECT_EQ(0, volume_delegate->handle_volume_up_count());
184 SendKeyPressSync(ui::VKEY_VOLUME_UP, false, false, false); 182 SendKeyPressSync(ui::VKEY_VOLUME_UP, false, false, false);
185 EXPECT_EQ(1, volume_delegate->handle_volume_up_count()); 183 EXPECT_EQ(1, volume_delegate->handle_volume_up_count());
186 184
187 // Test TOGGLE_WIFI. 185 // Test TOGGLE_WIFI.
188 TestNetworkObserver network_observer; 186 TestNetworkObserver network_observer;
189 shell()->system_tray_notifier()->AddNetworkObserver(&network_observer); 187 WmShell::Get()->system_tray_notifier()->AddNetworkObserver(&network_observer);
190 188
191 EXPECT_FALSE(network_observer.wifi_enabled_status()); 189 EXPECT_FALSE(network_observer.wifi_enabled_status());
192 SendKeyPressSync(ui::VKEY_WLAN, false, false, false); 190 SendKeyPressSync(ui::VKEY_WLAN, false, false, false);
193 EXPECT_TRUE(network_observer.wifi_enabled_status()); 191 EXPECT_TRUE(network_observer.wifi_enabled_status());
194 SendKeyPressSync(ui::VKEY_WLAN, false, false, false); 192 SendKeyPressSync(ui::VKEY_WLAN, false, false, false);
195 EXPECT_FALSE(network_observer.wifi_enabled_status()); 193 EXPECT_FALSE(network_observer.wifi_enabled_status());
196 194
197 shell()->system_tray_notifier()->RemoveNetworkObserver(&network_observer); 195 WmShell::Get()->system_tray_notifier()->RemoveNetworkObserver(
196 &network_observer);
198 } 197 }
199 198
200 // Tests the app list accelerator. 199 // Tests the app list accelerator.
201 TEST_F(AcceleratorInteractiveUITest, MAYBE_ToggleAppList) { 200 TEST_F(AcceleratorInteractiveUITest, MAYBE_ToggleAppList) {
202 EXPECT_FALSE(shell()->GetAppListTargetVisibility()); 201 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility());
203 SendKeyPressSync(ui::VKEY_LWIN, false, false, false); 202 SendKeyPressSync(ui::VKEY_LWIN, false, false, false);
204 EXPECT_TRUE(shell()->GetAppListTargetVisibility()); 203 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
205 SendKeyPressSync(ui::VKEY_LWIN, false, false, false); 204 SendKeyPressSync(ui::VKEY_LWIN, false, false, false);
206 EXPECT_FALSE(shell()->GetAppListTargetVisibility()); 205 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility());
207 } 206 }
208 207
209 } // namespace test 208 } // namespace test
210 } // namespace ash 209 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_controller.cc ('k') | ash/ash.gyp » ('j') | ash/shell.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698