| 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..0a132ff39beb385f89ba9527a587f8d8170da397 100644
|
| --- a/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
|
| +++ b/device/bluetooth/bluez/bluetooth_bluez_unittest.cc
|
| @@ -2490,7 +2490,7 @@ TEST_F(BluetoothBlueZTest, DeviceInquiryRSSIInvalidated) {
|
| properties->rssi.ReplaceValue(-75);
|
| properties->rssi.set_valid(true);
|
|
|
| - ASSERT_EQ(-75, devices[idx]->GetInquiryRSSI());
|
| + ASSERT_EQ(-75, devices[idx]->GetInquiryRSSI().value());
|
|
|
| // Install an observer; expect the DeviceChanged method to be called when
|
| // we invalidate the RSSI of the device.
|
| @@ -2503,8 +2503,56 @@ 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_FALSE(devices[idx]->GetInquiryRSSI());
|
| +}
|
| +
|
| +TEST_F(BluetoothBlueZTest, DeviceInquiryPowerOutOfBounds) {
|
| + // RSSI and Tx Power 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);
|
| + properties->tx_power.set_valid(true);
|
| +
|
| + // Small invalid value
|
| + properties->rssi.ReplaceValue(-129);
|
| + EXPECT_FALSE(devices[idx]->GetInquiryRSSI());
|
| +
|
| + properties->tx_power.ReplaceValue(-129);
|
| + EXPECT_FALSE(devices[idx]->GetInquiryTxPower());
|
| +
|
| + // Small valid value
|
| + properties->rssi.ReplaceValue(-128);
|
| + EXPECT_EQ(-128, devices[idx]->GetInquiryRSSI().value());
|
| +
|
| + properties->tx_power.ReplaceValue(-128);
|
| + EXPECT_EQ(-128, devices[idx]->GetInquiryTxPower().value());
|
| +
|
| + // Large valid value.
|
| + properties->rssi.ReplaceValue(127);
|
| + EXPECT_EQ(127, devices[idx]->GetInquiryRSSI().value());
|
| +
|
| + properties->tx_power.ReplaceValue(127);
|
| + EXPECT_EQ(127, devices[idx]->GetInquiryTxPower().value());
|
| +
|
| + // Large invalid value
|
| + properties->rssi.ReplaceValue(128);
|
| + EXPECT_FALSE(devices[idx]->GetInquiryRSSI());
|
| +
|
| + properties->tx_power.ReplaceValue(128);
|
| + EXPECT_FALSE(devices[idx]->GetInquiryTxPower());
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerInvalidated) {
|
| @@ -2527,7 +2575,7 @@ TEST_F(BluetoothBlueZTest, DeviceInquiryTxPowerInvalidated) {
|
| properties->tx_power.ReplaceValue(0);
|
| properties->tx_power.set_valid(true);
|
|
|
| - ASSERT_EQ(0, devices[idx]->GetInquiryTxPower());
|
| + ASSERT_EQ(0, devices[idx]->GetInquiryTxPower().value());
|
|
|
| // Install an observer; expect the DeviceChanged method to be called when
|
| // we invalidate the tx_power of the device.
|
| @@ -2540,8 +2588,7 @@ 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_FALSE(devices[idx]->GetInquiryTxPower());
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, ForgetDevice) {
|
| @@ -4132,14 +4179,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_FALSE(conn_info.rssi);
|
| + EXPECT_FALSE(conn_info.transmit_power);
|
| + EXPECT_FALSE(conn_info.max_transmit_power);
|
| }
|
|
|
| TEST_F(BluetoothBlueZTest, GetConnectionInfoForConnectedDevice) {
|
| @@ -4157,9 +4204,9 @@ TEST_F(BluetoothBlueZTest, GetConnectionInfoForConnectedDevice) {
|
| fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4);
|
| BluetoothDevice::ConnectionInfo conn_info;
|
| device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info));
|
| - EXPECT_EQ(-10, conn_info.rssi);
|
| - EXPECT_EQ(3, conn_info.transmit_power);
|
| - EXPECT_EQ(4, conn_info.max_transmit_power);
|
| + EXPECT_EQ(-10, conn_info.rssi.value());
|
| + EXPECT_EQ(3, conn_info.transmit_power.value());
|
| + EXPECT_EQ(4, conn_info.max_transmit_power.value());
|
| }
|
|
|
| // Verifies Shutdown shuts down the adapter as expected.
|
|
|