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 "mock_bluetooth_central_manager_mac.h" | 5 #import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" |
| 6 |
| 7 #import "device/bluetooth/test/bluetooth_test_mac.h" |
| 8 #import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h" |
6 | 9 |
7 @implementation MockCentralManager | 10 @implementation MockCentralManager |
8 | 11 |
9 @synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount; | 12 @synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount; |
10 @synthesize stopScanCallCount = _stopScanCallCount; | 13 @synthesize stopScanCallCount = _stopScanCallCount; |
11 @synthesize delegate = _delegate; | 14 @synthesize delegate = _delegate; |
12 @synthesize state = _state; | 15 @synthesize state = _state; |
| 16 @synthesize bluetoothTestMac = _bluetoothTestMac; |
| 17 |
| 18 - (BOOL)isKindOfClass:(Class)aClass { |
| 19 if (aClass == [CBCentralManager class] || |
| 20 [aClass isSubclassOfClass:[CBCentralManager class]]) { |
| 21 return YES; |
| 22 } |
| 23 return [super isKindOfClass:aClass]; |
| 24 } |
| 25 |
| 26 - (BOOL)isMemberOfClass:(Class)aClass { |
| 27 if (aClass == [CBCentralManager class] || |
| 28 [aClass isSubclassOfClass:[CBCentralManager class]]) { |
| 29 return YES; |
| 30 } |
| 31 return [super isKindOfClass:aClass]; |
| 32 } |
13 | 33 |
14 - (void)scanForPeripheralsWithServices:(NSArray*)serviceUUIDs | 34 - (void)scanForPeripheralsWithServices:(NSArray*)serviceUUIDs |
15 options:(NSDictionary*)options { | 35 options:(NSDictionary*)options { |
16 _scanForPeripheralsCallCount++; | 36 _scanForPeripheralsCallCount++; |
17 } | 37 } |
18 | 38 |
19 - (void)stopScan { | 39 - (void)stopScan { |
20 _stopScanCallCount++; | 40 _stopScanCallCount++; |
21 } | 41 } |
22 | 42 |
| 43 - (void)connectPeripheral:(CBPeripheral*)peripheral |
| 44 options:(NSDictionary*)options { |
| 45 if (_bluetoothTestMac) { |
| 46 _bluetoothTestMac->OnFakeBluetoothDeviceConnectGattCalled(); |
| 47 } |
| 48 } |
| 49 |
| 50 - (void)cancelPeripheralConnection:(CBPeripheral*)peripheral { |
| 51 if (_bluetoothTestMac) { |
| 52 _bluetoothTestMac->OnFakeBluetoothGattDisconnect(); |
| 53 } |
| 54 } |
| 55 |
23 @end | 56 @end |
OLD | NEW |