summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
blob: fbb0dff41e75d315a5044a6e61dde508fe7382fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"

#import "device/bluetooth/test/bluetooth_test_mac.h"
#import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"

@implementation MockCentralManager

@synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount;
@synthesize stopScanCallCount = _stopScanCallCount;
@synthesize delegate = _delegate;
@synthesize state = _state;
@synthesize bluetoothTestMac = _bluetoothTestMac;

- (BOOL)isKindOfClass:(Class)aClass {
  if (aClass == [CBCentralManager class] ||
      [aClass isSubclassOfClass:[CBCentralManager class]]) {
    return YES;
  }
  return [super isKindOfClass:aClass];
}

- (BOOL)isMemberOfClass:(Class)aClass {
  if (aClass == [CBCentralManager class] ||
      [aClass isSubclassOfClass:[CBCentralManager class]]) {
    return YES;
  }
  return [super isKindOfClass:aClass];
}

- (void)scanForPeripheralsWithServices:(NSArray*)serviceUUIDs
                               options:(NSDictionary*)options {
  _scanForPeripheralsCallCount++;
}

- (void)stopScan {
  _stopScanCallCount++;
}

- (void)connectPeripheral:(CBPeripheral*)peripheral
                  options:(NSDictionary*)options {
  if (_bluetoothTestMac) {
    _bluetoothTestMac->OnFakeBluetoothDeviceConnectGattCalled();
  }
}

- (void)cancelPeripheralConnection:(CBPeripheral*)peripheral {
  if (_bluetoothTestMac) {
    _bluetoothTestMac->OnFakeBluetoothGattDisconnect();
  }
}

@end