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/shell.h" | 16 #include "ash/shell.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "chrome/browser/chromeos/login/login_manager_test.h" | 18 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 18 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 19 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 19 #include "chrome/browser/chromeos/login/startup_utils.h" | 20 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 20 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 21 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 26 #include "components/user_manager/user_manager.h" | 27 #include "components/user_manager/user_manager.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 29 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | |
| 30 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" | |
| 31 | |
| 32 using bluez::BluezDBusManager; | |
| 33 using bluez::FakeBluetoothAdapterClient; | |
| 28 | 34 |
| 29 namespace chromeos { | 35 namespace chromeos { |
| 30 | 36 |
| 31 namespace { | 37 namespace { |
| 32 | 38 |
| 33 // 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 |
| 34 // are definitely not enterprise. This lets us to avoid faking of policy fetch | 40 // are definitely not enterprise. This lets us to avoid faking of policy fetch |
| 35 // procedure. | 41 // procedure. |
| 36 const char kUser1[] = "user1@gmail.com"; | 42 const char kUser1[] = "user1@gmail.com"; |
| 37 const char kUser2[] = "user2@gmail.com"; | 43 const char kUser2[] = "user2@gmail.com"; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 CreateDefaultView(); | 110 CreateDefaultView(); |
| 105 EXPECT_EQ(base::k12HourClock, GetHourType()); | 111 EXPECT_EQ(base::k12HourClock, GetHourType()); |
| 106 | 112 |
| 107 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); | 113 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); |
| 108 // Allow clock setting to be sent to ash over mojo. | 114 // Allow clock setting to be sent to ash over mojo. |
| 109 content::RunAllPendingInMessageLoop(); | 115 content::RunAllPendingInMessageLoop(); |
| 110 CreateDefaultView(); | 116 CreateDefaultView(); |
| 111 EXPECT_EQ(base::k24HourClock, GetHourType()); | 117 EXPECT_EQ(base::k24HourClock, GetHourType()); |
| 112 } | 118 } |
| 113 | 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. | |
|
msw
2017/03/17 00:11:06
nit: cite a bug?
James Cook
2017/03/17 04:02:57
Done.
| |
| 124 IN_PROC_BROWSER_TEST_F(SystemTrayDelegateBluetoothTest, Basics) { | |
| 125 // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to | |
| 126 // wait or use timers. | |
| 127 FakeBluetoothAdapterClient* adapter_client = | |
| 128 static_cast<FakeBluetoothAdapterClient*>( | |
| 129 BluezDBusManager::Get()->GetBluetoothAdapterClient()); | |
| 130 adapter_client->SetSimulationIntervalMs(0); | |
| 131 | |
| 132 ash::SystemTrayDelegate* delegate = | |
| 133 ash::WmShell::Get()->system_tray_delegate(); | |
| 134 EXPECT_TRUE(delegate->GetBluetoothAvailable()); | |
| 135 EXPECT_FALSE(delegate->GetBluetoothEnabled()); | |
| 136 EXPECT_FALSE(delegate->GetBluetoothDiscovering()); | |
|
msw
2017/03/17 00:11:05
nit: also check IsBluetoothDiscovering like below?
James Cook
2017/03/17 04:02:57
Done.
| |
| 137 | |
| 138 ash::BluetoothDeviceList devices; | |
| 139 delegate->GetAvailableBluetoothDevices(&devices); | |
| 140 // The devices are fake in tests, so don't assume any particular number. | |
| 141 EXPECT_FALSE(devices.empty()); | |
| 142 | |
| 143 // Turn Bluetooth on. | |
| 144 delegate->ToggleBluetooth(); | |
| 145 content::RunAllPendingInMessageLoop(); | |
| 146 EXPECT_TRUE(delegate->GetBluetoothEnabled()); | |
| 147 | |
| 148 delegate->BluetoothStartDiscovering(); | |
| 149 content::RunAllPendingInMessageLoop(); | |
| 150 EXPECT_TRUE(delegate->GetBluetoothDiscovering()); | |
| 151 EXPECT_TRUE(delegate->IsBluetoothDiscovering()); | |
| 152 | |
| 153 delegate->BluetoothStopDiscovering(); | |
| 154 content::RunAllPendingInMessageLoop(); | |
| 155 EXPECT_FALSE(delegate->GetBluetoothDiscovering()); | |
| 156 EXPECT_FALSE(delegate->IsBluetoothDiscovering()); | |
| 157 | |
| 158 // Turn Bluetooth off. | |
| 159 delegate->ToggleBluetooth(); | |
| 160 content::RunAllPendingInMessageLoop(); | |
| 161 EXPECT_FALSE(delegate->GetBluetoothEnabled()); | |
| 162 } | |
| 163 | |
| 114 } // namespace chromeos | 164 } // namespace chromeos |
| OLD | NEW |