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

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

Issue 1950033002: bluetooth: mac: Initial BluetoothRemoteGattCharacteristicMac implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@servicescan_cleanup
Patch Set: Updating the characteristic property conversion 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
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 () {
15 scoped_nsobject<CBUUID> _UUID; 16 scoped_nsobject<CBUUID> _UUID;
16 BOOL _primary; 17 BOOL _primary;
18 scoped_nsobject<NSMutableArray> _characteristics;
17 } 19 }
18 20
19 @end 21 @end
20 22
21 @implementation MockCBService 23 @implementation MockCBService
22 24
23 @synthesize isPrimary = _primary; 25 @synthesize isPrimary = _primary;
24 26
25 - (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary { 27 - (instancetype)initWithCBUUID:(CBUUID*)uuid primary:(BOOL)isPrimary {
26 self = [super init]; 28 self = [super init];
27 if (self) { 29 if (self) {
28 _UUID.reset([uuid retain]); 30 _UUID.reset([uuid retain]);
29 _primary = isPrimary; 31 _primary = isPrimary;
32 _characteristics.reset([[NSMutableArray alloc] init]);
30 } 33 }
31 return self; 34 return self;
32 } 35 }
33 36
34 - (BOOL)isKindOfClass:(Class)aClass { 37 - (BOOL)isKindOfClass:(Class)aClass {
35 if (aClass == [CBService class] || 38 if (aClass == [CBService class] ||
36 [aClass isSubclassOfClass:[CBService class]]) { 39 [aClass isSubclassOfClass:[CBService class]]) {
37 return YES; 40 return YES;
38 } 41 }
39 return [super isKindOfClass:aClass]; 42 return [super isKindOfClass:aClass];
40 } 43 }
41 44
42 - (BOOL)isMemberOfClass:(Class)aClass { 45 - (BOOL)isMemberOfClass:(Class)aClass {
43 if (aClass == [CBService class] || 46 if (aClass == [CBService class] ||
44 [aClass isSubclassOfClass:[CBService class]]) { 47 [aClass isSubclassOfClass:[CBService class]]) {
45 return YES; 48 return YES;
46 } 49 }
47 return [super isKindOfClass:aClass]; 50 return [super isKindOfClass:aClass];
48 } 51 }
49 52
50 - (CBUUID*)UUID { 53 - (CBUUID*)UUID {
51 return _UUID.get(); 54 return _UUID.get();
52 } 55 }
53 56
57 - (void)addCharacteristicWithUUID:(CBUUID*)cb_uuid properties:(int)properties {
58 scoped_nsobject<MockCBCharacteristic> characteristic_mock(
59 [[MockCBCharacteristic alloc] initWithCBUUID:cb_uuid
60 properties:properties]);
61 [_characteristics.get() addObject:characteristic_mock];
62 }
63
54 - (CBService*)service { 64 - (CBService*)service {
55 return ObjCCast<CBService>(self); 65 return ObjCCast<CBService>(self);
56 } 66 }
57 67
68 - (NSArray*)characteristics {
69 return _characteristics.get();
70 }
71
58 @end 72 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698