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

Unified Diff: device/bluetooth/bluetooth_gatt_chromeos_unittest.cc

Issue 788193004: chromeos/dbus: Update Bluetooth GATT API clients to upstream definition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & tbr Created 5 years, 10 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_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc
index fca6a1dc0ae2ddad1bc2d93f9dba723db898cc2a..b4549c726acdd1c28a7bae2f0b8455f8355326e9 100644
--- a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc
@@ -1090,15 +1090,14 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) {
GetHeartRateMeasurementPath().value());
ASSERT_TRUE(characteristic);
EXPECT_EQ(1U, characteristic->GetDescriptors().size());
+ EXPECT_FALSE(characteristic->IsNotifying());
BluetoothGattDescriptor* descriptor = characteristic->GetDescriptors()[0];
EXPECT_FALSE(descriptor->IsLocal());
EXPECT_EQ(BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid(),
descriptor->GetUUID());
- std::vector<uint8> desc_value;
- desc_value.push_back(1);
- desc_value.push_back(0);
+ std::vector<uint8_t> desc_value = {0x00, 0x00};
/* The cached value will be empty until the first read request */
EXPECT_FALSE(ValuesEqual(desc_value, descriptor->GetValue()));
@@ -1139,7 +1138,7 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) {
EXPECT_EQ(0, observer.gatt_service_changed_count_);
EXPECT_EQ(1, observer.gatt_descriptor_value_changed_count_);
- // Read new value.
+ // Read value. The value should remain unchanged.
descriptor->ReadRemoteDescriptor(
base::Bind(&BluetoothGattChromeOSTest::ValueCallback,
base::Unretained(this)),
@@ -1150,6 +1149,32 @@ TEST_F(BluetoothGattChromeOSTest, GattDescriptorValue) {
EXPECT_TRUE(ValuesEqual(last_read_value_, descriptor->GetValue()));
EXPECT_FALSE(ValuesEqual(desc_value, descriptor->GetValue()));
EXPECT_EQ(0, observer.gatt_service_changed_count_);
+ EXPECT_EQ(1, observer.gatt_descriptor_value_changed_count_);
+
+ // Start notifications on the descriptor's characteristic. The descriptor
+ // value should change.
+ characteristic->StartNotifySession(
+ base::Bind(&BluetoothGattChromeOSTest::NotifySessionCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback,
+ base::Unretained(this)));
+ base::MessageLoop::current()->Run();
+ EXPECT_EQ(3, success_callback_count_);
+ EXPECT_EQ(1, error_callback_count_);
+ EXPECT_EQ(1U, update_sessions_.size());
+ EXPECT_TRUE(characteristic->IsNotifying());
+
+ // Read the new descriptor value. We should receive a value updated event.
+ descriptor->ReadRemoteDescriptor(
+ base::Bind(&BluetoothGattChromeOSTest::ValueCallback,
+ base::Unretained(this)),
+ base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback,
+ base::Unretained(this)));
+ EXPECT_EQ(4, success_callback_count_);
+ EXPECT_EQ(1, error_callback_count_);
+ EXPECT_TRUE(ValuesEqual(last_read_value_, descriptor->GetValue()));
+ EXPECT_FALSE(ValuesEqual(desc_value, descriptor->GetValue()));
+ EXPECT_EQ(0, observer.gatt_service_changed_count_);
EXPECT_EQ(2, observer.gatt_descriptor_value_changed_count_);
}

Powered by Google App Engine
This is Rietveld 408576698