OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/bluetooth/test/bluetooth_test_bluez.h" | 5 #include "device/bluetooth/test/bluetooth_test_bluez.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 BluetoothTestBlueZ::BluetoothTestBlueZ() | 60 BluetoothTestBlueZ::BluetoothTestBlueZ() |
61 : fake_bluetooth_device_client_(nullptr) {} | 61 : fake_bluetooth_device_client_(nullptr) {} |
62 | 62 |
63 BluetoothTestBlueZ::~BluetoothTestBlueZ() {} | 63 BluetoothTestBlueZ::~BluetoothTestBlueZ() {} |
64 | 64 |
65 void BluetoothTestBlueZ::SetUp() { | 65 void BluetoothTestBlueZ::SetUp() { |
66 BluetoothTestBase::SetUp(); | 66 BluetoothTestBase::SetUp(); |
67 std::unique_ptr<bluez::BluezDBusManagerSetter> dbus_setter = | 67 std::unique_ptr<bluez::BluezDBusManagerSetter> dbus_setter = |
68 bluez::BluezDBusManager::GetSetterForTesting(); | 68 bluez::BluezDBusManager::GetSetterForTesting(); |
69 fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient; | 69 fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient; |
70 // TODO(rkc): This is a big hacky. Creating a device client creates three | |
71 // devices by default. For now, the easiest path is to just clear them, but | |
72 // a better way will be to only create them as needed. This will require | |
73 // looking at a lot of tests but should be done eventually. | |
74 fake_bluetooth_device_client_->RemoveAllDevices(); | |
75 dbus_setter->SetBluetoothDeviceClient( | 70 dbus_setter->SetBluetoothDeviceClient( |
76 std::unique_ptr<bluez::BluetoothDeviceClient>( | 71 std::unique_ptr<bluez::BluetoothDeviceClient>( |
77 fake_bluetooth_device_client_)); | 72 fake_bluetooth_device_client_)); |
78 } | 73 } |
79 | 74 |
80 void BluetoothTestBlueZ::TearDown() { | 75 void BluetoothTestBlueZ::TearDown() { |
81 adapter_ = nullptr; | 76 adapter_ = nullptr; |
82 bluez::BluezDBusManager::Shutdown(); | 77 bluez::BluezDBusManager::Shutdown(); |
83 BluetoothTestBase::TearDown(); | 78 BluetoothTestBase::TearDown(); |
84 } | 79 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 std::vector<BluetoothLocalGattService*> services; | 318 std::vector<BluetoothLocalGattService*> services; |
324 bluez::BluetoothAdapterBlueZ* adapter_bluez = | 319 bluez::BluetoothAdapterBlueZ* adapter_bluez = |
325 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); | 320 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter_.get()); |
326 | 321 |
327 for (const auto& iter : adapter_bluez->registered_gatt_services_) | 322 for (const auto& iter : adapter_bluez->registered_gatt_services_) |
328 services.push_back(iter.second); | 323 services.push_back(iter.second); |
329 return services; | 324 return services; |
330 } | 325 } |
331 | 326 |
332 } // namespace device | 327 } // namespace device |
OLD | NEW |