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
3 // found in the LICENSE file.
5 #include "ash/system/tray/test_system_tray_delegate.h"
9 #include "ash/session_state_delegate.h"
10 #include "ash/shell.h"
11 #include "ash/volume_control_delegate.h"
12 #include "base/utf_string_conversions.h"
13 #include "base/message_loop.h"
14 #include "base/string16.h"
15 #include "base/time.h"
22 class TestVolumeControlDelegate
: public VolumeControlDelegate
{
24 TestVolumeControlDelegate() {}
25 virtual ~TestVolumeControlDelegate() {}
27 virtual bool HandleVolumeMute(const ui::Accelerator
& accelerator
) OVERRIDE
{
30 virtual bool HandleVolumeDown(const ui::Accelerator
& accelerator
) OVERRIDE
{
33 virtual bool HandleVolumeUp(const ui::Accelerator
& accelerator
) OVERRIDE
{
36 virtual void SetVolumePercent(double percent
) OVERRIDE
{
38 virtual bool IsAudioMuted() const OVERRIDE
{
41 virtual void SetAudioMuted(bool muted
) OVERRIDE
{
43 virtual float GetVolumeLevel() const OVERRIDE
{
46 virtual void SetVolumeLevel(float level
) OVERRIDE
{
50 DISALLOW_COPY_AND_ASSIGN(TestVolumeControlDelegate
);
55 TestSystemTrayDelegate::TestSystemTrayDelegate()
56 : wifi_enabled_(true),
57 cellular_enabled_(true),
58 bluetooth_enabled_(true),
59 caps_lock_enabled_(false),
60 volume_control_delegate_(
61 ALLOW_THIS_IN_INITIALIZER_LIST(new TestVolumeControlDelegate
)) {
64 TestSystemTrayDelegate::~TestSystemTrayDelegate() {
67 void TestSystemTrayDelegate::Initialize() {
70 void TestSystemTrayDelegate::Shutdown() {
73 bool TestSystemTrayDelegate::GetTrayVisibilityOnStartup() {
77 // Overridden from SystemTrayDelegate:
78 const base::string16
TestSystemTrayDelegate::GetUserDisplayName() const {
79 return UTF8ToUTF16("Über tray Über tray Über tray Über tray");
82 const std::string
TestSystemTrayDelegate::GetUserEmail() const {
86 const gfx::ImageSkia
& TestSystemTrayDelegate::GetUserImage() const {
90 user::LoginStatus
TestSystemTrayDelegate::GetUserLoginStatus() const {
91 // At new user image screen manager->IsUserLoggedIn() would return true
92 // but there's no browser session available yet so use SessionStarted().
93 SessionStateDelegate
* delegate
=
94 Shell::GetInstance()->session_state_delegate();
96 if (!delegate
->IsActiveUserSessionStarted())
97 return ash::user::LOGGED_IN_NONE
;
98 if (delegate
->IsScreenLocked())
99 return user::LOGGED_IN_LOCKED
;
100 // TODO(nkostylev): Support LOGGED_IN_OWNER, LOGGED_IN_GUEST, LOGGED_IN_KIOSK,
102 return user::LOGGED_IN_USER
;
105 bool TestSystemTrayDelegate::IsOobeCompleted() const {
109 void TestSystemTrayDelegate::GetLoggedInUsers(UserEmailList
* users
) {
112 void TestSystemTrayDelegate::SwitchActiveUser(const std::string
& email
) {
115 void TestSystemTrayDelegate::ChangeProfilePicture() {
118 const std::string
TestSystemTrayDelegate::GetEnterpriseDomain() const {
119 return std::string();
122 const base::string16
TestSystemTrayDelegate::GetEnterpriseMessage() const {
126 bool TestSystemTrayDelegate::SystemShouldUpgrade() const {
130 base::HourClockType
TestSystemTrayDelegate::GetHourClockType() const {
131 return base::k24HourClock
;
134 PowerSupplyStatus
TestSystemTrayDelegate::GetPowerSupplyStatus() const {
135 return PowerSupplyStatus();
138 void TestSystemTrayDelegate::RequestStatusUpdate() const {
141 void TestSystemTrayDelegate::ShowSettings() {
144 void TestSystemTrayDelegate::ShowDateSettings() {
147 void TestSystemTrayDelegate::ShowNetworkSettings() {
150 void TestSystemTrayDelegate::ShowBluetoothSettings() {
153 void TestSystemTrayDelegate::ShowDisplaySettings() {
156 void TestSystemTrayDelegate::ShowDriveSettings() {
159 void TestSystemTrayDelegate::ShowIMESettings() {
162 void TestSystemTrayDelegate::ShowHelp() {
165 void TestSystemTrayDelegate::ShowAccessibilityHelp() {
168 void TestSystemTrayDelegate::ShowPublicAccountInfo() {
171 void TestSystemTrayDelegate::ShowEnterpriseInfo() {
174 void TestSystemTrayDelegate::ShowUserLogin() {
177 void TestSystemTrayDelegate::ShutDown() {
178 MessageLoop::current()->Quit();
181 void TestSystemTrayDelegate::SignOut() {
182 MessageLoop::current()->Quit();
185 void TestSystemTrayDelegate::RequestLockScreen() {
188 void TestSystemTrayDelegate::RequestRestart() {
191 void TestSystemTrayDelegate::GetAvailableBluetoothDevices(
192 BluetoothDeviceList
* list
) {
195 void TestSystemTrayDelegate::BluetoothStartDiscovering() {
198 void TestSystemTrayDelegate::BluetoothStopDiscovering() {
201 void TestSystemTrayDelegate::ConnectToBluetoothDevice(
202 const std::string
& address
) {
205 void TestSystemTrayDelegate::GetCurrentIME(IMEInfo
* info
) {
208 void TestSystemTrayDelegate::GetAvailableIMEList(IMEInfoList
* list
) {
211 void TestSystemTrayDelegate::GetCurrentIMEProperties(
212 IMEPropertyInfoList
* list
) {
215 void TestSystemTrayDelegate::SwitchIME(const std::string
& ime_id
) {
218 void TestSystemTrayDelegate::ActivateIMEProperty(const std::string
& key
) {
221 void TestSystemTrayDelegate::CancelDriveOperation(const base::FilePath
&) {
224 void TestSystemTrayDelegate::GetDriveOperationStatusList(
225 ash::DriveOperationStatusList
*) {
228 void TestSystemTrayDelegate::GetMostRelevantNetworkIcon(NetworkIconInfo
* info
,
232 void TestSystemTrayDelegate::GetVirtualNetworkIcon(ash::NetworkIconInfo
* info
) {
235 void TestSystemTrayDelegate::GetAvailableNetworks(
236 std::vector
<NetworkIconInfo
>* list
) {
239 void TestSystemTrayDelegate::GetVirtualNetworks(
240 std::vector
<NetworkIconInfo
>* list
) {
243 void TestSystemTrayDelegate::ConnectToNetwork(const std::string
& network_id
) {
246 void TestSystemTrayDelegate::GetNetworkAddresses(
247 std::string
* ip_address
,
248 std::string
* ethernet_mac_address
,
249 std::string
* wifi_mac_address
) {
250 *ip_address
= "127.0.0.1";
251 *ethernet_mac_address
= "00:11:22:33:44:55";
252 *wifi_mac_address
= "66:77:88:99:00:11";
255 void TestSystemTrayDelegate::RequestNetworkScan() {
258 void TestSystemTrayDelegate::AddBluetoothDevice() {
261 void TestSystemTrayDelegate::ToggleAirplaneMode() {
264 void TestSystemTrayDelegate::ToggleWifi() {
265 wifi_enabled_
= !wifi_enabled_
;
268 void TestSystemTrayDelegate::ToggleMobile() {
269 cellular_enabled_
= !cellular_enabled_
;
272 void TestSystemTrayDelegate::ToggleBluetooth() {
273 bluetooth_enabled_
= !bluetooth_enabled_
;
276 bool TestSystemTrayDelegate::IsBluetoothDiscovering() {
280 void TestSystemTrayDelegate::ShowOtherWifi() {
283 void TestSystemTrayDelegate::ShowOtherVPN() {
286 void TestSystemTrayDelegate::ShowOtherCellular() {
289 bool TestSystemTrayDelegate::IsNetworkConnected() {
293 bool TestSystemTrayDelegate::GetWifiAvailable() {
297 bool TestSystemTrayDelegate::GetMobileAvailable() {
301 bool TestSystemTrayDelegate::GetBluetoothAvailable() {
305 bool TestSystemTrayDelegate::GetWifiEnabled() {
306 return wifi_enabled_
;
309 bool TestSystemTrayDelegate::GetMobileEnabled() {
310 return cellular_enabled_
;
313 bool TestSystemTrayDelegate::GetBluetoothEnabled() {
314 return bluetooth_enabled_
;
317 bool TestSystemTrayDelegate::GetMobileScanSupported() {
321 bool TestSystemTrayDelegate::GetCellularCarrierInfo(std::string
* carrier_id
,
322 std::string
* topup_url
,
323 std::string
* setup_url
) {
327 bool TestSystemTrayDelegate::GetWifiScanning() {
331 bool TestSystemTrayDelegate::GetCellularInitializing() {
335 void TestSystemTrayDelegate::ShowCellularURL(const std::string
& url
) {
338 void TestSystemTrayDelegate::ChangeProxySettings() {
341 VolumeControlDelegate
* TestSystemTrayDelegate::GetVolumeControlDelegate()
343 return volume_control_delegate_
.get();
346 void TestSystemTrayDelegate::SetVolumeControlDelegate(
347 scoped_ptr
<VolumeControlDelegate
> delegate
) {
348 volume_control_delegate_
= delegate
.Pass();
351 bool TestSystemTrayDelegate::GetSessionStartTime(
352 base::TimeTicks
* session_start_time
) {
356 bool TestSystemTrayDelegate::GetSessionLengthLimit(
357 base::TimeDelta
* session_length_limit
) {
361 int TestSystemTrayDelegate::GetSystemTrayMenuWidth() {
362 // This is the default width for English languages.
366 base::string16
TestSystemTrayDelegate::FormatTimeDuration(
367 const base::TimeDelta
& delta
) const {
368 return base::string16();
371 void TestSystemTrayDelegate::MaybeSpeak(const std::string
& utterance
) const {