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

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

Issue 2028823003: Mac: Make ScopedTypeRef require explicit constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dependency 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
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 23 matching lines...) Expand all
34 MockCentralManager* get() { return mock_central_manager_.get(); }; 34 MockCentralManager* get() { return mock_central_manager_.get(); };
35 35
36 private: 36 private:
37 scoped_nsobject<MockCentralManager> mock_central_manager_; 37 scoped_nsobject<MockCentralManager> mock_central_manager_;
38 38
39 DISALLOW_COPY_AND_ASSIGN(ScopedMockCentralManager); 39 DISALLOW_COPY_AND_ASSIGN(ScopedMockCentralManager);
40 }; 40 };
41 41
42 namespace { 42 namespace {
43 43
44 NSDictionary* CreateAdvertisementData(NSString* name, NSArray* uuids) { 44 scoped_nsobject<NSDictionary> CreateAdvertisementData(NSString* name,
45 NSMutableDictionary* advertisement_data = 45 NSArray* uuids) {
46 NSMutableDictionary* advertisement_data(
46 [NSMutableDictionary dictionaryWithDictionary:@{ 47 [NSMutableDictionary dictionaryWithDictionary:@{
47 CBAdvertisementDataLocalNameKey : name, 48 CBAdvertisementDataLocalNameKey : name,
48 CBAdvertisementDataServiceDataKey : @{}, 49 CBAdvertisementDataServiceDataKey : @{},
49 CBAdvertisementDataIsConnectable : @(YES), 50 CBAdvertisementDataIsConnectable : @(YES),
50 }]; 51 }]);
51 if (uuids) { 52 if (uuids) {
52 [advertisement_data setObject:uuids 53 [advertisement_data setObject:uuids
53 forKey:CBAdvertisementDataServiceUUIDsKey]; 54 forKey:CBAdvertisementDataServiceUUIDsKey];
54 } 55 }
55 return [advertisement_data retain]; 56 return scoped_nsobject<NSDictionary>(advertisement_data,
57 base::scoped_policy::RETAIN);
56 } 58 }
57 59
58 } // namespace 60 } // namespace
59 61
60 // UUID1 hashes to kTestDeviceAddress1, and UUID2 to kTestDeviceAddress2. 62 // UUID1 hashes to kTestDeviceAddress1, and UUID2 to kTestDeviceAddress2.
61 const std::string BluetoothTestMac::kTestPeripheralUUID1 = 63 const std::string BluetoothTestMac::kTestPeripheralUUID1 =
62 "34045B00-0000-0000-0000-000000000000"; 64 "34045B00-0000-0000-0000-000000000000";
63 const std::string BluetoothTestMac::kTestPeripheralUUID2 = 65 const std::string BluetoothTestMac::kTestPeripheralUUID2 =
64 "EC1B8F00-0000-0000-0000-000000000000"; 66 "EC1B8F00-0000-0000-0000-000000000000";
65 67
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 error:nil]; 224 error:nil];
223 } 225 }
224 226
225 void BluetoothTestMac::SimulateGattServicesDiscovered( 227 void BluetoothTestMac::SimulateGattServicesDiscovered(
226 BluetoothDevice* device, 228 BluetoothDevice* device,
227 const std::vector<std::string>& uuids) { 229 const std::vector<std::string>& uuids) {
228 BluetoothLowEnergyDeviceMac* device_mac = 230 BluetoothLowEnergyDeviceMac* device_mac =
229 static_cast<BluetoothLowEnergyDeviceMac*>(device); 231 static_cast<BluetoothLowEnergyDeviceMac*>(device);
230 CBPeripheral* peripheral = device_mac->GetPeripheral(); 232 CBPeripheral* peripheral = device_mac->GetPeripheral();
231 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral); 233 MockCBPeripheral* peripheral_mock = ObjCCast<MockCBPeripheral>(peripheral);
232 scoped_nsobject<NSMutableArray> services = [[NSMutableArray alloc] init]; 234 scoped_nsobject<NSMutableArray> services([[NSMutableArray alloc] init]);
233 for (auto uuid : uuids) { 235 for (auto uuid : uuids) {
234 CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())]; 236 CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
235 [services addObject:cb_service_uuid]; 237 [services addObject:cb_service_uuid];
236 } 238 }
237 [peripheral_mock addServices:services]; 239 [peripheral_mock addServices:services];
238 [peripheral_mock didDiscoverServicesWithError:nil]; 240 [peripheral_mock didDiscoverServicesWithError:nil];
239 } 241 }
240 242
241 void BluetoothTestMac::SimulateGattServiceRemoved( 243 void BluetoothTestMac::SimulateGattServiceRemoved(
242 BluetoothRemoteGattService* service) { 244 BluetoothRemoteGattService* service) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); 296 // crypto::SHA256HashString(input_str, raw, sizeof(raw));
295 // if (base::HexEncode(raw, sizeof(raw)) == target) { 297 // if (base::HexEncode(raw, sizeof(raw)) == target) {
296 // return input_str; 298 // return input_str;
297 // } 299 // }
298 // ++input[0]; 300 // ++input[0];
299 // } 301 // }
300 // return ""; 302 // return "";
301 // } 303 // }
302 304
303 } // namespace device 305 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698