Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: device/bluetooth/test/bluetooth_test_bluez.cc

Issue 2640883002: Enable more unittests for BlueZ and ChromeOS. (Closed)
Patch Set: Added comment in TearDown. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/test/bluetooth_test_bluez.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/bluetooth_test_bluez.cc
diff --git a/device/bluetooth/test/bluetooth_test_bluez.cc b/device/bluetooth/test/bluetooth_test_bluez.cc
index d492f4a196461e96ca0c20e39658d7c0bc052637..19ac65aea94f29faa49667915d13140cf0f8d967 100644
--- a/device/bluetooth/test/bluetooth_test_bluez.cc
+++ b/device/bluetooth/test/bluetooth_test_bluez.cc
@@ -66,13 +66,38 @@ void BluetoothTestBlueZ::SetUp() {
BluetoothTestBase::SetUp();
std::unique_ptr<bluez::BluezDBusManagerSetter> dbus_setter =
bluez::BluezDBusManager::GetSetterForTesting();
+
+ fake_bluetooth_adapter_client_ = new bluez::FakeBluetoothAdapterClient;
+ dbus_setter->SetBluetoothAdapterClient(
+ std::unique_ptr<bluez::BluetoothAdapterClient>(
+ fake_bluetooth_adapter_client_));
+
fake_bluetooth_device_client_ = new bluez::FakeBluetoothDeviceClient;
dbus_setter->SetBluetoothDeviceClient(
std::unique_ptr<bluez::BluetoothDeviceClient>(
fake_bluetooth_device_client_));
+
+ // Make the fake adapter post tasks without delay in order to avoid timing
+ // issues.
+ fake_bluetooth_adapter_client_->SetSimulationIntervalMs(0);
}
void BluetoothTestBlueZ::TearDown() {
+ // Connections and sessions will normally be closed by destructors,
+ // but for BlueZ we need to close them before shutting down the
+ // BluezDBusManager.
+ for (const auto& connection : gatt_connections_) {
+ if (connection->IsConnected())
+ connection->Disconnect();
+ }
+ gatt_connections_.clear();
+
+ for (const auto& session : discovery_sessions_) {
+ if (session->IsActive())
+ session->Stop(base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
+ }
+ discovery_sessions_.clear();
+
adapter_ = nullptr;
bluez::BluezDBusManager::Shutdown();
BluetoothTestBase::TearDown();
@@ -87,6 +112,8 @@ void BluetoothTestBlueZ::InitWithFakeAdapter() {
adapter_ = new bluez::BluetoothAdapterBlueZ(
base::Bind(&AdapterCallback, run_loop.QuitClosure()));
run_loop.Run();
+ adapter_->SetPowered(true, base::Bind(&base::DoNothing),
+ base::Bind(&base::DoNothing));
}
BluetoothDevice* BluetoothTestBlueZ::SimulateLowEnergyDevice(
« no previous file with comments | « device/bluetooth/test/bluetooth_test_bluez.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698