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

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

Issue 2071323002: bluetooth: mac: Initial BluetoothRemoteGattCharacteristicMac implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Skip reconnect-during-disconnected-event test Created 4 years, 6 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbservice_mac.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h" 5 #include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "device/bluetooth/test/bluetooth_test.h" 9 #include "device/bluetooth/test/bluetooth_test.h"
10 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h"
10 11
11 using base::mac::ObjCCast; 12 using base::mac::ObjCCast;
12 using base::scoped_nsobject; 13 using base::scoped_nsobject;
13 14
14 @interface MockCBService () { 15 @interface MockCBService () {
16 // Owner of this instance.
17 CBPeripheral* _peripheral;
15 scoped_nsobject<CBUUID> _UUID; 18 scoped_nsobject<CBUUID> _UUID;
16 BOOL _primary; 19 BOOL _primary;
20 scoped_nsobject<NSMutableArray> _characteristics;
17 } 21 }
18 22
19 @end 23 @end
20 24
21 @implementation MockCBService 25 @implementation MockCBService
22 26
23 @synthesize isPrimary = _primary; 27 @synthesize isPrimary = _primary;
24 28
25 - (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary { 29 - (instancetype)initWithPeripheral:(CBPeripheral*)peripheral
30 CBUUID:(CBUUID*)uuid
31 primary:(BOOL)isPrimary {
26 self = [super init]; 32 self = [super init];
27 if (self) { 33 if (self) {
28 _UUID.reset([uuid retain]); 34 _UUID.reset([uuid retain]);
29 _primary = isPrimary; 35 _primary = isPrimary;
36 _peripheral = peripheral;
37 _characteristics.reset([[NSMutableArray alloc] init]);
30 } 38 }
31 return self; 39 return self;
32 } 40 }
33 41
34 - (BOOL)isKindOfClass:(Class)aClass { 42 - (BOOL)isKindOfClass:(Class)aClass {
35 if (aClass == [CBService class] || 43 if (aClass == [CBService class] ||
36 [aClass isSubclassOfClass:[CBService class]]) { 44 [aClass isSubclassOfClass:[CBService class]]) {
37 return YES; 45 return YES;
38 } 46 }
39 return [super isKindOfClass:aClass]; 47 return [super isKindOfClass:aClass];
40 } 48 }
41 49
42 - (BOOL)isMemberOfClass:(Class)aClass { 50 - (BOOL)isMemberOfClass:(Class)aClass {
43 if (aClass == [CBService class] || 51 if (aClass == [CBService class] ||
44 [aClass isSubclassOfClass:[CBService class]]) { 52 [aClass isSubclassOfClass:[CBService class]]) {
45 return YES; 53 return YES;
46 } 54 }
47 return [super isKindOfClass:aClass]; 55 return [super isKindOfClass:aClass];
48 } 56 }
49 57
58 - (CBPeripheral*)peripheral {
59 return _peripheral;
60 }
61
50 - (CBUUID*)UUID { 62 - (CBUUID*)UUID {
51 return _UUID.get(); 63 return _UUID.get();
52 } 64 }
53 65
66 - (void)addCharacteristicWithUUID:(CBUUID*)cb_uuid properties:(int)properties {
67 scoped_nsobject<MockCBCharacteristic> characteristic_mock(
68 [[MockCBCharacteristic alloc] initWithCBUUID:cb_uuid
69 properties:properties]);
70 [_characteristics.get() addObject:characteristic_mock];
71 }
72
73 - (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristic_mock {
74 [_characteristics.get() removeObject:characteristic_mock];
75 }
76
54 - (CBService*)service { 77 - (CBService*)service {
55 return ObjCCast<CBService>(self); 78 return ObjCCast<CBService>(self);
56 } 79 }
57 80
81 - (NSArray*)characteristics {
82 return _characteristics.get();
83 }
84
58 @end 85 @end
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbservice_mac.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698