| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright 2017 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. |  | 
| 4 |  | 
| 5 #include "chrome/browser/ui/ash/tray_bluetooth_helper.h" |  | 
| 6 |  | 
| 7 #include <vector> |  | 
| 8 |  | 
| 9 #include "ash/common/system/tray/system_tray_delegate.h" |  | 
| 10 #include "ash/test/ash_test_base.h" |  | 
| 11 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |  | 
| 12 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" |  | 
| 13 |  | 
| 14 using bluez::BluezDBusManager; |  | 
| 15 using bluez::FakeBluetoothAdapterClient; |  | 
| 16 |  | 
| 17 using TrayBluetoothHelperTest = ash::test::AshTestBase; |  | 
| 18 |  | 
| 19 // Tests basic functionality like turning Bluetooth on and off. |  | 
| 20 TEST_F(TrayBluetoothHelperTest, Basics) { |  | 
| 21   // Set Bluetooth discovery simulation delay to 0 so the test doesn't have to |  | 
| 22   // wait or use timers. |  | 
| 23   FakeBluetoothAdapterClient* adapter_client = |  | 
| 24       static_cast<FakeBluetoothAdapterClient*>( |  | 
| 25           BluezDBusManager::Get()->GetBluetoothAdapterClient()); |  | 
| 26   adapter_client->SetSimulationIntervalMs(0); |  | 
| 27 |  | 
| 28   TrayBluetoothHelper helper; |  | 
| 29   helper.Initialize(); |  | 
| 30   RunAllPendingInMessageLoop(); |  | 
| 31   EXPECT_TRUE(helper.GetAvailable()); |  | 
| 32   EXPECT_FALSE(helper.GetEnabled()); |  | 
| 33   EXPECT_FALSE(helper.HasDiscoverySession()); |  | 
| 34   EXPECT_FALSE(helper.IsDiscovering()); |  | 
| 35 |  | 
| 36   std::vector<ash::BluetoothDeviceInfo> devices; |  | 
| 37   helper.GetAvailableDevices(&devices); |  | 
| 38   // The devices are fake in tests, so don't assume any particular number. |  | 
| 39   EXPECT_FALSE(devices.empty()); |  | 
| 40 |  | 
| 41   // Turn Bluetooth on. |  | 
| 42   helper.ToggleEnabled(); |  | 
| 43   RunAllPendingInMessageLoop(); |  | 
| 44   EXPECT_TRUE(helper.GetEnabled()); |  | 
| 45 |  | 
| 46   helper.StartDiscovering(); |  | 
| 47   RunAllPendingInMessageLoop(); |  | 
| 48   EXPECT_TRUE(helper.HasDiscoverySession()); |  | 
| 49   EXPECT_TRUE(helper.IsDiscovering()); |  | 
| 50 |  | 
| 51   helper.StopDiscovering(); |  | 
| 52   RunAllPendingInMessageLoop(); |  | 
| 53   EXPECT_FALSE(helper.HasDiscoverySession()); |  | 
| 54   EXPECT_FALSE(helper.IsDiscovering()); |  | 
| 55 |  | 
| 56   // Turn Bluetooth off. |  | 
| 57   helper.ToggleEnabled(); |  | 
| 58   RunAllPendingInMessageLoop(); |  | 
| 59   EXPECT_FALSE(helper.GetEnabled()); |  | 
| 60 } |  | 
| OLD | NEW | 
|---|