OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_cbperipheral_mac.h" | 5 #include "device/bluetooth/test/mock_bluetooth_cbperipheral_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_mac.h" | 9 #include "device/bluetooth/test/bluetooth_test_mac.h" |
10 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h" | 10 #include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 base::scoped_policy::RETAIN); | 138 base::scoped_policy::RETAIN); |
139 DCHECK(serviceToRemove); | 139 DCHECK(serviceToRemove); |
140 [_services.get() removeObject:serviceToRemove]; | 140 [_services.get() removeObject:serviceToRemove]; |
141 [self didModifyServices:@[ serviceToRemove ]]; | 141 [self didModifyServices:@[ serviceToRemove ]]; |
142 } | 142 } |
143 | 143 |
144 - (void)mockDidDiscoverServices { | 144 - (void)mockDidDiscoverServices { |
145 [_delegate peripheral:self.peripheral didDiscoverServices:nil]; | 145 [_delegate peripheral:self.peripheral didDiscoverServices:nil]; |
146 } | 146 } |
147 | 147 |
| 148 - (void)mockDidDiscoverCharacteristicsForService:(CBService*)service { |
| 149 [_delegate peripheral:self.peripheral |
| 150 didDiscoverCharacteristicsForService:service |
| 151 error:nil]; |
| 152 } |
| 153 |
| 154 - (void)mockDidDiscoverDescriptorsForCharacteristic: |
| 155 (CBCharacteristic*)characteristic { |
| 156 [_delegate peripheral:self.peripheral |
| 157 didDiscoverDescriptorsForCharacteristic:characteristic |
| 158 error:nil]; |
| 159 } |
| 160 |
148 - (void)mockDidDiscoverEvents { | 161 - (void)mockDidDiscoverEvents { |
149 [self mockDidDiscoverServices]; | 162 [self mockDidDiscoverServices]; |
150 // BluetoothLowEnergyDeviceMac is expected to call | 163 // BluetoothLowEnergyDeviceMac is expected to call |
151 // -[CBPeripheral discoverCharacteristics:forService:] for each services, | 164 // -[CBPeripheral discoverCharacteristics:forService:] for each services, |
152 // so -[<CBPeripheralDelegate peripheral:didDiscoverCharacteristicsForService: | 165 // so -[<CBPeripheralDelegate peripheral:didDiscoverCharacteristicsForService: |
153 // error:] needs to be called for all services. | 166 // error:] needs to be called for all services. |
154 for (CBService* service in _services.get()) { | 167 for (CBService* service in _services.get()) { |
155 [_delegate peripheral:self.peripheral | 168 [self mockDidDiscoverCharacteristicsForService:service]; |
156 didDiscoverCharacteristicsForService:service | |
157 error:nil]; | |
158 for (CBCharacteristic* characteristic in service.characteristics) { | 169 for (CBCharacteristic* characteristic in service.characteristics) { |
159 // After discovering services, BluetoothLowEnergyDeviceMac is expected to | 170 // After discovering services, BluetoothLowEnergyDeviceMac is expected to |
160 // discover characteristics for all services. | 171 // discover characteristics for all services. |
161 [_delegate peripheral:self.peripheral | 172 [_delegate peripheral:self.peripheral |
162 didDiscoverDescriptorsForCharacteristic:characteristic | 173 didDiscoverDescriptorsForCharacteristic:characteristic |
163 error:nil]; | 174 error:nil]; |
164 } | 175 } |
165 } | 176 } |
166 } | 177 } |
167 | 178 |
(...skipping 26 matching lines...) Expand all Loading... |
194 return ObjCCast<CBPeripheral>(self); | 205 return ObjCCast<CBPeripheral>(self); |
195 } | 206 } |
196 | 207 |
197 - (void)setNotifyValue:(BOOL)notification | 208 - (void)setNotifyValue:(BOOL)notification |
198 forCharacteristic:(CBCharacteristic*)characteristic { | 209 forCharacteristic:(CBCharacteristic*)characteristic { |
199 _bluetoothTestMac->OnFakeBluetoothGattSetCharacteristicNotification( | 210 _bluetoothTestMac->OnFakeBluetoothGattSetCharacteristicNotification( |
200 notification == YES); | 211 notification == YES); |
201 } | 212 } |
202 | 213 |
203 @end | 214 @end |
OLD | NEW |