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 "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h" | 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 if (fake_adapter_name == "GlucoseHeartRateAdapter") | 153 if (fake_adapter_name == "GlucoseHeartRateAdapter") |
154 return GetGlucoseHeartRateAdapter(); | 154 return GetGlucoseHeartRateAdapter(); |
155 if (fake_adapter_name == "UnicodeDeviceAdapter") | 155 if (fake_adapter_name == "UnicodeDeviceAdapter") |
156 return GetUnicodeDeviceAdapter(); | 156 return GetUnicodeDeviceAdapter(); |
157 if (fake_adapter_name == "MissingServiceHeartRateAdapter") | 157 if (fake_adapter_name == "MissingServiceHeartRateAdapter") |
158 return GetMissingServiceHeartRateAdapter(); | 158 return GetMissingServiceHeartRateAdapter(); |
159 if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter") | 159 if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter") |
160 return GetMissingCharacteristicHeartRateAdapter(); | 160 return GetMissingCharacteristicHeartRateAdapter(); |
161 if (fake_adapter_name == "HeartRateAdapter") | 161 if (fake_adapter_name == "HeartRateAdapter") |
162 return GetHeartRateAdapter(); | 162 return GetHeartRateAdapter(); |
163 if (fake_adapter_name == "UnnamedHeartRateAdapter") | |
164 return GetUnnamedHeartRateAdapter(); | |
163 if (fake_adapter_name == "TwoHeartRateServicesAdapter") | 165 if (fake_adapter_name == "TwoHeartRateServicesAdapter") |
164 return GetTwoHeartRateServicesAdapter(); | 166 return GetTwoHeartRateServicesAdapter(); |
165 if (fake_adapter_name == "DisconnectingHeartRateAdapter") | 167 if (fake_adapter_name == "DisconnectingHeartRateAdapter") |
166 return GetDisconnectingHeartRateAdapter(); | 168 return GetDisconnectingHeartRateAdapter(); |
167 if (fake_adapter_name == "BlacklistTestAdapter") | 169 if (fake_adapter_name == "BlacklistTestAdapter") |
168 return GetBlacklistTestAdapter(); | 170 return GetBlacklistTestAdapter(); |
169 if (fake_adapter_name == "FailingConnectionsAdapter") | 171 if (fake_adapter_name == "FailingConnectionsAdapter") |
170 return GetFailingConnectionsAdapter(); | 172 return GetFailingConnectionsAdapter(); |
171 if (fake_adapter_name == "FailingGATTOperationsAdapter") | 173 if (fake_adapter_name == "FailingGATTOperationsAdapter") |
172 return GetFailingGATTOperationsAdapter(); | 174 return GetFailingGATTOperationsAdapter(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 device->AddMockService(GetGenericAccessService(device.get())); | 435 device->AddMockService(GetGenericAccessService(device.get())); |
434 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); | 436 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); |
435 | 437 |
436 adapter->AddMockDevice(std::move(device)); | 438 adapter->AddMockDevice(std::move(device)); |
437 | 439 |
438 return adapter; | 440 return adapter; |
439 } | 441 } |
440 | 442 |
441 // static | 443 // static |
442 scoped_refptr<NiceMockBluetoothAdapter> | 444 scoped_refptr<NiceMockBluetoothAdapter> |
445 LayoutTestBluetoothAdapterProvider::GetUnnamedHeartRateAdapter() { | |
446 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); | |
447 std::unique_ptr<NiceMockBluetoothDevice> device( | |
448 GetHeartRateDevice(adapter.get(), "")); | |
ortuno
2016/07/21 17:42:29
Well this is not really an Unnamed device is more
scheib
2016/07/30 02:38:14
Done - created unnamed and empty named versions.
| |
449 | |
450 // TODO(ortuno): Implement the rest of the service's characteristics | |
451 // See: http://crbug.com/529975 | |
452 | |
453 device->AddMockService(GetGenericAccessService(device.get())); | |
454 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); | |
455 | |
456 adapter->AddMockDevice(std::move(device)); | |
457 | |
458 return adapter; | |
459 } | |
460 | |
461 // static | |
462 scoped_refptr<NiceMockBluetoothAdapter> | |
443 LayoutTestBluetoothAdapterProvider::GetTwoHeartRateServicesAdapter() { | 463 LayoutTestBluetoothAdapterProvider::GetTwoHeartRateServicesAdapter() { |
444 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); | 464 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); |
445 std::unique_ptr<NiceMockBluetoothDevice> device( | 465 std::unique_ptr<NiceMockBluetoothDevice> device( |
446 GetHeartRateDevice(adapter.get())); | 466 GetHeartRateDevice(adapter.get())); |
447 | 467 |
448 device->AddMockService(GetGenericAccessService(device.get())); | 468 device->AddMockService(GetGenericAccessService(device.get())); |
449 | 469 |
450 // First Heart Rate Service has one Heart Rate Measurement characteristic | 470 // First Heart Rate Service has one Heart Rate Measurement characteristic |
451 // and one Body Sensor Location characteristic. | 471 // and one Body Sensor Location characteristic. |
452 std::unique_ptr<NiceMockBluetoothGattService> first_heart_rate( | 472 std::unique_ptr<NiceMockBluetoothGattService> first_heart_rate( |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 | 733 |
714 ON_CALL(*device, CreateGattConnection(_, _)) | 734 ON_CALL(*device, CreateGattConnection(_, _)) |
715 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); | 735 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); |
716 | 736 |
717 return device; | 737 return device; |
718 } | 738 } |
719 | 739 |
720 // static | 740 // static |
721 std::unique_ptr<NiceMockBluetoothDevice> | 741 std::unique_ptr<NiceMockBluetoothDevice> |
722 LayoutTestBluetoothAdapterProvider::GetHeartRateDevice( | 742 LayoutTestBluetoothAdapterProvider::GetHeartRateDevice( |
723 MockBluetoothAdapter* adapter) { | 743 MockBluetoothAdapter* adapter, |
744 const std::string& device_name) { | |
724 BluetoothDevice::UUIDList uuids; | 745 BluetoothDevice::UUIDList uuids; |
725 uuids.push_back(BluetoothUUID(kGenericAccessServiceUUID)); | 746 uuids.push_back(BluetoothUUID(kGenericAccessServiceUUID)); |
726 uuids.push_back(BluetoothUUID(kHeartRateServiceUUID)); | 747 uuids.push_back(BluetoothUUID(kHeartRateServiceUUID)); |
727 | 748 |
728 return GetConnectableDevice(adapter, "Heart Rate Device", uuids); | 749 return GetConnectableDevice(adapter, device_name, uuids); |
729 } | 750 } |
730 | 751 |
731 // Services | 752 // Services |
732 | 753 |
733 // static | 754 // static |
734 std::unique_ptr<NiceMockBluetoothGattService> | 755 std::unique_ptr<NiceMockBluetoothGattService> |
735 LayoutTestBluetoothAdapterProvider::GetBaseGATTService( | 756 LayoutTestBluetoothAdapterProvider::GetBaseGATTService( |
736 const std::string& identifier, | 757 const std::string& identifier, |
737 MockBluetoothDevice* device, | 758 MockBluetoothDevice* device, |
738 const std::string& uuid) { | 759 const std::string& uuid) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 return BluetoothUUID(); | 1094 return BluetoothUUID(); |
1074 } | 1095 } |
1075 | 1096 |
1076 // static | 1097 // static |
1077 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { | 1098 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { |
1078 return BluetoothDevice::CanonicalizeAddress( | 1099 return BluetoothDevice::CanonicalizeAddress( |
1079 base::StringPrintf("%012" PRIx64, addr)); | 1100 base::StringPrintf("%012" PRIx64, addr)); |
1080 } | 1101 } |
1081 | 1102 |
1082 } // namespace content | 1103 } // namespace content |
OLD | NEW |