| OLD | NEW |
| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 - (BOOL)isMemberOfClass:(Class)aClass { | 42 - (BOOL)isMemberOfClass:(Class)aClass { |
| 43 if (aClass == [CBDescriptor class] || | 43 if (aClass == [CBDescriptor class] || |
| 44 [aClass isSubclassOfClass:[CBDescriptor class]]) { | 44 [aClass isSubclassOfClass:[CBDescriptor class]]) { |
| 45 return YES; | 45 return YES; |
| 46 } | 46 } |
| 47 return [super isKindOfClass:aClass]; | 47 return [super isKindOfClass:aClass]; |
| 48 } | 48 } |
| 49 | 49 |
| 50 - (CBUUID*)UUID { | 50 - (CBUUID*)UUID { |
| 51 return _UUID.get(); | 51 return _UUID; |
| 52 } | 52 } |
| 53 | 53 |
| 54 - (NSData*)value { | 54 - (NSData*)value { |
| 55 return _value.get(); | 55 return _value; |
| 56 } | 56 } |
| 57 | 57 |
| 58 - (CBDescriptor*)descriptor { | 58 - (CBDescriptor*)descriptor { |
| 59 return ObjCCast<CBDescriptor>(self); | 59 return ObjCCast<CBDescriptor>(self); |
| 60 } | 60 } |
| 61 | 61 |
| 62 - (CBCharacteristic*)characteristic { | 62 - (CBCharacteristic*)characteristic { |
| 63 return _characteristic; | 63 return _characteristic; |
| 64 } | 64 } |
| 65 | 65 |
| 66 - (void)simulateReadWithValue:(id)value error:(NSError*)error { | 66 - (void)simulateReadWithValue:(id)value error:(NSError*)error { |
| 67 _value.reset([value copy]); | 67 _value.reset([value copy]); |
| 68 CBPeripheral* peripheral = _characteristic.service.peripheral; | 68 CBPeripheral* peripheral = _characteristic.service.peripheral; |
| 69 [peripheral.delegate peripheral:peripheral | 69 [peripheral.delegate peripheral:peripheral |
| 70 didUpdateValueForDescriptor:self.descriptor | 70 didUpdateValueForDescriptor:self.descriptor |
| 71 error:error]; | 71 error:error]; |
| 72 } | 72 } |
| 73 | 73 |
| 74 - (void)simulateWriteWithError:(NSError*)error { | 74 - (void)simulateWriteWithError:(NSError*)error { |
| 75 CBPeripheral* peripheral = _characteristic.service.peripheral; | 75 CBPeripheral* peripheral = _characteristic.service.peripheral; |
| 76 [peripheral.delegate peripheral:peripheral | 76 [peripheral.delegate peripheral:peripheral |
| 77 didWriteValueForDescriptor:self.descriptor | 77 didWriteValueForDescriptor:self.descriptor |
| 78 error:error]; | 78 error:error]; |
| 79 } | 79 } |
| 80 | 80 |
| 81 @end | 81 @end |
| OLD | NEW |