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

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

Issue 2242833002: Bluetooth: mac: add connected BLE devices at startup Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Device: bluetooth: use untyped containers Created 4 years, 3 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 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 if (BluetoothAdapterMac::IsLowEnergyAvailable()) { 138 if (BluetoothAdapterMac::IsLowEnergyAvailable()) {
139 mock_central_manager_.reset( 139 mock_central_manager_.reset(
140 new ScopedMockCentralManager([[MockCentralManager alloc] init])); 140 new ScopedMockCentralManager([[MockCentralManager alloc] init]));
141 mock_central_manager_->get().bluetoothTestMac = this; 141 mock_central_manager_->get().bluetoothTestMac = this;
142 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn]; 142 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn];
143 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get()); 143 adapter_mac_->SetCentralManagerForTesting((id)mock_central_manager_->get());
144 } 144 }
145 } 145 }
146 146
147 void BluetoothTestMac::InitWithFakeAdapterWithConnectedLowEnergyDevice() {
148 MockCentralManager* mock_central_manager = [[MockCentralManager alloc] init];
149
150 scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
151 initWithUTF8StringIdentifier:kTestPeripheralUUID1.c_str()
152 name:@(kTestDeviceName.c_str())]);
153
154 mock_central_manager.connected_peripherals = @[ mock_peripheral.get() ];
155
156 mock_central_manager_.reset(
157 new ScopedMockCentralManager(mock_central_manager));
158
159 mock_central_manager_->get().bluetoothTestMac = this;
160 [mock_central_manager_->get() setState:CBCentralManagerStatePoweredOn];
161
162 adapter_mac_ =
163 BluetoothAdapterMac::CreateAdapterForTest(
164 kTestAdapterName, kTestAdapterAddress, message_loop_.task_runner(),
165 (id)mock_central_manager_->get())
166 .get();
167 adapter_ = adapter_mac_;
168 }
169
147 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) { 170 BluetoothDevice* BluetoothTestMac::SimulateLowEnergyDevice(int device_ordinal) {
148 TestBluetoothAdapterObserver observer(adapter_); 171 TestBluetoothAdapterObserver observer(adapter_);
149 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_; 172 CBCentralManager* central_manager = adapter_mac_->low_energy_central_manager_;
150 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate = 173 BluetoothLowEnergyCentralManagerDelegate* central_manager_delegate =
151 adapter_mac_->low_energy_central_manager_delegate_; 174 adapter_mac_->low_energy_central_manager_delegate_;
152 175
153 const char* identifier; 176 const char* identifier;
154 NSString* name; 177 NSString* name;
155 NSArray* uuids; 178 NSArray* uuids;
156 NSNumber* rssi; 179 NSNumber* rssi;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 511 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
489 // if (base::HexEncode(raw, sizeof(raw)) == target) { 512 // if (base::HexEncode(raw, sizeof(raw)) == target) {
490 // return input_str; 513 // return input_str;
491 // } 514 // }
492 // ++input[0]; 515 // ++input[0];
493 // } 516 // }
494 // return ""; 517 // return "";
495 // } 518 // }
496 519
497 } // namespace device 520 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/test/bluetooth_test_mac.h ('k') | device/bluetooth/test/mock_bluetooth_central_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698