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

Side by Side Diff: device/bluetooth/bluetooth_adapter_mac_unittest.mm

Issue 2906883004: bluetooth: macOS: Removing useless |.get()| (Closed)
Patch Set: Merge from top of tree 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_adapter_mac.h" 5 #include "device/bluetooth/bluetooth_adapter_mac.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return adapter_->GetDevice(address); 62 return adapter_->GetDevice(address);
63 } 63 }
64 64
65 CBPeripheral* CreateMockPeripheral(const char* identifier) { 65 CBPeripheral* CreateMockPeripheral(const char* identifier) {
66 if (!BluetoothAdapterMac::IsLowEnergyAvailable()) { 66 if (!BluetoothAdapterMac::IsLowEnergyAvailable()) {
67 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 67 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
68 return nil; 68 return nil;
69 } 69 }
70 base::scoped_nsobject<MockCBPeripheral> mock_peripheral( 70 base::scoped_nsobject<MockCBPeripheral> mock_peripheral(
71 [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier]); 71 [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier]);
72 return [mock_peripheral.get().peripheral retain]; 72 return [[mock_peripheral peripheral] retain];
73 } 73 }
74 74
75 NSDictionary* AdvertisementData() { 75 NSDictionary* AdvertisementData() {
76 NSDictionary* advertisement_data = @{ 76 NSDictionary* advertisement_data = @{
77 CBAdvertisementDataIsConnectable : @(YES), 77 CBAdvertisementDataIsConnectable : @(YES),
78 CBAdvertisementDataServiceDataKey : [NSDictionary dictionary], 78 CBAdvertisementDataServiceDataKey : [NSDictionary dictionary],
79 }; 79 };
80 return [advertisement_data retain]; 80 return [advertisement_data retain];
81 } 81 }
82 82
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Check that stopScan was not called. 228 // Check that stopScan was not called.
229 EXPECT_EQ(0, [mock_central_manager_ stopScanCallCount]); 229 EXPECT_EQ(0, [mock_central_manager_ stopScanCallCount]);
230 } 230 }
231 231
232 TEST_F(BluetoothAdapterMacTest, CheckGetPeripheralHashAddress) { 232 TEST_F(BluetoothAdapterMacTest, CheckGetPeripheralHashAddress) {
233 if (!SetMockCentralManager(CBCentralManagerStatePoweredOn)) 233 if (!SetMockCentralManager(CBCentralManagerStatePoweredOn))
234 return; 234 return;
235 base::scoped_nsobject<CBPeripheral> mock_peripheral( 235 base::scoped_nsobject<CBPeripheral> mock_peripheral(
236 CreateMockPeripheral(kTestNSUUID)); 236 CreateMockPeripheral(kTestNSUUID));
237 if (mock_peripheral.get() == nil) 237 if (!mock_peripheral)
238 return; 238 return;
239 EXPECT_EQ(kTestHashAddress, GetHashAddress(mock_peripheral)); 239 EXPECT_EQ(kTestHashAddress, GetHashAddress(mock_peripheral));
240 } 240 }
241 241
242 TEST_F(BluetoothAdapterMacTest, LowEnergyDeviceUpdatedNewDevice) { 242 TEST_F(BluetoothAdapterMacTest, LowEnergyDeviceUpdatedNewDevice) {
243 if (!SetMockCentralManager(CBCentralManagerStatePoweredOn)) 243 if (!SetMockCentralManager(CBCentralManagerStatePoweredOn))
244 return; 244 return;
245 base::scoped_nsobject<CBPeripheral> mock_peripheral( 245 base::scoped_nsobject<CBPeripheral> mock_peripheral(
246 CreateMockPeripheral(kTestNSUUID)); 246 CreateMockPeripheral(kTestNSUUID));
247 if (mock_peripheral.get() == nil) 247 if (!mock_peripheral)
248 return; 248 return;
249 base::scoped_nsobject<NSDictionary> advertisement_data(AdvertisementData()); 249 base::scoped_nsobject<NSDictionary> advertisement_data(AdvertisementData());
250 250
251 EXPECT_EQ(0, NumDevices()); 251 EXPECT_EQ(0, NumDevices());
252 EXPECT_FALSE(DevicePresent(mock_peripheral)); 252 EXPECT_FALSE(DevicePresent(mock_peripheral));
253 LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi); 253 LowEnergyDeviceUpdated(mock_peripheral, advertisement_data, kTestRssi);
254 EXPECT_EQ(1, NumDevices()); 254 EXPECT_EQ(1, NumDevices());
255 EXPECT_TRUE(DevicePresent(mock_peripheral)); 255 EXPECT_TRUE(DevicePresent(mock_peripheral));
256 } 256 }
257 257
258 } // namespace device 258 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.mm ('k') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698