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

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

Issue 2026193002: Preparing for characteristics discovery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot one variable Created 4 years, 6 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
« no previous file with comments | « no previous file | device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bluetooth_test_mac.h" 5 #include "device/bluetooth/test/bluetooth_test_mac.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 BluetoothDeviceMac::GetNSErrorFromConnectErrorCode(errorCode); 206 BluetoothDeviceMac::GetNSErrorFromConnectErrorCode(errorCode);
207 [centralManager.delegate centralManager:centralManager 207 [centralManager.delegate centralManager:centralManager
208 didFailToConnectPeripheral:peripheral 208 didFailToConnectPeripheral:peripheral
209 error:error]; 209 error:error];
210 } 210 }
211 211
212 void BluetoothTestMac::SimulateGattDisconnection(BluetoothDevice* device) { 212 void BluetoothTestMac::SimulateGattDisconnection(BluetoothDevice* device) {
213 BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac = 213 BluetoothLowEnergyDeviceMac* lowEnergyDeviceMac =
214 static_cast<BluetoothLowEnergyDeviceMac*>(device); 214 static_cast<BluetoothLowEnergyDeviceMac*>(device);
215 CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral(); 215 CBPeripheral* peripheral = lowEnergyDeviceMac->GetPeripheral();
216 MockCBPeripheral* mockPeripheral = (MockCBPeripheral*)peripheral; 216 MockCBPeripheral* peripheral_mock = (MockCBPeripheral*)peripheral;
217 [mockPeripheral setState:CBPeripheralStateDisconnected]; 217 [peripheral_mock setState:CBPeripheralStateDisconnected];
218 CBCentralManager* centralManager = 218 CBCentralManager* central_manager =
219 ObjCCast<CBCentralManager>(mock_central_manager_->get()); 219 ObjCCast<CBCentralManager>(mock_central_manager_->get());
220 [centralManager.delegate centralManager:centralManager 220 [central_manager.delegate centralManager:central_manager
221 didDisconnectPeripheral:peripheral 221 didDisconnectPeripheral:peripheral
222 error:nil]; 222 error:nil];
223 [peripheral_mock removeAllServices];
ortuno 2016/06/01 04:11:49 Does this actually happen on real devices?
223 } 224 }
224 225
225 void BluetoothTestMac::SimulateGattServicesDiscovered( 226 void BluetoothTestMac::SimulateGattServicesDiscovered(
226 BluetoothDevice* device, 227 BluetoothDevice* device,
227 const std::vector<std::string>& uuids) { 228 const std::vector<std::string>& uuids) {
228 BluetoothLowEnergyDeviceMac* device_mac = 229 BluetoothLowEnergyDeviceMac* device_mac =
229 static_cast<BluetoothLowEnergyDeviceMac*>(device); 230 static_cast<BluetoothLowEnergyDeviceMac*>(device);
230 CBPeripheral* peripheral = device_mac->GetPeripheral(); 231 CBPeripheral* peripheral = device_mac->GetPeripheral();
231 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral); 232 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral);
232 scoped_nsobject<NSMutableArray> services = [[NSMutableArray alloc] init]; 233 scoped_nsobject<NSMutableArray> services = [[NSMutableArray alloc] init];
233 for (auto uuid : uuids) { 234 for (auto uuid : uuids) {
234 CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())]; 235 CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
235 [services addObject:cb_service_uuid]; 236 [services addObject:cb_service_uuid];
236 } 237 }
237 [peripheral_mock removeAllServices];
238 [peripheral_mock addServices:services]; 238 [peripheral_mock addServices:services];
239 [peripheral_mock didDiscoverWithError:nil]; 239 [peripheral_mock didDiscoverServicesWithError:nil];
240 } 240 }
241 241
242 void BluetoothTestMac::SimulateGattServiceRemoved( 242 void BluetoothTestMac::SimulateGattServiceRemoved(
243 BluetoothRemoteGattService* service) { 243 BluetoothRemoteGattService* service) {
244 BluetoothUUID bluetooth_service_uuid = service->GetUUID(); 244 BluetoothUUID bluetooth_service_uuid = service->GetUUID();
245 std::string service_uuid_string = bluetooth_service_uuid.canonical_value(); 245 std::string service_uuid_string = bluetooth_service_uuid.canonical_value();
246 BluetoothRemoteGattServiceMac* mac_gatt_service = 246 BluetoothRemoteGattServiceMac* mac_gatt_service =
247 static_cast<BluetoothRemoteGattServiceMac*>(service); 247 static_cast<BluetoothRemoteGattServiceMac*>(service);
248 BluetoothDevice* device = service->GetDevice(); 248 BluetoothDevice* device = service->GetDevice();
249 BluetoothLowEnergyDeviceMac* device_mac = 249 BluetoothLowEnergyDeviceMac* device_mac =
250 static_cast<BluetoothLowEnergyDeviceMac*>(device); 250 static_cast<BluetoothLowEnergyDeviceMac*>(device);
251 CBPeripheral* peripheral = device_mac->GetPeripheral(); 251 CBPeripheral* peripheral = device_mac->GetPeripheral();
252 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral); 252 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral);
253 [peripheral_mock removeService:mac_gatt_service->GetService()]; 253 [peripheral_mock removeService:mac_gatt_service->GetService()];
254 [peripheral_mock didDiscoverWithError:nil]; 254 [peripheral_mock didDiscoverServicesWithError:nil];
255 } 255 }
256 256
257 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() { 257 void BluetoothTestMac::OnFakeBluetoothDeviceConnectGattCalled() {
258 gatt_connection_attempts_++; 258 gatt_connection_attempts_++;
259 } 259 }
260 260
261 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() { 261 void BluetoothTestMac::OnFakeBluetoothGattDisconnect() {
262 gatt_disconnection_attempts_++; 262 gatt_disconnection_attempts_++;
263 } 263 }
264 264
(...skipping 30 matching lines...) Expand all
295 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 295 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
296 // if (base::HexEncode(raw, sizeof(raw)) == target) { 296 // if (base::HexEncode(raw, sizeof(raw)) == target) {
297 // return input_str; 297 // return input_str;
298 // } 298 // }
299 // ++input[0]; 299 // ++input[0];
300 // } 300 // }
301 // return ""; 301 // return "";
302 // } 302 // }
303 303
304 } // namespace device 304 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698