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/bluetooth_test_mac.h" |
| 6 |
5 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
6 #include "device/bluetooth/bluetooth_adapter_mac.h" | 8 #include "device/bluetooth/bluetooth_adapter_mac.h" |
7 #include "device/bluetooth/test/bluetooth_test_mac.h" | |
8 #include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" | 9 #include "device/bluetooth/test/mock_bluetooth_central_manager_mac.h" |
9 #include "third_party/ocmock/OCMock/OCMock.h" | 10 #include "third_party/ocmock/OCMock/OCMock.h" |
10 | 11 |
11 #if defined(OS_IOS) | 12 #if defined(OS_IOS) |
12 #import <CoreBluetooth/CoreBluetooth.h> | 13 #import <CoreBluetooth/CoreBluetooth.h> |
13 #else // !defined(OS_IOS) | 14 #else // !defined(OS_IOS) |
14 #import <IOBluetooth/IOBluetooth.h> | 15 #import <IOBluetooth/IOBluetooth.h> |
15 #endif // defined(OS_IOS) | 16 #endif // defined(OS_IOS) |
16 | 17 |
17 namespace device { | 18 namespace device { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 CBPeripheral* CreateMockPeripheral(NSString* identifier) { | 22 CBPeripheral* CreateMockPeripheral(NSString* peripheral_identifier) { |
22 Class peripheral_class = NSClassFromString(@"CBPeripheral"); | 23 Class peripheral_class = NSClassFromString(@"CBPeripheral"); |
23 id mock_peripheral = [OCMockObject mockForClass:[peripheral_class class]]; | 24 id mock_peripheral = [OCMockObject mockForClass:[peripheral_class class]]; |
24 [static_cast<CBPeripheral*>( | 25 [[[mock_peripheral stub] andReturnValue:@(CBPeripheralStateDisconnected)] |
25 [[mock_peripheral stub] andReturnValue:@(CBPeripheralStateDisconnected)]) | |
26 performSelector:@selector(state)]; | 26 performSelector:@selector(state)]; |
27 [[[mock_peripheral stub] andReturn:[NSString string]] name]; | |
28 Class uuid_class = NSClassFromString(@"NSUUID"); | 27 Class uuid_class = NSClassFromString(@"NSUUID"); |
29 [[[mock_peripheral stub] | 28 [[[mock_peripheral stub] |
30 andReturn:[[uuid_class performSelector:@selector(UUID)] | 29 andReturn:[[uuid_class performSelector:@selector(UUID)] |
31 performSelector:@selector(initWithUUIDString:) | 30 performSelector:@selector(initWithUUIDString:) |
32 withObject:identifier]] identifier]; | 31 withObject:peripheral_identifier]] |
33 | 32 performSelector:@selector(identifier)]; |
| 33 [[[mock_peripheral stub] |
| 34 andReturn:[NSString stringWithUTF8String:BluetoothTest::kTestDeviceName |
| 35 .c_str()]] name]; |
34 return mock_peripheral; | 36 return mock_peripheral; |
35 } | 37 } |
36 | 38 |
37 NSDictionary* CreateAdvertisementData(NSString* name, NSArray* uuids) { | 39 NSDictionary* CreateAdvertisementData(NSString* name, NSArray* uuids) { |
38 NSMutableDictionary* advertisement_data = | 40 NSMutableDictionary* advertisement_data = |
39 [NSMutableDictionary dictionaryWithDictionary:@{ | 41 [NSMutableDictionary dictionaryWithDictionary:@{ |
40 @"CBAdvertisementDataLocalNameKey" : name, | 42 @"CBAdvertisementDataLocalNameKey" : name, |
41 @"CBAdvertisementDataServiceDataKey" : [NSDictionary dictionary], | 43 @"CBAdvertisementDataServiceDataKey" : [NSDictionary dictionary], |
42 @"CBAdvertisementDataIsConnectable" : @(YES), | 44 @"CBAdvertisementDataIsConnectable" : @(YES), |
43 }]; | 45 }]; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); | 203 // crypto::SHA256HashString(input_str, raw, sizeof(raw)); |
202 // if (base::HexEncode(raw, sizeof(raw)) == target) { | 204 // if (base::HexEncode(raw, sizeof(raw)) == target) { |
203 // return input_str; | 205 // return input_str; |
204 // } | 206 // } |
205 // ++input[0]; | 207 // ++input[0]; |
206 // } | 208 // } |
207 // return ""; | 209 // return ""; |
208 // } | 210 // } |
209 | 211 |
210 } // namespace device | 212 } // namespace device |
OLD | NEW |