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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 NiceMockBluetoothGattService; | 57 NiceMockBluetoothGattService; |
58 typedef testing::NiceMock<MockBluetoothGattNotifySession> | 58 typedef testing::NiceMock<MockBluetoothGattNotifySession> |
59 NiceMockBluetoothGattNotifySession; | 59 NiceMockBluetoothGattNotifySession; |
60 | 60 |
61 namespace { | 61 namespace { |
62 // Bluetooth UUIDs suitable to pass to BluetoothUUID(). | 62 // Bluetooth UUIDs suitable to pass to BluetoothUUID(). |
63 const char kBatteryServiceUUID[] = "180f"; | 63 const char kBatteryServiceUUID[] = "180f"; |
64 const char kGenericAccessServiceUUID[] = "1800"; | 64 const char kGenericAccessServiceUUID[] = "1800"; |
65 const char kGlucoseServiceUUID[] = "1808"; | 65 const char kGlucoseServiceUUID[] = "1808"; |
66 const char kHeartRateServiceUUID[] = "180d"; | 66 const char kHeartRateServiceUUID[] = "180d"; |
| 67 const char kHumanInterfaceDeviceServiceUUID[] = "1812"; |
67 const char kTxPowerServiceUUID[] = "1804"; | 68 const char kTxPowerServiceUUID[] = "1804"; |
68 const char kHeartRateMeasurementUUID[] = "2a37"; | 69 const char kHeartRateMeasurementUUID[] = "2a37"; |
69 const char kBodySensorLocation[] = "2a38"; | 70 const char kBodySensorLocation[] = "2a38"; |
70 const char kDeviceNameUUID[] = "2a00"; | 71 const char kDeviceNameUUID[] = "2a00"; |
71 | 72 |
72 const int kDefaultTxPower = -10; // TxPower of a device broadcasting at 0.1mW. | 73 const int kDefaultTxPower = -10; // TxPower of a device broadcasting at 0.1mW. |
73 const int kDefaultRssi = -51; // RSSI at 1m from a device broadcasting at | 74 const int kDefaultRssi = -51; // RSSI at 1m from a device broadcasting at |
74 // 0.1mW. | 75 // 0.1mW. |
75 | 76 |
76 // Invokes Run() on the k-th argument of the function with no arguments. | 77 // Invokes Run() on the k-th argument of the function with no arguments. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (fake_adapter_name == "GlucoseHeartRateAdapter") | 145 if (fake_adapter_name == "GlucoseHeartRateAdapter") |
145 return GetGlucoseHeartRateAdapter(); | 146 return GetGlucoseHeartRateAdapter(); |
146 if (fake_adapter_name == "UnicodeDeviceAdapter") | 147 if (fake_adapter_name == "UnicodeDeviceAdapter") |
147 return GetUnicodeDeviceAdapter(); | 148 return GetUnicodeDeviceAdapter(); |
148 if (fake_adapter_name == "MissingServiceHeartRateAdapter") | 149 if (fake_adapter_name == "MissingServiceHeartRateAdapter") |
149 return GetMissingServiceHeartRateAdapter(); | 150 return GetMissingServiceHeartRateAdapter(); |
150 if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter") | 151 if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter") |
151 return GetMissingCharacteristicHeartRateAdapter(); | 152 return GetMissingCharacteristicHeartRateAdapter(); |
152 if (fake_adapter_name == "HeartRateAdapter") | 153 if (fake_adapter_name == "HeartRateAdapter") |
153 return GetHeartRateAdapter(); | 154 return GetHeartRateAdapter(); |
| 155 if (fake_adapter_name == "HeartRateAndHIDAdapter") |
| 156 return GetHeartRateAndHIDAdapter(); |
154 if (fake_adapter_name == "FailingConnectionsAdapter") | 157 if (fake_adapter_name == "FailingConnectionsAdapter") |
155 return GetFailingConnectionsAdapter(); | 158 return GetFailingConnectionsAdapter(); |
156 if (fake_adapter_name == "FailingGATTOperationsAdapter") | 159 if (fake_adapter_name == "FailingGATTOperationsAdapter") |
157 return GetFailingGATTOperationsAdapter(); | 160 return GetFailingGATTOperationsAdapter(); |
158 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") | 161 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") |
159 return GetSecondDiscoveryFindsHeartRateAdapter(); | 162 return GetSecondDiscoveryFindsHeartRateAdapter(); |
160 if (fake_adapter_name == "DelayedServicesDiscoveryAdapter") | 163 if (fake_adapter_name == "DelayedServicesDiscoveryAdapter") |
161 return GetDelayedServicesDiscoveryAdapter(); | 164 return GetDelayedServicesDiscoveryAdapter(); |
162 if (fake_adapter_name.empty()) | 165 if (fake_adapter_name.empty()) |
163 return nullptr; | 166 return nullptr; |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 482 |
480 device->AddMockService(GetGenericAccessService(adapter.get(), device.get())); | 483 device->AddMockService(GetGenericAccessService(adapter.get(), device.get())); |
481 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); | 484 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); |
482 adapter->AddMockDevice(std::move(device)); | 485 adapter->AddMockDevice(std::move(device)); |
483 | 486 |
484 return adapter; | 487 return adapter; |
485 } | 488 } |
486 | 489 |
487 // static | 490 // static |
488 scoped_refptr<NiceMockBluetoothAdapter> | 491 scoped_refptr<NiceMockBluetoothAdapter> |
| 492 LayoutTestBluetoothAdapterProvider::GetHeartRateAndHIDAdapter() { |
| 493 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); |
| 494 |
| 495 BluetoothDevice::UUIDList uuids; |
| 496 uuids.push_back(BluetoothUUID(kHeartRateServiceUUID)); |
| 497 uuids.push_back(BluetoothUUID(kHumanInterfaceDeviceServiceUUID)); |
| 498 |
| 499 scoped_ptr<NiceMockBluetoothDevice> device( |
| 500 GetConnectableDevice(adapter.get(), "Heart Rate And HID Device", uuids)); |
| 501 |
| 502 device->AddMockService(GetGenericAccessService(adapter.get(), device.get())); |
| 503 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); |
| 504 device->AddMockService( |
| 505 GetBaseGATTService(device.get(), kHumanInterfaceDeviceServiceUUID)); |
| 506 adapter->AddMockDevice(std::move(device)); |
| 507 |
| 508 return adapter; |
| 509 } |
| 510 |
| 511 // static |
| 512 scoped_refptr<NiceMockBluetoothAdapter> |
489 LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() { | 513 LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() { |
490 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); | 514 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); |
491 | 515 |
492 for (int error = 0; error < BluetoothDevice::NUM_CONNECT_ERROR_CODES; | 516 for (int error = 0; error < BluetoothDevice::NUM_CONNECT_ERROR_CODES; |
493 error++) { | 517 error++) { |
494 adapter->AddMockDevice(GetUnconnectableDevice( | 518 adapter->AddMockDevice(GetUnconnectableDevice( |
495 adapter.get(), static_cast<BluetoothDevice::ConnectErrorCode>(error))); | 519 adapter.get(), static_cast<BluetoothDevice::ConnectErrorCode>(error))); |
496 } | 520 } |
497 | 521 |
498 return adapter; | 522 return adapter; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 return BluetoothUUID(); | 901 return BluetoothUUID(); |
878 } | 902 } |
879 | 903 |
880 // static | 904 // static |
881 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { | 905 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { |
882 return BluetoothDevice::CanonicalizeAddress( | 906 return BluetoothDevice::CanonicalizeAddress( |
883 base::StringPrintf("%012" PRIx64, addr)); | 907 base::StringPrintf("%012" PRIx64, addr)); |
884 } | 908 } |
885 | 909 |
886 } // namespace content | 910 } // namespace content |
OLD | NEW |