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

Unified Diff: device/bluetooth/test/bluetooth_test_mac.mm

Issue 2854733002: bluetooth: macOS: BluetoothLowEnergyDeviceMac::IsConnectable() not implemented (Closed)
Patch Set: Adding unittests and implementation Created 3 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/test/bluetooth_test_mac.mm
diff --git a/device/bluetooth/test/bluetooth_test_mac.mm b/device/bluetooth/test/bluetooth_test_mac.mm
index b308802dbfaea87ea641191178c934eed78c73e9..99ef43e242576ae0ed87480cac56a282d8730c2b 100644
--- a/device/bluetooth/test/bluetooth_test_mac.mm
+++ b/device/bluetooth/test/bluetooth_test_mac.mm
@@ -52,10 +52,11 @@ scoped_nsobject<NSDictionary> CreateAdvertisementData(
NSString* name,
NSArray* uuids,
NSDictionary* service_data,
- NSNumber* tx_power) {
+ NSNumber* tx_power,
+ BOOL connectable) {
NSMutableDictionary* advertisement_data(
[NSMutableDictionary dictionaryWithDictionary:@{
- CBAdvertisementDataIsConnectable : @(YES)
+ CBAdvertisementDataIsConnectable : @(connectable)
}]);
if (name) {
@@ -152,6 +153,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
NSNumber* rssi;
NSDictionary* service_data;
NSNumber* tx_power;
+ BOOL connectable;
switch (device_ordinal) {
case 1:
@@ -167,6 +169,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
[NSData dataWithBytes:(unsigned char[]){1} length:1]
};
tx_power = @(static_cast<int8_t>(TestTxPower::LOWEST));
+ connectable = YES;
break;
case 2:
identifier = kTestPeripheralUUID1.c_str();
@@ -183,6 +186,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
[NSData dataWithBytes:(unsigned char[]){0, 2} length:2]
};
tx_power = @(static_cast<int8_t>(TestTxPower::LOWER));
+ connectable = YES;
break;
case 3:
identifier = kTestPeripheralUUID1.c_str();
@@ -191,6 +195,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
uuids = nil;
service_data = nil;
tx_power = nil;
+ connectable = YES;
break;
case 4:
identifier = kTestPeripheralUUID2.c_str();
@@ -199,6 +204,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
uuids = nil;
service_data = nil;
tx_power = nil;
+ connectable = YES;
break;
case 5:
identifier = kTestPeripheralUUID1.c_str();
@@ -207,6 +213,16 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
uuids = nil;
service_data = nil;
tx_power = nil;
+ connectable = YES;
+ break;
+ case 6:
+ identifier = kTestPeripheralUUID1.c_str();
+ name = nil;
+ rssi = @(static_cast<int8_t>(TestRSSI::HIGH));
+ uuids = nil;
+ service_data = nil;
+ tx_power = nil;
+ connectable = NO;
break;
default:
NOTREACHED() << "SimulateLowEnergyDevice not implemented for "
@@ -217,6 +233,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
uuids = nil;
service_data = nil;
tx_power = nil;
+ connectable = NO;
}
scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
initWithUTF8StringIdentifier:identifier
@@ -226,7 +243,7 @@ BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
centralManager:central_manager
didDiscoverPeripheral:mock_peripheral.get().peripheral
advertisementData:CreateAdvertisementData(name, uuids, service_data,
- tx_power)
+ tx_power, connectable)
RSSI:rssi];
return observer.last_device();
}

Powered by Google App Engine
This is Rietveld 408576698