| OLD | NEW |
| 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 #include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h" | 10 #include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } // namespace | 89 } // namespace |
| 90 } // device | 90 } // device |
| 91 | 91 |
| 92 @interface MockCBCharacteristic () { | 92 @interface MockCBCharacteristic () { |
| 93 // Owner of this instance. | 93 // Owner of this instance. |
| 94 CBService* _service; | 94 CBService* _service; |
| 95 scoped_nsobject<CBUUID> _UUID; | 95 scoped_nsobject<CBUUID> _UUID; |
| 96 CBCharacteristicProperties _cb_properties; | 96 CBCharacteristicProperties _cb_properties; |
| 97 scoped_nsobject<NSMutableArray> _simulatedDescriptors; | 97 scoped_nsobject<NSMutableArray> _simulatedDescriptors; |
| 98 scoped_nsobject<NSArray> _descriptors; | 98 scoped_nsobject<NSArray> _descriptors; |
| 99 scoped_nsobject<NSData> _value; | 99 scoped_nsobject<NSObject> _value; |
| 100 BOOL _notifying; | 100 BOOL _notifying; |
| 101 } | 101 } |
| 102 @end | 102 @end |
| 103 | 103 |
| 104 @implementation MockCBCharacteristic | 104 @implementation MockCBCharacteristic |
| 105 | 105 |
| 106 - (instancetype)initWithService:(CBService*)service | 106 - (instancetype)initWithService:(CBService*)service |
| 107 CBUUID:(CBUUID*)uuid | 107 CBUUID:(CBUUID*)uuid |
| 108 properties:(int)properties { | 108 properties:(int)properties { |
| 109 self = [super init]; | 109 self = [super init]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 - (BOOL)isMemberOfClass:(Class)aClass { | 129 - (BOOL)isMemberOfClass:(Class)aClass { |
| 130 if (aClass == [CBCharacteristic class] || | 130 if (aClass == [CBCharacteristic class] || |
| 131 [aClass isSubclassOfClass:[CBCharacteristic class]]) { | 131 [aClass isSubclassOfClass:[CBCharacteristic class]]) { |
| 132 return YES; | 132 return YES; |
| 133 } | 133 } |
| 134 return [super isKindOfClass:aClass]; | 134 return [super isKindOfClass:aClass]; |
| 135 } | 135 } |
| 136 | 136 |
| 137 - (void)simulateReadWithValue:(NSData*)value error:(NSError*)error { | 137 - (void)simulateReadWithValue:(id)value error:(NSError*)error { |
| 138 _value.reset([value copy]); | 138 _value.reset([value copy]); |
| 139 CBPeripheral* peripheral = _service.peripheral; | 139 CBPeripheral* peripheral = _service.peripheral; |
| 140 [peripheral.delegate peripheral:peripheral | 140 [peripheral.delegate peripheral:peripheral |
| 141 didUpdateValueForCharacteristic:self.characteristic | 141 didUpdateValueForCharacteristic:self.characteristic |
| 142 error:error]; | 142 error:error]; |
| 143 } | 143 } |
| 144 | 144 |
| 145 - (void)simulateWriteWithError:(NSError*)error { | 145 - (void)simulateWriteWithError:(NSError*)error { |
| 146 CBPeripheral* peripheral = _service.peripheral; | 146 CBPeripheral* peripheral = _service.peripheral; |
| 147 [peripheral.delegate peripheral:peripheral | 147 [peripheral.delegate peripheral:peripheral |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 - (CBCharacteristicProperties)properties { | 215 - (CBCharacteristicProperties)properties { |
| 216 return _cb_properties; | 216 return _cb_properties; |
| 217 } | 217 } |
| 218 | 218 |
| 219 - (NSArray*)descriptors { | 219 - (NSArray*)descriptors { |
| 220 return _descriptors; | 220 return _descriptors; |
| 221 } | 221 } |
| 222 | 222 |
| 223 - (NSData*)value { | 223 - (id)value { |
| 224 return _value.get(); | 224 return _value.get(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 - (BOOL)isNotifying { | 227 - (BOOL)isNotifying { |
| 228 return _notifying; | 228 return _notifying; |
| 229 } | 229 } |
| 230 | 230 |
| 231 @end | 231 @end |
| OLD | NEW |