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

Unified Diff: device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc

Issue 1947353002: //device/bluetooth support for attribute properties and permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@properties
Patch Set: Created 4 years, 7 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_local_gatt_descriptor_unittest.cc
diff --git a/device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc b/device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc
index 2a318b29265fd8e28eb41dc2cc3b6abac2794f1e..1e93540d2471cd55cb3a7d6df4242926c6ccd449 100644
--- a/device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc
+++ b/device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc
@@ -22,25 +22,32 @@ class BluetoothLocalGattDescriptorTest : public BluetoothGattServerTest {
device::BluetoothLocalGattCharacteristic::Properties(),
device::BluetoothLocalGattCharacteristic::Permissions(),
service_.get());
- descriptor_ = BluetoothLocalGattDescriptor::Create(
+ read_descriptor_ = BluetoothLocalGattDescriptor::Create(
BluetoothUUID(kTestUUIDGenericAttribute),
- device::BluetoothLocalGattCharacteristic::Permissions(),
+ device::BluetoothLocalGattCharacteristic::PERMISSION_READ,
+ characteristic_.get());
+ write_descriptor_ = BluetoothLocalGattDescriptor::Create(
+ BluetoothUUID(kTestUUIDGenericAttribute),
+ device::BluetoothLocalGattCharacteristic::
+ PERMISSION_WRITE_ENCRYPTED_AUTHENTICATED,
characteristic_.get());
- EXPECT_LT(0u, descriptor_->GetIdentifier().size());
+ EXPECT_LT(0u, read_descriptor_->GetIdentifier().size());
+ EXPECT_LT(0u, write_descriptor_->GetIdentifier().size());
CompleteGattSetup();
}
protected:
base::WeakPtr<BluetoothLocalGattCharacteristic> characteristic_;
- base::WeakPtr<BluetoothLocalGattDescriptor> descriptor_;
+ base::WeakPtr<BluetoothLocalGattDescriptor> read_descriptor_;
+ base::WeakPtr<BluetoothLocalGattDescriptor> write_descriptor_;
};
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValue) {
delegate_->value_to_write_ = 0x1337;
SimulateLocalGattDescriptorValueReadRequest(
- service_.get(), descriptor_.get(), GetReadValueCallback(Call::EXPECTED),
- GetCallback(Call::NOT_EXPECTED));
+ service_.get(), read_descriptor_.get(),
+ GetReadValueCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
EXPECT_EQ(delegate_->value_to_write_, GetInteger(last_read_value_));
}
@@ -50,7 +57,7 @@ TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValue) {
TEST_F(BluetoothLocalGattDescriptorTest, WriteLocalDescriptorValue) {
const uint64_t kValueToWrite = 0x7331ul;
SimulateLocalGattDescriptorValueWriteRequest(
- service_.get(), descriptor_.get(), GetValue(kValueToWrite),
+ service_.get(), write_descriptor_.get(), GetValue(kValueToWrite),
GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
EXPECT_EQ(kValueToWrite, delegate_->last_written_value_);
@@ -62,7 +69,7 @@ TEST_F(BluetoothLocalGattDescriptorTest, ReadLocalDescriptorValueFail) {
delegate_->value_to_write_ = 0x1337;
delegate_->should_fail_ = true;
SimulateLocalGattDescriptorValueReadRequest(
- service_.get(), descriptor_.get(),
+ service_.get(), read_descriptor_.get(),
GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
@@ -74,7 +81,31 @@ TEST_F(BluetoothLocalGattDescriptorTest, WriteLocalDescriptorValueFail) {
const uint64_t kValueToWrite = 0x7331ul;
delegate_->should_fail_ = true;
SimulateLocalGattDescriptorValueWriteRequest(
- service_.get(), descriptor_.get(), GetValue(kValueToWrite),
+ service_.get(), write_descriptor_.get(), GetValue(kValueToWrite),
+ GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
+
+ EXPECT_NE(kValueToWrite, delegate_->last_written_value_);
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattDescriptorTest,
+ ReadLocalDescriptorValueWrongPermissions) {
+ delegate_->value_to_write_ = 0x1337;
+ SimulateLocalGattDescriptorValueReadRequest(
+ service_.get(), write_descriptor_.get(),
+ GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
+
+ EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
+}
+#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
+
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+TEST_F(BluetoothLocalGattDescriptorTest,
+ WriteLocalDescriptorValueWrongPermissions) {
+ const uint64_t kValueToWrite = 0x7331ul;
+ SimulateLocalGattDescriptorValueWriteRequest(
+ service_.get(), read_descriptor_.get(), GetValue(kValueToWrite),
GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(kValueToWrite, delegate_->last_written_value_);

Powered by Google App Engine
This is Rietveld 408576698