| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" | 5 #import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" |
| 6 | 6 |
| 7 #import "base/mac/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #import "device/bluetooth/test/bluetooth_test_mac.h" | 8 #import "device/bluetooth/test/bluetooth_test_mac.h" |
| 9 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" | 9 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 - (void)cancelPeripheralConnection:(CBPeripheral*)peripheral { | 67 - (void)cancelPeripheralConnection:(CBPeripheral*)peripheral { |
| 68 if (_bluetoothTestMac) { | 68 if (_bluetoothTestMac) { |
| 69 _bluetoothTestMac->OnFakeBluetoothGattDisconnect(); | 69 _bluetoothTestMac->OnFakeBluetoothGattDisconnect(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 - (NSArray*)retrieveConnectedPeripheralServiceUUIDs { | 73 - (NSArray*)retrieveConnectedPeripheralServiceUUIDs { |
| 74 return [[_retrieveConnectedPeripheralServiceUUIDs.get() copy] autorelease]; | 74 return [[_retrieveConnectedPeripheralServiceUUIDs copy] autorelease]; |
| 75 } | 75 } |
| 76 | 76 |
| 77 - (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services { | 77 - (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services { |
| 78 [_retrieveConnectedPeripheralServiceUUIDs.get() | 78 [_retrieveConnectedPeripheralServiceUUIDs |
| 79 addObjectsFromArray:[services copy]]; | 79 addObjectsFromArray:[services copy]]; |
| 80 NSMutableArray* connectedPeripherals = [[NSMutableArray alloc] init]; | 80 NSMutableArray* connectedPeripherals = [[NSMutableArray alloc] init]; |
| 81 for (CBUUID* uuid in services) { | 81 for (CBUUID* uuid in services) { |
| 82 NSSet* peripheralSet = | 82 NSSet* peripheralSet = |
| 83 [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid]; | 83 [_connectedMockPeripheralPerServiceUUID objectForKey:uuid]; |
| 84 [connectedPeripherals addObjectsFromArray:peripheralSet.allObjects]; | 84 [connectedPeripherals addObjectsFromArray:peripheralSet.allObjects]; |
| 85 } | 85 } |
| 86 return connectedPeripherals; | 86 return connectedPeripherals; |
| 87 } | 87 } |
| 88 | 88 |
| 89 - (void)setConnectedMockPeripheral:(CBPeripheral*)peripheral | 89 - (void)setConnectedMockPeripheral:(CBPeripheral*)peripheral |
| 90 withServiceUUIDs:(NSSet*)serviceUUIDs { | 90 withServiceUUIDs:(NSSet*)serviceUUIDs { |
| 91 for (CBUUID* uuid in serviceUUIDs) { | 91 for (CBUUID* uuid in serviceUUIDs) { |
| 92 NSMutableSet* peripheralSet = | 92 NSMutableSet* peripheralSet = |
| 93 [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid]; | 93 [_connectedMockPeripheralPerServiceUUID objectForKey:uuid]; |
| 94 if (!peripheralSet) { | 94 if (!peripheralSet) { |
| 95 peripheralSet = [NSMutableSet set]; | 95 peripheralSet = [NSMutableSet set]; |
| 96 [_connectedMockPeripheralPerServiceUUID.get() setObject:peripheralSet | 96 [_connectedMockPeripheralPerServiceUUID setObject:peripheralSet |
| 97 forKey:uuid]; | 97 forKey:uuid]; |
| 98 } | 98 } |
| 99 [peripheralSet addObject:peripheral]; | 99 [peripheralSet addObject:peripheral]; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 - (void)resetRetrieveConnectedPeripheralServiceUUIDs { | 103 - (void)resetRetrieveConnectedPeripheralServiceUUIDs { |
| 104 [_retrieveConnectedPeripheralServiceUUIDs removeAllObjects]; | 104 [_retrieveConnectedPeripheralServiceUUIDs removeAllObjects]; |
| 105 } | 105 } |
| 106 | 106 |
| 107 @end | 107 @end |
| OLD | NEW |