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

Unified Diff: device/bluetooth/bluez/bluetooth_bluez_unittest.cc

Issue 2908673002: device/blueooth: Add BlueZ unit test for BluetoothDevice::SetConnectionInterval. (Closed)
Patch Set: test invalid case Created 3 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 | « no previous file | device/bluetooth/dbus/fake_bluetooth_device_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluez/bluetooth_bluez_unittest.cc
diff --git a/device/bluetooth/bluez/bluetooth_bluez_unittest.cc b/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
index 6632d545665ff191c6a3183eef6a23a3f1d8eba4..1d62713383a1b948e0c0e08e1f0d8a657304f21d 100644
--- a/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
+++ b/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
@@ -4576,4 +4576,54 @@ TEST_F(BluetoothBlueZTest, AdvertisingDataFlagsChanged) {
EXPECT_EQ(0x23u, device->GetAdvertisingDataFlags().value());
}
+TEST_F(BluetoothBlueZTest, SetConnectionLatency) {
+ GetAdapter();
+ DiscoverDevices();
+
+ // SetConnectionLatency is supported on LE devices.
+ bluez::FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
+ bluez::FakeBluetoothDeviceClient::kConnectUnpairablePath));
+ properties->type.ReplaceValue(BluetoothDeviceClient::kTypeLe);
+ BluetoothDevice* device = adapter_->GetDevice(
+ bluez::FakeBluetoothDeviceClient::kConnectUnpairableAddress);
+ ASSERT_TRUE(device);
+
+ device->SetConnectionLatency(
+ BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_LOW, GetCallback(),
+ GetErrorCallback());
+ EXPECT_EQ(1, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+
+ device->SetConnectionLatency(
+ BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_HIGH,
+ GetCallback(), GetErrorCallback());
+ EXPECT_EQ(2, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+
+ // Dual mode devices should be supported as well.
+ properties->type.ReplaceValue(BluetoothDeviceClient::kTypeDual);
+ device->SetConnectionLatency(
+ BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM,
+ GetCallback(), GetErrorCallback());
+ EXPECT_EQ(3, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+
+ // This API is not supported for BR/EDR devices.
+ properties->type.ReplaceValue(BluetoothDeviceClient::kTypeBredr);
+ device->SetConnectionLatency(
+ BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM,
+ GetCallback(), GetErrorCallback());
+ EXPECT_EQ(3, callback_count_);
+ EXPECT_EQ(1, error_callback_count_);
+
+ // Return an error if the type is not valid.
+ properties->type.set_valid(false);
+ device->SetConnectionLatency(
+ BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_MEDIUM,
+ GetCallback(), GetErrorCallback());
+ EXPECT_EQ(3, callback_count_);
+ EXPECT_EQ(2, error_callback_count_);
+}
+
} // namespace bluez
« no previous file with comments | « no previous file | device/bluetooth/dbus/fake_bluetooth_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698