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

Unified Diff: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc

Issue 1979163002: Add DBus plumbing and tests for sending devices with ATT read/writes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@devices
Patch Set: gyp fix 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
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
index 3523cd1cfebdf54a4dcf28481049cbc658a53201..6cebf6021d935bc32331191ca3465524278de3e2 100644
--- a/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_local_gatt_characteristic_unittest.cc
@@ -16,6 +16,9 @@ class BluetoothLocalGattCharacteristicTest : public BluetoothGattServerTest {
BluetoothGattServerTest::SetUp();
StartGattSetup();
+ // We will need this device to use with simulating read/write attribute
+ // value events.
+ device_ = SimulateLowEnergyDevice(1);
read_characteristic_ = BluetoothLocalGattCharacteristic::Create(
BluetoothUUID(kTestUUIDGenericAttribute),
device::BluetoothLocalGattCharacteristic::
@@ -48,16 +51,18 @@ class BluetoothLocalGattCharacteristicTest : public BluetoothGattServerTest {
base::WeakPtr<BluetoothLocalGattCharacteristic> write_characteristic_;
base::WeakPtr<BluetoothLocalGattCharacteristic> notify_characteristic_;
base::WeakPtr<BluetoothLocalGattCharacteristic> indicate_characteristic_;
+ BluetoothDevice* device_;
};
#if defined(OS_CHROMEOS) || defined(OS_LINUX)
TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValue) {
delegate_->value_to_write_ = 0x1337;
SimulateLocalGattCharacteristicValueReadRequest(
- read_characteristic_.get(), GetReadValueCallback(Call::EXPECTED),
+ device_, read_characteristic_.get(), GetReadValueCallback(Call::EXPECTED),
GetCallback(Call::NOT_EXPECTED));
EXPECT_EQ(delegate_->value_to_write_, GetInteger(last_read_value_));
+ EXPECT_EQ(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -65,10 +70,11 @@ TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValue) {
TEST_F(BluetoothLocalGattCharacteristicTest, WriteLocalCharacteristicValue) {
const uint64_t kValueToWrite = 0x7331ul;
SimulateLocalGattCharacteristicValueWriteRequest(
- write_characteristic_.get(), GetValue(kValueToWrite),
+ device_, write_characteristic_.get(), GetValue(kValueToWrite),
GetCallback(Call::EXPECTED), GetCallback(Call::NOT_EXPECTED));
EXPECT_EQ(kValueToWrite, delegate_->last_written_value_);
+ EXPECT_EQ(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -77,10 +83,11 @@ TEST_F(BluetoothLocalGattCharacteristicTest, ReadLocalCharacteristicValueFail) {
delegate_->value_to_write_ = 0x1337;
delegate_->should_fail_ = true;
SimulateLocalGattCharacteristicValueReadRequest(
- read_characteristic_.get(), GetReadValueCallback(Call::NOT_EXPECTED),
- GetCallback(Call::EXPECTED));
+ device_, read_characteristic_.get(),
+ GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
+ EXPECT_NE(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -89,10 +96,11 @@ TEST_F(BluetoothLocalGattCharacteristicTest,
ReadLocalCharacteristicValueWrongPermission) {
delegate_->value_to_write_ = 0x1337;
SimulateLocalGattCharacteristicValueReadRequest(
- write_characteristic_.get(), GetReadValueCallback(Call::NOT_EXPECTED),
- GetCallback(Call::EXPECTED));
+ device_, write_characteristic_.get(),
+ GetReadValueCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(delegate_->value_to_write_, GetInteger(last_read_value_));
+ EXPECT_NE(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -102,10 +110,11 @@ TEST_F(BluetoothLocalGattCharacteristicTest,
const uint64_t kValueToWrite = 0x7331ul;
delegate_->should_fail_ = true;
SimulateLocalGattCharacteristicValueWriteRequest(
- write_characteristic_.get(), GetValue(kValueToWrite),
+ device_, write_characteristic_.get(), GetValue(kValueToWrite),
GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(kValueToWrite, delegate_->last_written_value_);
+ EXPECT_NE(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
@@ -114,10 +123,11 @@ TEST_F(BluetoothLocalGattCharacteristicTest,
WriteLocalCharacteristicValueWrongPermission) {
const uint64_t kValueToWrite = 0x7331ul;
SimulateLocalGattCharacteristicValueWriteRequest(
- read_characteristic_.get(), GetValue(kValueToWrite),
+ device_, read_characteristic_.get(), GetValue(kValueToWrite),
GetCallback(Call::NOT_EXPECTED), GetCallback(Call::EXPECTED));
EXPECT_NE(kValueToWrite, delegate_->last_written_value_);
+ EXPECT_NE(device_->GetIdentifier(), delegate_->last_seen_device_);
}
#endif // defined(OS_CHROMEOS) || defined(OS_LINUX)
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_local_gatt_descriptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698