Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/common/system/date/date_default_view.h" | 9 #include "ash/common/system/date/date_default_view.h" |
| 10 #include "ash/common/system/date/date_view.h" | 10 #include "ash/common/system/date/date_view.h" |
| 11 #include "ash/common/system/date/system_info_default_view.h" | 11 #include "ash/common/system/date/system_info_default_view.h" |
| 12 #include "ash/common/system/date/tray_date.h" | 12 #include "ash/common/system/date/tray_date.h" |
| 13 #include "ash/common/system/date/tray_system_info.h" | 13 #include "ash/common/system/date/tray_system_info.h" |
| 14 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "chrome/browser/chromeos/login/login_manager_test.h" | 18 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 19 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 19 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 20 #include "chrome/browser/chromeos/login/startup_utils.h" | 20 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 21 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 21 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 27 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
| 28 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 29 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 29 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
|
msw
2017/03/21 01:54:44
nit: remove bluetooth includes and using statement
James Cook
2017/03/21 04:43:01
Done.
| |
| 30 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" | 30 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" |
| 31 | 31 |
| 32 using bluez::BluezDBusManager; | 32 using bluez::BluezDBusManager; |
| 33 using bluez::FakeBluetoothAdapterClient; | 33 using bluez::FakeBluetoothAdapterClient; |
| 34 | 34 |
| 35 namespace chromeos { | 35 namespace chromeos { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // Because policy is not needed this test it is better to use e-mails that | 39 // Because policy is not needed this test it is better to use e-mails that |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 CreateDefaultView(); | 110 CreateDefaultView(); |
| 111 EXPECT_EQ(base::k12HourClock, GetHourType()); | 111 EXPECT_EQ(base::k12HourClock, GetHourType()); |
| 112 | 112 |
| 113 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); | 113 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); |
| 114 // Allow clock setting to be sent to ash over mojo. | 114 // Allow clock setting to be sent to ash over mojo. |
| 115 content::RunAllPendingInMessageLoop(); | 115 content::RunAllPendingInMessageLoop(); |
| 116 CreateDefaultView(); | 116 CreateDefaultView(); |
| 117 EXPECT_EQ(base::k24HourClock, GetHourType()); | 117 EXPECT_EQ(base::k24HourClock, GetHourType()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 using SystemTrayDelegateBluetoothTest = InProcessBrowserTest; | |
| 121 | |
| 122 // Tests basic functionality of the Bluetooth interface. | |
| 123 // TODO(jamescook): Delete this test when TrayBluetoothHelper moves to ash. | |
| 124 // http://crbug.com/660043 | |
| 125 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateBluetoothTest, Basics) { | |
| 126 // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to | |
| 127 // wait or use timers. | |
| 128 FakeBluetoothAdapterClient* adapter_client = | |
| 129 static_cast<FakeBluetoothAdapterClient*>( | |
| 130 BluezDBusManager::Get()->GetBluetoothAdapterClient()); | |
| 131 adapter_client->SetSimulationIntervalMs(0); | |
| 132 | |
| 133 ash::SystemTrayDelegate* delegate = | |
| 134 ash::WmShell::Get()->system_tray_delegate(); | |
| 135 EXPECT_TRUE(delegate->GetBluetoothAvailable()); | |
| 136 EXPECT_FALSE(delegate->GetBluetoothEnabled()); | |
| 137 EXPECT_FALSE(delegate->GetBluetoothDiscovering()); | |
| 138 EXPECT_FALSE(delegate->IsBluetoothDiscovering()); | |
| 139 | |
| 140 ash::BluetoothDeviceList devices; | |
| 141 delegate->GetAvailableBluetoothDevices(&devices); | |
| 142 // The devices are fake in tests, so don't assume any particular number. | |
| 143 EXPECT_FALSE(devices.empty()); | |
| 144 | |
| 145 // Turn Bluetooth on. | |
| 146 delegate->ToggleBluetooth(); | |
| 147 content::RunAllPendingInMessageLoop(); | |
| 148 EXPECT_TRUE(delegate->GetBluetoothEnabled()); | |
| 149 | |
| 150 delegate->BluetoothStartDiscovering(); | |
| 151 content::RunAllPendingInMessageLoop(); | |
| 152 EXPECT_TRUE(delegate->GetBluetoothDiscovering()); | |
| 153 EXPECT_TRUE(delegate->IsBluetoothDiscovering()); | |
| 154 | |
| 155 delegate->BluetoothStopDiscovering(); | |
| 156 content::RunAllPendingInMessageLoop(); | |
| 157 EXPECT_FALSE(delegate->GetBluetoothDiscovering()); | |
| 158 EXPECT_FALSE(delegate->IsBluetoothDiscovering()); | |
| 159 | |
| 160 // Turn Bluetooth off. | |
| 161 delegate->ToggleBluetooth(); | |
| 162 content::RunAllPendingInMessageLoop(); | |
| 163 EXPECT_FALSE(delegate->GetBluetoothEnabled()); | |
| 164 } | |
| 165 | |
| 166 } // namespace chromeos | 120 } // namespace chromeos |
| OLD | NEW |