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

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

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Nit for the tests Created 4 years, 1 month 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_central_manager_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
diff --git a/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm b/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
index fbb0dff41e75d315a5044a6e61dde508fe7382fd..b4f06a273de3c3d80a1a18b074b98705bd6fe6a6 100644
--- a/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
@@ -4,10 +4,16 @@
#import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"
+#import "base/mac/scoped_nsobject.h"
#import "device/bluetooth/test/bluetooth_test_mac.h"
#import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
-@implementation MockCentralManager
+using base::scoped_nsobject;
+
+@implementation MockCentralManager {
+ scoped_nsobject<NSMutableDictionary> _connectedMockPeripheralPerServiceUUID;
+ scoped_nsobject<NSMutableArray> _retrieveConnectedPeripheralServiceUUIDs;
+}
@synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount;
@synthesize stopScanCallCount = _stopScanCallCount;
@@ -15,6 +21,17 @@
@synthesize state = _state;
@synthesize bluetoothTestMac = _bluetoothTestMac;
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _connectedMockPeripheralPerServiceUUID.reset(
+ [[NSMutableDictionary alloc] init]);
+ _retrieveConnectedPeripheralServiceUUIDs.reset(
+ [[NSMutableArray alloc] init]);
+ }
+ return self;
+}
+
- (BOOL)isKindOfClass:(Class)aClass {
if (aClass == [CBCentralManager class] ||
[aClass isSubclassOfClass:[CBCentralManager class]]) {
@@ -53,4 +70,38 @@
}
}
+- (NSArray*)retrieveConnectedPeripheralServiceUUIDs {
+ return [[_retrieveConnectedPeripheralServiceUUIDs.get() copy] autorelease];
+}
+
+- (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services {
+ [_retrieveConnectedPeripheralServiceUUIDs.get()
+ addObjectsFromArray:[services copy]];
+ NSMutableArray* connectedPeripherals = [[NSMutableArray alloc] init];
+ for (CBUUID* uuid in services) {
+ NSSet* peripheralSet =
+ [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid];
+ [connectedPeripherals addObjectsFromArray:peripheralSet.allObjects];
+ }
+ return connectedPeripherals;
+}
+
+- (void)setConnectedMockPeripheral:(CBPeripheral*)peripheral
+ withServiceUUIDs:(NSSet*)serviceUUIDs {
+ for (CBUUID* uuid in serviceUUIDs) {
+ NSMutableSet* peripheralSet =
+ [_connectedMockPeripheralPerServiceUUID.get() objectForKey:uuid];
+ if (!peripheralSet) {
+ peripheralSet = [NSMutableSet set];
+ [_connectedMockPeripheralPerServiceUUID.get() setObject:peripheralSet
+ forKey:uuid];
+ }
+ [peripheralSet addObject:peripheral];
+ }
+}
+
+- (void)resetRetrieveConnectedPeripheralServiceUUIDs {
+ [_retrieveConnectedPeripheralServiceUUIDs removeAllObjects];
+}
+
@end
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_central_manager_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698