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

Unified Diff: device/bluetooth/bluetooth_adapter_mac_unittest.mm

Issue 1842223003: Remove outdated devices from Android device chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test for ItemChooserDialog Created 4 years, 8 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
Index: device/bluetooth/bluetooth_adapter_mac_unittest.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac_unittest.mm b/device/bluetooth/bluetooth_adapter_mac_unittest.mm
index 2436375441ef9c28b117dd6eef1abdc57d790429..90bee2814398e4b83bbf1d1889c6f736b415985b 100644
--- a/device/bluetooth/bluetooth_adapter_mac_unittest.mm
+++ b/device/bluetooth/bluetooth_adapter_mac_unittest.mm
@@ -79,12 +79,6 @@ class BluetoothAdapterMacTest : public testing::Test {
return BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
}
- void SetDeviceTimeGreaterThanTimeout(BluetoothLowEnergyDeviceMac* device) {
- device->last_update_time_.reset([[NSDate
- dateWithTimeInterval:-(BluetoothAdapterMac::kDiscoveryTimeoutSec + 1)
- sinceDate:[NSDate date]] retain]);
- }
-
void AddLowEnergyDevice(BluetoothLowEnergyDeviceMac* device) {
adapter_mac_->devices_.set(device->GetAddress(),
scoped_ptr<BluetoothDevice>(device));
@@ -98,8 +92,6 @@ class BluetoothAdapterMacTest : public testing::Test {
return (device != NULL);
}
- void RemoveTimedOutDevices() { adapter_mac_->RemoveTimedOutDevices(); }
-
bool SetMockCentralManager(CBCentralManagerState desired_state) {
if (!BluetoothAdapterMac::IsLowEnergyAvailable()) {
LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
@@ -268,62 +260,4 @@ TEST_F(BluetoothAdapterMacTest, LowEnergyDeviceUpdatedNewDevice) {
EXPECT_TRUE(DevicePresent(mock_peripheral));
}
-TEST_F(BluetoothAdapterMacTest, LowEnergyDeviceUpdatedOldDevice) {
- if (!SetMockCentralManager(CBCentralManagerStatePoweredOn))
- return;
- base::scoped_nsobject<CBPeripheral> mock_peripheral(
- CreateMockPeripheral(kTestNSUUID));
- if (mock_peripheral.get() == nil)
- return;
- base::scoped_nsobject<NSDictionary> advertisement_data(
- CreateAdvertisementData());
-
- // Update the device for the first time and check it was correctly added to
- // |devices_|.
- EXPECT_EQ(0, NumDevices());
- EXPECT_FALSE(DevicePresent(mock_peripheral));
- LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi);
- EXPECT_EQ(1, NumDevices());
- EXPECT_TRUE(DevicePresent(mock_peripheral));
- // Search for the device by the address corresponding to |kTestNSUUID|.
- BluetoothDeviceMac* device =
- static_cast<BluetoothDeviceMac*>(GetDevice(kTestHashAddress));
- base::scoped_nsobject<NSDate> first_update_time(
- [device->GetLastUpdateTime() retain]);
-
- // Update the device a second time. The device should be updated in
- // |devices_| so check the time returned by GetLastUpdateTime() has increased.
- LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi);
- EXPECT_EQ(1, NumDevices());
- EXPECT_TRUE(DevicePresent(mock_peripheral));
- device = static_cast<BluetoothDeviceMac*>(GetDevice(kTestHashAddress));
- EXPECT_TRUE([device->GetLastUpdateTime() compare:first_update_time] ==
- NSOrderedDescending);
-}
-
-TEST_F(BluetoothAdapterMacTest, UpdateDevicesRemovesLowEnergyDevice) {
- if (!SetMockCentralManager(CBCentralManagerStatePoweredOn))
- return;
- base::scoped_nsobject<CBPeripheral> mock_peripheral(
- CreateMockPeripheral(kTestNSUUID));
- if (mock_peripheral.get() == nil)
- return;
- base::scoped_nsobject<NSDictionary> advertisement_data(
- CreateAdvertisementData());
-
- BluetoothLowEnergyDeviceMac* device = new BluetoothLowEnergyDeviceMac(
- adapter_mac_, mock_peripheral, advertisement_data, kTestRssi);
- SetDeviceTimeGreaterThanTimeout(device);
-
- EXPECT_EQ(0, NumDevices());
- AddLowEnergyDevice(device);
- EXPECT_EQ(1, NumDevices());
- EXPECT_TRUE(DevicePresent(mock_peripheral));
-
- // Check that object pointed to by |device| is deleted by the adapter.
- RemoveTimedOutDevices();
- EXPECT_EQ(0, NumDevices());
- EXPECT_FALSE(DevicePresent(mock_peripheral));
-}
-
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698