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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_central_manager_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Cleanup Created 4 years, 2 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 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 "device/bluetooth/test/bluetooth_test_mac.h" 8 #import "device/bluetooth/test/bluetooth_test_mac.h"
8 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" 9 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
9 10
10 @implementation MockCentralManager 11 using base::scoped_nsobject;
12
13 @implementation MockCentralManager {
14 scoped_nsobject<NSArray> _connectedMockPeripheral;
15 }
11 16
12 @synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount; 17 @synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount;
13 @synthesize stopScanCallCount = _stopScanCallCount; 18 @synthesize stopScanCallCount = _stopScanCallCount;
14 @synthesize delegate = _delegate; 19 @synthesize delegate = _delegate;
15 @synthesize state = _state; 20 @synthesize state = _state;
16 @synthesize bluetoothTestMac = _bluetoothTestMac; 21 @synthesize bluetoothTestMac = _bluetoothTestMac;
17 22
23 - (instancetype)init {
24 self = [super init];
25 if (self) {
26 _connectedMockPeripheral.reset([[NSArray alloc] init]);
27 }
28 return self;
29 }
30
31 - (void)dealloc {
32 [_connectedMockPeripheral release];
33 [super dealloc];
34 }
35
18 - (BOOL)isKindOfClass:(Class)aClass { 36 - (BOOL)isKindOfClass:(Class)aClass {
19 if (aClass == [CBCentralManager class] || 37 if (aClass == [CBCentralManager class] ||
20 [aClass isSubclassOfClass:[CBCentralManager class]]) { 38 [aClass isSubclassOfClass:[CBCentralManager class]]) {
21 return YES; 39 return YES;
22 } 40 }
23 return [super isKindOfClass:aClass]; 41 return [super isKindOfClass:aClass];
24 } 42 }
25 43
26 - (BOOL)isMemberOfClass:(Class)aClass { 44 - (BOOL)isMemberOfClass:(Class)aClass {
27 if (aClass == [CBCentralManager class] || 45 if (aClass == [CBCentralManager class] ||
(...skipping 18 matching lines...) Expand all
46 _bluetoothTestMac->OnFakeBluetoothDeviceConnectGattCalled(); 64 _bluetoothTestMac->OnFakeBluetoothDeviceConnectGattCalled();
47 } 65 }
48 } 66 }
49 67
50 - (void)cancelPeripheralConnection:(CBPeripheral*)peripheral { 68 - (void)cancelPeripheralConnection:(CBPeripheral*)peripheral {
51 if (_bluetoothTestMac) { 69 if (_bluetoothTestMac) {
52 _bluetoothTestMac->OnFakeBluetoothGattDisconnect(); 70 _bluetoothTestMac->OnFakeBluetoothGattDisconnect();
53 } 71 }
54 } 72 }
55 73
74 - (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services {
75 return _connectedMockPeripheral.get();
76 }
77
78 - (void)setConnectedMockPeripherals:(NSArray*)peripherals {
79 _connectedMockPeripheral.reset([peripherals copy]);
80 }
81
56 @end 82 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698