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

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

Issue 2767813002: Bluetooth: macOS: Implementing read/write for descriptors (Closed)
Patch Set: . Created 3 years, 8 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_cbdescriptor_mac.h" 5 #include "device/bluetooth/test/mock_bluetooth_cbdescriptor_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/bluetooth_gatt_characteristic.h" 9 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
10 10
11 using base::mac::ObjCCast; 11 using base::mac::ObjCCast;
12 using base::scoped_nsobject; 12 using base::scoped_nsobject;
13 13
14 @interface MockCBDescriptor () { 14 @interface MockCBDescriptor () {
15 // Owner of this instance. 15 // Owner of this instance.
16 CBCharacteristic* _characteristic; 16 CBCharacteristic* _characteristic;
17 scoped_nsobject<CBUUID> _UUID; 17 scoped_nsobject<CBUUID> _UUID;
18 scoped_nsobject<NSData> _value;
18 } 19 }
19 @end 20 @end
20 21
21 @implementation MockCBDescriptor 22 @implementation MockCBDescriptor
22 23
23 - (instancetype)initWithCharacteristic:(CBCharacteristic*)characteristic 24 - (instancetype)initWithCharacteristic:(CBCharacteristic*)characteristic
24 CBUUID:(CBUUID*)uuid { 25 CBUUID:(CBUUID*)uuid {
25 self = [super init]; 26 self = [super init];
26 if (self) { 27 if (self) {
27 _characteristic = characteristic; 28 _characteristic = characteristic;
(...skipping 15 matching lines...) Expand all
43 [aClass isSubclassOfClass:[CBDescriptor class]]) { 44 [aClass isSubclassOfClass:[CBDescriptor class]]) {
44 return YES; 45 return YES;
45 } 46 }
46 return [super isKindOfClass:aClass]; 47 return [super isKindOfClass:aClass];
47 } 48 }
48 49
49 - (CBUUID*)UUID { 50 - (CBUUID*)UUID {
50 return _UUID.get(); 51 return _UUID.get();
51 } 52 }
52 53
54 - (NSData*)value {
55 return _value.get();
56 }
57
53 - (CBDescriptor*)descriptor { 58 - (CBDescriptor*)descriptor {
54 return ObjCCast<CBDescriptor>(self); 59 return ObjCCast<CBDescriptor>(self);
55 } 60 }
56 61
57 - (CBCharacteristic*)characteristic { 62 - (CBCharacteristic*)characteristic {
58 return _characteristic; 63 return _characteristic;
59 } 64 }
60 65
66 - (void)simulateReadWithValue:(id)value error:(NSError*)error {
67 _value.reset([value copy]);
68 CBPeripheral* peripheral = _characteristic.service.peripheral;
69 [peripheral.delegate peripheral:peripheral
70 didUpdateValueForDescriptor:self.descriptor
71 error:error];
72 }
73
74 - (void)simulateWriteWithError:(NSError*)error {
75 CBPeripheral* peripheral = _characteristic.service.peripheral;
76 [peripheral.delegate peripheral:peripheral
77 didWriteValueForDescriptor:self.descriptor
78 error:error];
79 }
80
61 @end 81 @end
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h ('k') | device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698