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

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

Issue 2094633003: Bluetooth: Mac: implementation for start notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@write_read_characteristicscan_servicescan_cleanup
Patch Set: Addressing msarda's comments Created 4 years, 5 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_cbcharacteristic_mac.h" 5 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_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
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 } // namespace 88 } // namespace
89 } // device 89 } // device
90 90
91 @interface MockCBCharacteristic () { 91 @interface MockCBCharacteristic () {
92 // Owner of this instance. 92 // Owner of this instance.
93 CBService* _service; 93 CBService* _service;
94 scoped_nsobject<CBUUID> _UUID; 94 scoped_nsobject<CBUUID> _UUID;
95 CBCharacteristicProperties _cb_properties; 95 CBCharacteristicProperties _cb_properties;
96 base::scoped_nsobject<NSData> _value; 96 base::scoped_nsobject<NSData> _value;
97 BOOL _notifying;
97 } 98 }
98 @end 99 @end
99 100
100 @implementation MockCBCharacteristic 101 @implementation MockCBCharacteristic
101 102
102 - (instancetype)initWithService:(CBService*)service 103 - (instancetype)initWithService:(CBService*)service
103 CBUUID:(CBUUID*)uuid 104 CBUUID:(CBUUID*)uuid
104 properties:(int)properties { 105 properties:(int)properties {
105 self = [super init]; 106 self = [super init];
106 if (self) { 107 if (self) {
(...skipping 30 matching lines...) Expand all
137 error:error]; 138 error:error];
138 } 139 }
139 140
140 - (void)simulateWriteWithError:(NSError*)error { 141 - (void)simulateWriteWithError:(NSError*)error {
141 CBPeripheral* peripheral = _service.peripheral; 142 CBPeripheral* peripheral = _service.peripheral;
142 [peripheral.delegate peripheral:peripheral 143 [peripheral.delegate peripheral:peripheral
143 didWriteValueForCharacteristic:self.characteristic 144 didWriteValueForCharacteristic:self.characteristic
144 error:error]; 145 error:error];
145 } 146 }
146 147
148 - (void)simulateGattNotifySessionStarted {
149 _notifying = YES;
150 CBPeripheral* peripheral = _service.peripheral;
151 [peripheral.delegate peripheral:peripheral
152 didUpdateNotificationStateForCharacteristic:self.characteristic
153 error:nil];
154 }
155
156 - (void)simulateGattNotifySessionFailedWithError:(NSError*)error {
157 CBPeripheral* peripheral = _service.peripheral;
158 [peripheral.delegate peripheral:peripheral
159 didUpdateNotificationStateForCharacteristic:self.characteristic
160 error:error];
161 }
162
163 - (void)simulateGattCharacteristicChangedWithValue:(NSData*)value {
164 _value.reset([value copy]);
165 CBPeripheral* peripheral = _service.peripheral;
166 [peripheral.delegate peripheral:peripheral
167 didUpdateValueForCharacteristic:self.characteristic
168 error:nil];
169 }
170
147 - (CBUUID*)UUID { 171 - (CBUUID*)UUID {
148 return _UUID.get(); 172 return _UUID.get();
149 } 173 }
150 174
151 - (CBCharacteristic*)characteristic { 175 - (CBCharacteristic*)characteristic {
152 return ObjCCast<CBCharacteristic>(self); 176 return ObjCCast<CBCharacteristic>(self);
153 } 177 }
154 178
155 - (CBService*)service { 179 - (CBService*)service {
156 return _service; 180 return _service;
157 } 181 }
158 182
159 - (CBCharacteristicProperties)properties { 183 - (CBCharacteristicProperties)properties {
160 return _cb_properties; 184 return _cb_properties;
161 } 185 }
162 186
163 - (NSData*)value { 187 - (NSData*)value {
164 return _value.get(); 188 return _value.get();
165 } 189 }
166 190
191 - (BOOL)isNotifying {
192 return _notifying;
193 }
194
167 @end 195 @end
OLDNEW
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_cbcharacteristic_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