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

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: 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
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..cc7e6cfa1f12cad81f92a2b3b880430419a77064 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
ortuno 2016/01/19 17:55:45 Colon at the end of a sentence.
tommyt 2016/01/20 07:54:08 Done.
+ 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
ortuno 2016/01/19 17:55:45 Colon at the end of a sentence.
tommyt 2016/01/20 07:54:08 Done.
+ 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
ortuno 2016/01/19 17:55:46 Colon at the end of a sentence.
tommyt 2016/01/20 07:54:08 Done.
+ 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) {
« device/bluetooth/bluetooth_device.cc ('K') | « device/bluetooth/bluetooth_device_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698