Chromium Code Reviews| Index: chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc |
| index a64eb66e65d4eb7e6d5e960d9c495791bfed8220..291164818864da44192d4a3ec28594f5d9c6e703 100644 |
| --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc |
| +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc |
| @@ -12,6 +12,7 @@ |
| #include "ash/common/system/date/tray_date.h" |
| #include "ash/common/system/date/tray_system_info.h" |
| #include "ash/common/system/tray/system_tray.h" |
| +#include "ash/common/wm_shell.h" |
| #include "ash/shell.h" |
| #include "base/macros.h" |
| #include "chrome/browser/chromeos/login/login_manager_test.h" |
| @@ -25,6 +26,11 @@ |
| #include "components/prefs/pref_service.h" |
| #include "components/user_manager/user_manager.h" |
| #include "content/public/test/test_utils.h" |
| +#include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| +#include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" |
| + |
| +using bluez::BluezDBusManager; |
| +using bluez::FakeBluetoothAdapterClient; |
| namespace chromeos { |
| @@ -111,4 +117,48 @@ IN_PROC_BROWSER_TEST_F(SystemTrayDelegateChromeOSTest, |
| EXPECT_EQ(base::k24HourClock, GetHourType()); |
| } |
| +using SystemTrayDelegateBluetoothTest = InProcessBrowserTest; |
| + |
| +// Tests basic functionality of the Bluetooth interface. |
| +// 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.
|
| +IN_PROC_BROWSER_TEST_F(SystemTrayDelegateBluetoothTest, Basics) { |
| + // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to |
| + // wait or use timers. |
| + FakeBluetoothAdapterClient* adapter_client = |
| + static_cast<FakeBluetoothAdapterClient*>( |
| + BluezDBusManager::Get()->GetBluetoothAdapterClient()); |
| + adapter_client->SetSimulationIntervalMs(0); |
| + |
| + ash::SystemTrayDelegate* delegate = |
| + ash::WmShell::Get()->system_tray_delegate(); |
| + EXPECT_TRUE(delegate->GetBluetoothAvailable()); |
| + EXPECT_FALSE(delegate->GetBluetoothEnabled()); |
| + 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.
|
| + |
| + ash::BluetoothDeviceList devices; |
| + delegate->GetAvailableBluetoothDevices(&devices); |
| + // The devices are fake in tests, so don't assume any particular number. |
| + EXPECT_FALSE(devices.empty()); |
| + |
| + // Turn Bluetooth on. |
| + delegate->ToggleBluetooth(); |
| + content::RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(delegate->GetBluetoothEnabled()); |
| + |
| + delegate->BluetoothStartDiscovering(); |
| + content::RunAllPendingInMessageLoop(); |
| + EXPECT_TRUE(delegate->GetBluetoothDiscovering()); |
| + EXPECT_TRUE(delegate->IsBluetoothDiscovering()); |
| + |
| + delegate->BluetoothStopDiscovering(); |
| + content::RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(delegate->GetBluetoothDiscovering()); |
| + EXPECT_FALSE(delegate->IsBluetoothDiscovering()); |
| + |
| + // Turn Bluetooth off. |
| + delegate->ToggleBluetooth(); |
| + content::RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(delegate->GetBluetoothEnabled()); |
| +} |
| + |
| } // namespace chromeos |