Chromium Code Reviews| 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 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ | 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ |
| 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ | 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER _H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "device/bluetooth/bluetooth_adapter_factory.h" | 9 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 10 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 10 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 11 #include "device/bluetooth/test/mock_bluetooth_device.h" | 11 #include "device/bluetooth/test/mock_bluetooth_device.h" |
| 12 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 12 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
| 13 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | 13 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
| 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // Implements fake adapters with named mock data set for use in tests as a | 18 // Implements fake adapters with named mock data set for use in tests as a |
| 19 // result of layout tests calling testRunner.setBluetoothMockDataSet. | 19 // result of layout tests calling testRunner.setBluetoothMockDataSet. |
| 20 | 20 |
| 21 // We have a complete “GenericAccessAdapter”, meaning it has a device which has | 21 // We have a complete “GenericAccessAdapter”, meaning it has a device which has |
| 22 // a Generic Access service with a Device Name characteristic with a descriptor. | 22 // a Generic Access service with a Device Name characteristic with a descriptor. |
| 23 // The other adapters are named based on their particular non-expected behavior. | 23 // The other adapters are named based on their particular non-expected behavior. |
| 24 | 24 |
| 25 // errorUUID note: | |
| 26 // This algorithm consists of replacing the top 32 bits of | |
| 27 // "00000000-97e5-4cd7-b9f1-f5a427670c59" with the bits of the alias. | |
|
Jeffrey Yasskin
2015/07/21 23:08:58
You don't need the "The algorithm consists of" wor
ortuno
2015/07/22 01:06:20
Done.
| |
| 28 // For example, errorUUID(0xDEADBEEF) turns into | |
| 29 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". | |
| 30 | |
| 25 class LayoutTestBluetoothAdapterProvider { | 31 class LayoutTestBluetoothAdapterProvider { |
| 26 public: | 32 public: |
| 27 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. | 33 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. |
| 28 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( | 34 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( |
| 29 const std::string& fake_adapter_name); | 35 const std::string& fake_adapter_name); |
| 30 | 36 |
| 31 private: | 37 private: |
| 32 // Adapters | 38 // Adapters |
| 33 | 39 |
| 34 // |BaseAdapter| | 40 // |BaseAdapter| |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 | 102 |
| 97 // |MissingCharacteristicGenericAccessAdapter| | 103 // |MissingCharacteristicGenericAccessAdapter| |
| 98 // Inherits from EmptyAdapter | 104 // Inherits from EmptyAdapter |
| 99 // Internal Structure: | 105 // Internal Structure: |
| 100 // - GenericAccessDevice | 106 // - GenericAccessDevice |
| 101 // - GenericAccess UUID (0x1800) | 107 // - GenericAccess UUID (0x1800) |
| 102 // - GenericAccessService | 108 // - GenericAccessService |
| 103 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 109 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 104 GetMissingCharacteristicGenericAccessAdapter(); | 110 GetMissingCharacteristicGenericAccessAdapter(); |
| 105 | 111 |
| 112 // |FailingConnectionsAdapter| | |
| 113 // Inherits from BaseAdapter | |
| 114 // FailingConnectionsAdapter holds a device for each type of connection error | |
| 115 // that can occur. This way we don’t need to create an adapter for each type | |
| 116 // of error. Each of the devices has a different UUID so that they can be | |
|
Jeffrey Yasskin
2015/07/21 23:08:58
"has a service with a different UUID"
ortuno
2015/07/22 01:06:20
Done.
| |
| 117 // accessed by using different filters. | |
| 118 // See errorUUID note at the top for errorUUID() explanation. | |
| 119 // Internal Structure: | |
| 120 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) | |
|
Jeffrey Yasskin
2015/07/21 23:08:58
This set of error codes isn't going to generalize
Jeffrey Yasskin
2015/07/21 23:09:33
@scheib, thoughts?
scheib
2015/07/22 00:15:58
In thinking over this, I agree, these tests have v
ortuno
2015/07/22 01:06:20
I think we are removing connection_errors. I will
| |
| 121 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) | |
| 122 // - UnconnectableDevice(BluetoothDevice::ERROR_FAILED) errorUUID(0x2) | |
| 123 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_FAILED) errorUUID(0x3) | |
| 124 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_CANCELED) errorUUID(0x4) | |
| 125 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_REJECTED) errorUUID(0x5) | |
| 126 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_TIMEOUT) errorUUID(0x6) | |
| 127 // - UnconnectableDevice(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE) | |
| 128 // errorUUID(0x7) | |
| 129 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
| 130 GetFailingConnectionsAdapter(); | |
| 131 | |
| 106 // Discovery Sessions | 132 // Discovery Sessions |
| 107 | 133 |
| 108 // |DiscoverySession| | 134 // |DiscoverySession| |
| 109 // Mock Functions: | 135 // Mock Functions: |
| 110 // - Stop: | 136 // - Stop: |
| 111 // Run success callback. | 137 // Run success callback. |
| 112 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | 138 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> |
| 113 GetDiscoverySession(); | 139 GetDiscoverySession(); |
| 114 | 140 |
| 115 // Devices | 141 // Devices |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 // None. | 218 // None. |
| 193 // Mock Functions: | 219 // Mock Functions: |
| 194 // - CreateGattConnection: | 220 // - CreateGattConnection: |
| 195 // - Run success callback with BaseGATTConnection | 221 // - Run success callback with BaseGATTConnection |
| 196 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 222 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 197 GetConnectableDeviceNew( | 223 GetConnectableDeviceNew( |
| 198 device::MockBluetoothAdapter* adapter, | 224 device::MockBluetoothAdapter* adapter, |
| 199 const std::string& device_name = "Connectable Device", | 225 const std::string& device_name = "Connectable Device", |
| 200 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); | 226 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); |
| 201 | 227 |
| 228 // |UnconnectableDevice| | |
| 229 // Inherits from BaseDevice(adapter, device_name) | |
| 230 // Adv UUIDs Added: | |
| 231 // - uuid | |
|
Jeffrey Yasskin
2015/07/21 23:08:58
'uuid' isn't one of the arguments.
ortuno
2015/07/22 01:06:20
Done.
| |
| 232 // Services Added: | |
| 233 // None. | |
| 234 // Mock Functions: | |
| 235 // - CreateGATTConnection: | |
| 236 // - Run error callback with error_type | |
| 237 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | |
| 238 GetUnconnectableDevice( | |
| 239 device::MockBluetoothAdapter* adapter, | |
| 240 device::BluetoothDevice::ConnectErrorCode error_code, | |
| 241 const std::string& device_name = "Unconnectable Device"); | |
| 242 | |
| 202 // |GenericAccessDevice| | 243 // |GenericAccessDevice| |
| 203 // Inherits from ConnectableDevice(adapter, device_name) | 244 // Inherits from ConnectableDevice(adapter, device_name) |
| 204 // Adv UUIDs Added: | 245 // Adv UUIDs Added: |
| 205 // - Generic Access UUID (0x1800) | 246 // - Generic Access UUID (0x1800) |
| 206 // Services Added: | 247 // Services Added: |
| 207 // None. Each user of the GenericAccessDevice is in charge of adding the | 248 // None. Each user of the GenericAccessDevice is in charge of adding the |
| 208 // relevant services, characteristics, and descriptors. | 249 // relevant services, characteristics, and descriptors. |
| 209 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 250 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 210 GetGenericAccessDevice( | 251 GetGenericAccessDevice( |
| 211 device::MockBluetoothAdapter* adapter, | 252 device::MockBluetoothAdapter* adapter, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 // - |GetService| returns |service|. | 348 // - |GetService| returns |service|. |
| 308 // - |IsNotifying| returns false. | 349 // - |IsNotifying| returns false. |
| 309 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 350 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
| 310 GetGattCharacteristic(device::MockBluetoothGattService* service, | 351 GetGattCharacteristic(device::MockBluetoothGattService* service, |
| 311 const std::string& uuid); | 352 const std::string& uuid); |
| 312 }; | 353 }; |
| 313 | 354 |
| 314 } // namespace content | 355 } // namespace content |
| 315 | 356 |
| 316 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ | 357 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ |
| OLD | NEW |