| 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 c2f0fa1bb3b010df85dd0ba7fab1e6bd69a53261..86d0ef12d0ad9814a2b4f9d4abf902d114d02d83 100644
|
| --- a/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
|
| +++ b/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
|
| @@ -2503,8 +2503,43 @@ TEST_F(BluetoothBlueZTest, DeviceInquiryRSSIInvalidated) {
|
| EXPECT_EQ(1, observer.device_changed_count());
|
| EXPECT_EQ(devices[idx], observer.last_device());
|
|
|
| - int unknown_power = BluetoothDevice::kUnknownPower;
|
| - EXPECT_EQ(unknown_power, devices[idx]->GetInquiryRSSI());
|
| + EXPECT_EQ(BluetoothDevice::kUnknownRSSI, devices[idx]->GetInquiryRSSI());
|
| +}
|
| +
|
| +TEST_F(BluetoothBlueZTest, DeviceInquiryRSSIOutOfBounds) {
|
| + // RSSI should be a int8 but Bluez returns a int16 because DBus doesn't
|
| + // support int8 even though Bluez uses a int8 internally. This test
|
| + // makes sure we handle values outside of the int8 range.
|
| + GetAdapter();
|
| +
|
| + BluetoothAdapter::DeviceList devices = adapter_->GetDevices();
|
| + ASSERT_EQ(2U, devices.size());
|
| +
|
| + int idx = GetDeviceIndexByAddress(
|
| + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress);
|
| + ASSERT_NE(-1, idx);
|
| +
|
| + bluez::FakeBluetoothDeviceClient::Properties* properties =
|
| + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
|
| + bluez::FakeBluetoothDeviceClient::kPairedDevicePath));
|
| +
|
| + properties->rssi.set_valid(true);
|
| +
|
| + // Small invalid value
|
| + properties->rssi.ReplaceValue(-129);
|
| + EXPECT_EQ(BluetoothDevice::kUnknownRSSI, devices[idx]->GetInquiryRSSI());
|
| +
|
| + // Small valid value
|
| + properties->rssi.ReplaceValue(-128);
|
| + EXPECT_EQ(-128, devices[idx]->GetInquiryRSSI());
|
| +
|
| + // Large valid value. (127 is used for BluetoothDevice::kUnknownRSSI).
|
| + properties->rssi.ReplaceValue(126);
|
| + EXPECT_EQ(126, devices[idx]->GetInquiryRSSI());
|
| +
|
| + // Large invalid value
|
| + properties->rssi.ReplaceValue(128);
|
| + EXPECT_EQ(BluetoothDevice::kUnknownRSSI, devices[idx]->GetInquiryRSSI());
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerInvalidated) {
|
| @@ -2540,8 +2575,46 @@ TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerInvalidated) {
|
| EXPECT_EQ(1, observer.device_changed_count());
|
| EXPECT_EQ(devices[idx], observer.last_device());
|
|
|
| - int unknown_power = BluetoothDevice::kUnknownPower;
|
| - EXPECT_EQ(unknown_power, devices[idx]->GetInquiryTxPower());
|
| + EXPECT_EQ(BluetoothDevice::kUnknownTxPower,
|
| + devices[idx]->GetInquiryTxPower());
|
| +}
|
| +
|
| +TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerOutOfBounds) {
|
| + // TxPower should be a int8 but Bluez returns a int16 because DBus doesn't
|
| + // support int8 even though Bluez uses a int8 internally. This test
|
| + // makes sure we handle values outside of the int8 range.
|
| + GetAdapter();
|
| +
|
| + BluetoothAdapter::DeviceList devices = adapter_->GetDevices();
|
| + ASSERT_EQ(2U, devices.size());
|
| +
|
| + int idx = GetDeviceIndexByAddress(
|
| + devices, bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress);
|
| + ASSERT_NE(-1, idx);
|
| +
|
| + bluez::FakeBluetoothDeviceClient::Properties* properties =
|
| + fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
|
| + bluez::FakeBluetoothDeviceClient::kPairedDevicePath));
|
| +
|
| + properties->tx_power.set_valid(true);
|
| +
|
| + // Small invalid value
|
| + properties->tx_power.ReplaceValue(-129);
|
| + EXPECT_EQ(BluetoothDevice::kUnknownTxPower,
|
| + devices[idx]->GetInquiryTxPower());
|
| +
|
| + // Small valid value. (-128 is used for BluetoothDevice::kUnknownRSSI).
|
| + properties->tx_power.ReplaceValue(-127);
|
| + EXPECT_EQ(-127, devices[idx]->GetInquiryTxPower());
|
| +
|
| + // Large valid value.
|
| + properties->tx_power.ReplaceValue(126);
|
| + EXPECT_EQ(126, devices[idx]->GetInquiryTxPower());
|
| +
|
| + // Large invalid value
|
| + properties->tx_power.ReplaceValue(128);
|
| + EXPECT_EQ(BluetoothDevice::kUnknownTxPower,
|
| + devices[idx]->GetInquiryTxPower());
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, ForgetDevice) {
|
| @@ -4132,14 +4205,14 @@ TEST_F(BluetoothBlueZTest, GetConnectionInfoForDisconnectedDevice) {
|
| bluez::FakeBluetoothDeviceClient::kPairedDeviceAddress);
|
|
|
| // Calling GetConnectionInfo for an unconnected device should return a result
|
| - // in which all fields are filled with BluetoothDevice::kUnknownPower.
|
| + // in which all fields are filled with BluetoothDevice::kUnknownRSSI and
|
| + // BluetoothDevice::kUnknownTxPower.
|
| BluetoothDevice::ConnectionInfo conn_info(0, 0, 0);
|
| device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info));
|
| - int unknown_power = BluetoothDevice::kUnknownPower;
|
| - EXPECT_NE(0, unknown_power);
|
| - EXPECT_EQ(unknown_power, conn_info.rssi);
|
| - EXPECT_EQ(unknown_power, conn_info.transmit_power);
|
| - EXPECT_EQ(unknown_power, conn_info.max_transmit_power);
|
| +
|
| + EXPECT_TRUE(conn_info.rssi == BluetoothDevice::kUnknownRSSI);
|
| + EXPECT_TRUE(conn_info.transmit_power == BluetoothDevice::kUnknownTxPower);
|
| + EXPECT_TRUE(conn_info.max_transmit_power == BluetoothDevice::kUnknownTxPower);
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, GetConnectionInfoForConnectedDevice) {
|
|
|