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

Unified Diff: device/bluetooth/bluetooth_gatt_characteristic_unittest.cc

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: Defer c++ pointer to a later patch. 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_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
index f2ddab72aa9b801eab5186a7b5122ad52112fec3..a36b80d399e01d8feff6f50a0728e74eac8a1e79 100644
--- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
@@ -701,4 +701,51 @@ TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) {
}
#endif // defined(OS_ANDROID)
+#if defined(OS_ANDROID)
+TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+
+ EXPECT_EQ(0u, characteristic1_->GetDescriptors().size());
+}
+#endif // defined(OS_ANDROID)
+
+#if defined(OS_ANDROID)
+TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) {
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+
+ // Add several Descriptors:
+ BluetoothUUID uuid1("11111111-0000-1000-8000-00805f9b34fb");
+ BluetoothUUID uuid2("22222222-0000-1000-8000-00805f9b34fb");
+ BluetoothUUID uuid3("33333333-0000-1000-8000-00805f9b34fb");
+ BluetoothUUID uuid4("44444444-0000-1000-8000-00805f9b34fb");
+ SimulateGattDescriptor(characteristic1_, uuid1.canonical_value());
+ SimulateGattDescriptor(characteristic1_, uuid2.canonical_value());
+ SimulateGattDescriptor(characteristic2_, uuid3.canonical_value());
+ SimulateGattDescriptor(characteristic2_, uuid4.canonical_value());
+
+ // Verify that GetDescriptor can retrieve descriptors again by ID,
+ // and that the same Descriptor is returned when searched by ID.
+ EXPECT_EQ(2u, characteristic1_->GetDescriptors().size());
+ EXPECT_EQ(2u, characteristic2_->GetDescriptors().size());
+ std::string c1_id1 = characteristic1_->GetDescriptors()[0]->GetIdentifier();
+ std::string c1_id2 = characteristic1_->GetDescriptors()[1]->GetIdentifier();
+ std::string c2_id1 = characteristic2_->GetDescriptors()[0]->GetIdentifier();
+ std::string c2_id2 = characteristic2_->GetDescriptors()[1]->GetIdentifier();
+ BluetoothUUID c1_uuid1 = characteristic1_->GetDescriptors()[0]->GetUUID();
+ BluetoothUUID c1_uuid2 = characteristic1_->GetDescriptors()[1]->GetUUID();
+ BluetoothUUID c2_uuid1 = characteristic2_->GetDescriptors()[0]->GetUUID();
+ BluetoothUUID c2_uuid2 = characteristic2_->GetDescriptors()[1]->GetUUID();
+ EXPECT_EQ(c1_uuid1, characteristic1_->GetDescriptor(c1_id1)->GetUUID());
Jeffrey Yasskin 2016/01/12 21:53:54 Also check that the pointer is the same for multip
scheib 2016/01/12 23:16:55 Done.
+ EXPECT_EQ(c1_uuid2, characteristic1_->GetDescriptor(c1_id2)->GetUUID());
+ EXPECT_EQ(c2_uuid1, characteristic2_->GetDescriptor(c2_id1)->GetUUID());
+ EXPECT_EQ(c2_uuid2, characteristic2_->GetDescriptor(c2_id2)->GetUUID());
+
+ // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order).
+ EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1);
+ EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2);
+ // ... but not uuid 3
+ EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3);
+}
+#endif // defined(OS_ANDROID)
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698