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

Unified Diff: device/bluetooth/bluetooth_chromeos_unittest.cc

Issue 1133173002: Expose TxPower for bluetooth devices during discovery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added unittests Created 5 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_adapter_chromeos.cc ('k') | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_chromeos_unittest.cc
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc
index 18728efe125b8347035f072d8a42d536ecf7c099..ad19d8b5c57e3bb7fc4b77a70e1fd95c1b3ebb4a 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -2204,6 +2204,76 @@ TEST_F(BluetoothChromeOSTest, DeviceUuidsChanged) {
EXPECT_EQ(uuids[4], BluetoothUUID("110a"));
}
+TEST_F(BluetoothChromeOSTest, DeviceInquiryRSSIInvalidated) {
+ // Simulate invalidation of inquiry RSSI of a device, as it occurs
+ // when discovery is finished.
+ GetAdapter();
+
+ BluetoothAdapter::DeviceList devices = adapter_->GetDevices();
+ ASSERT_EQ(2U, devices.size());
+ ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress,
+ devices[0]->GetAddress());
+
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath));
+
+ // During discovery, rssi is a valid value (-75)
+ properties->rssi.ReplaceValue(-75);
+ properties->rssi.set_valid(true);
+
+ ASSERT_EQ(-75, devices[0]->GetInquiryRSSI());
+
+ // Install an observer; expect the DeviceChanged method to be called when
+ // we invalidate the RSSI of the device.
+ TestBluetoothAdapterObserver observer(adapter_);
+
+ // When discovery is over, the value should be invalidated.
+ properties->rssi.set_valid(false);
+ properties->NotifyPropertyChanged(properties->rssi.name());
+
+ EXPECT_EQ(1, observer.device_changed_count());
+ EXPECT_EQ(devices[0], observer.last_device());
+
+ int unknown_power = BluetoothDevice::kUnknownPower;
+ EXPECT_EQ(unknown_power, devices[0]->GetInquiryRSSI());
+}
+
+TEST_F(BluetoothChromeOSTest, DeviceInquiryTxPowerInvalidated) {
+ // Simulate invalidation of inquiry TxPower of a device, as it occurs
+ // when discovery is finished.
+ GetAdapter();
+
+ BluetoothAdapter::DeviceList devices = adapter_->GetDevices();
+ ASSERT_EQ(2U, devices.size());
+ ASSERT_EQ(FakeBluetoothDeviceClient::kPairedDeviceAddress,
+ devices[0]->GetAddress());
+
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kPairedDevicePath));
+
+ // During discovery, tx_power is a valid value (0)
+ properties->tx_power.ReplaceValue(0);
+ properties->tx_power.set_valid(true);
+
+ ASSERT_EQ(0, devices[0]->GetInquiryTxPower());
+
+ // Install an observer; expect the DeviceChanged method to be called when
+ // we invalidate the tx_power of the device.
+ TestBluetoothAdapterObserver observer(adapter_);
+
+ // When discovery is over, the value should be invalidated.
+ properties->tx_power.set_valid(false);
+ properties->NotifyPropertyChanged(properties->tx_power.name());
+
+ EXPECT_EQ(1, observer.device_changed_count());
+ EXPECT_EQ(devices[0], observer.last_device());
+
+ int unknown_power = BluetoothDevice::kUnknownPower;
+ EXPECT_EQ(unknown_power, devices[0]->GetInquiryTxPower());
+}
+
TEST_F(BluetoothChromeOSTest, ForgetDevice) {
GetAdapter();
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.cc ('k') | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698