| 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/foundation_util.h" | 7 #import "base/mac/foundation_util.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "device/bluetooth/test/bluetooth_test_mac.h" | 9 #import "device/bluetooth/test/bluetooth_test_mac.h" |
| 10 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" | 10 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 // When cancelPeripheralConnection is called macOS marks the device as | 73 // When cancelPeripheralConnection is called macOS marks the device as |
| 74 // disconnected. | 74 // disconnected. |
| 75 MockCBPeripheral* mock_peripheral = | 75 MockCBPeripheral* mock_peripheral = |
| 76 base::mac::ObjCCastStrict<MockCBPeripheral>(peripheral); | 76 base::mac::ObjCCastStrict<MockCBPeripheral>(peripheral); |
| 77 [mock_peripheral setState:CBPeripheralStateDisconnected]; | 77 [mock_peripheral setState:CBPeripheralStateDisconnected]; |
| 78 } | 78 } |
| 79 | 79 |
| 80 - (NSArray*)retrieveConnectedPeripheralServiceUUIDs { | 80 - (NSArray*)retrieveConnectedPeripheralServiceUUIDs { |
| 81 return [[_retrieveConnectedPeripheralServiceUUIDs.get() copy] autorelease]; | 81 return [[_retrieveConnectedPeripheralServiceUUIDs copy] autorelease]; |
| 82 } | 82 } |
| 83 | 83 |
| 84 - (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services { | 84 - (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services { |
| 85 [_retrieveConnectedPeripheralServiceUUIDs.get() | 85 [_retrieveConnectedPeripheralServiceUUIDs |
| 86 addObjectsFromArray:[services copy]]; | 86 addObjectsFromArray:[services copy]]; |
| 87 NSMutableArray* connectedPeripherals = [[NSMutableArray alloc] init]; | 87 NSMutableArray* connectedPeripherals = [[NSMutableArray alloc] init]; |
| 88 for (CBUUID* uuid in services) { | 88 for (CBUUID* uuid in services) { |
| 89 NSSet* peripheralSet = | 89 NSSet* peripheralSet = |
| 90 [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid]; | 90 [_connectedMockPeripheralPerServiceUUID objectForKey:uuid]; |
| 91 [connectedPeripherals addObjectsFromArray:peripheralSet.allObjects]; | 91 [connectedPeripherals addObjectsFromArray:peripheralSet.allObjects]; |
| 92 } | 92 } |
| 93 return connectedPeripherals; | 93 return connectedPeripherals; |
| 94 } | 94 } |
| 95 | 95 |
| 96 - (void)setConnectedMockPeripheral:(CBPeripheral*)peripheral | 96 - (void)setConnectedMockPeripheral:(CBPeripheral*)peripheral |
| 97 withServiceUUIDs:(NSSet*)serviceUUIDs { | 97 withServiceUUIDs:(NSSet*)serviceUUIDs { |
| 98 for (CBUUID* uuid in serviceUUIDs) { | 98 for (CBUUID* uuid in serviceUUIDs) { |
| 99 NSMutableSet* peripheralSet = | 99 NSMutableSet* peripheralSet = |
| 100 [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid]; | 100 [_connectedMockPeripheralPerServiceUUID objectForKey:uuid]; |
| 101 if (!peripheralSet) { | 101 if (!peripheralSet) { |
| 102 peripheralSet = [NSMutableSet set]; | 102 peripheralSet = [NSMutableSet set]; |
| 103 [_connectedMockPeripheralPerServiceUUID.get() setObject:peripheralSet | 103 [_connectedMockPeripheralPerServiceUUID setObject:peripheralSet |
| 104 forKey:uuid]; | 104 forKey:uuid]; |
| 105 } | 105 } |
| 106 [peripheralSet addObject:peripheral]; | 106 [peripheralSet addObject:peripheral]; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 - (void)resetRetrieveConnectedPeripheralServiceUUIDs { | 110 - (void)resetRetrieveConnectedPeripheralServiceUUIDs { |
| 111 [_retrieveConnectedPeripheralServiceUUIDs removeAllObjects]; | 111 [_retrieveConnectedPeripheralServiceUUIDs removeAllObjects]; |
| 112 } | 112 } |
| 113 | 113 |
| 114 @end | 114 @end |
| OLD | NEW |