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

Unified Diff: device/bluetooth/bluetooth_gatt_bluez_unittest.cc

Issue 1606523002: Tidy up service discovery state for bluez on disconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address issues highlighted in code review Created 4 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/bluetooth_adapter_bluez.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_gatt_bluez_unittest.cc
diff --git a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc
index 575c867b2f56ebccf49aba049ce136f1f0aacba6..8641c35c47b186d2ca544b160b985b78fad69e90 100644
--- a/device/bluetooth/bluetooth_gatt_bluez_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_bluez_unittest.cc
@@ -377,10 +377,41 @@ TEST_F(BluetoothGattBlueZTest, ServicesDiscovered) {
properties->gatt_services.ReplaceValue(
fake_bluetooth_gatt_service_client_->GetServices());
+ EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
+ EXPECT_EQ(1u, device->GetGattServices().size());
EXPECT_EQ(1, observer.gatt_services_discovered_count());
EXPECT_EQ(device, observer.last_device());
EXPECT_EQ(bluez::FakeBluetoothDeviceClient::kLowEnergyAddress,
observer.last_device_address());
+
+ // Disconnect from the device:
+ device->Disconnect(base::Bind(&BluetoothGattBlueZTest::SuccessCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothGattBlueZTest::ErrorCallback,
+ base::Unretained(this)));
+ fake_bluetooth_gatt_service_client_->HideHeartRateService();
+ properties->connected.ReplaceValue(false);
+
+ EXPECT_FALSE(device->IsConnected());
+ EXPECT_FALSE(device->IsGattServicesDiscoveryComplete());
+ EXPECT_EQ(0u, device->GetGattServices().size());
+
+ // Verify that the device can be connected to again:
+ device->CreateGattConnection(
+ base::Bind(&BluetoothGattBlueZTest::GattConnectionCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothGattBlueZTest::ConnectErrorCallback,
+ base::Unretained(this)));
+ properties->connected.ReplaceValue(true);
+ EXPECT_TRUE(device->IsConnected());
+
+ // Verify that service discovery can be done again:
+ fake_bluetooth_gatt_service_client_->ExposeHeartRateService(
+ dbus::ObjectPath(bluez::FakeBluetoothDeviceClient::kLowEnergyPath));
+ properties->gatt_services.ReplaceValue(
+ fake_bluetooth_gatt_service_client_->GetServices());
+ EXPECT_TRUE(device->IsGattServicesDiscoveryComplete());
+ EXPECT_EQ(1u, device->GetGattServices().size());
}
TEST_F(BluetoothGattBlueZTest, GattCharacteristicAddedAndRemoved) {
« no previous file with comments | « device/bluetooth/bluetooth_adapter_bluez.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698