| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // |MissingCharacteristicGenericAccessAdapter| | 97 // |MissingCharacteristicGenericAccessAdapter| |
| 98 // Inherits from EmptyAdapter | 98 // Inherits from EmptyAdapter |
| 99 // Internal Structure: | 99 // Internal Structure: |
| 100 // - GenericAccessDevice | 100 // - GenericAccessDevice |
| 101 // - GenericAccess UUID (0x1800) | 101 // - GenericAccess UUID (0x1800) |
| 102 // - GenericAccessService | 102 // - GenericAccessService |
| 103 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 103 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 104 GetMissingCharacteristicGenericAccessAdapter(); | 104 GetMissingCharacteristicGenericAccessAdapter(); |
| 105 | 105 |
| 106 // |FailingConnectionsAdapter| |
| 107 // Inherits from BaseAdapter |
| 108 // FailingConnectionsAdapter holds a device for each type of connection error |
| 109 // that can occur. This way we don’t need to create an adapter for each type |
| 110 // of error. Each of the devices has a service with a different UUID so that |
| 111 // they can be accessed by using different filters. |
| 112 // See errorUUID() declaration below. |
| 113 // Internal Structure: |
| 114 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) |
| 115 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) |
| 116 // - UnconnectableDevice(BluetoothDevice::ERROR_FAILED) errorUUID(0x2) |
| 117 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_FAILED) errorUUID(0x3) |
| 118 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_CANCELED) errorUUID(0x4) |
| 119 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_REJECTED) errorUUID(0x5) |
| 120 // - UnconnectableDevice(BluetoothDevice::ERROR_AUTH_TIMEOUT) errorUUID(0x6) |
| 121 // - UnconnectableDevice(BluetoothDevice::ERROR_UNSUPPORTED_DEVICE) |
| 122 // errorUUID(0x7) |
| 123 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 124 GetFailingConnectionsAdapter(); |
| 125 |
| 106 // Discovery Sessions | 126 // Discovery Sessions |
| 107 | 127 |
| 108 // |DiscoverySession| | 128 // |DiscoverySession| |
| 109 // Mock Functions: | 129 // Mock Functions: |
| 110 // - Stop: | 130 // - Stop: |
| 111 // Run success callback. | 131 // Run success callback. |
| 112 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | 132 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> |
| 113 GetDiscoverySession(); | 133 GetDiscoverySession(); |
| 114 | 134 |
| 115 // Devices | 135 // Devices |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // None. | 212 // None. |
| 193 // Mock Functions: | 213 // Mock Functions: |
| 194 // - CreateGattConnection: | 214 // - CreateGattConnection: |
| 195 // - Run success callback with BaseGATTConnection | 215 // - Run success callback with BaseGATTConnection |
| 196 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 216 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 197 GetConnectableDeviceNew( | 217 GetConnectableDeviceNew( |
| 198 device::MockBluetoothAdapter* adapter, | 218 device::MockBluetoothAdapter* adapter, |
| 199 const std::string& device_name = "Connectable Device", | 219 const std::string& device_name = "Connectable Device", |
| 200 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); | 220 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); |
| 201 | 221 |
| 222 // |UnconnectableDevice| |
| 223 // Inherits from BaseDevice(adapter, device_name) |
| 224 // Adv UUIDs Added: |
| 225 // - errorUUID(error_code) |
| 226 // Services Added: |
| 227 // None. |
| 228 // Mock Functions: |
| 229 // - CreateGATTConnection: |
| 230 // - Run error callback with error_type |
| 231 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 232 GetUnconnectableDevice( |
| 233 device::MockBluetoothAdapter* adapter, |
| 234 device::BluetoothDevice::ConnectErrorCode error_code, |
| 235 const std::string& device_name = "Unconnectable Device"); |
| 236 |
| 202 // |GenericAccessDevice| | 237 // |GenericAccessDevice| |
| 203 // Inherits from ConnectableDevice(adapter, device_name) | 238 // Inherits from ConnectableDevice(adapter, device_name) |
| 204 // Adv UUIDs Added: | 239 // Adv UUIDs Added: |
| 205 // - Generic Access UUID (0x1800) | 240 // - Generic Access UUID (0x1800) |
| 206 // Services Added: | 241 // Services Added: |
| 207 // None. Each user of the GenericAccessDevice is in charge of adding the | 242 // None. Each user of the GenericAccessDevice is in charge of adding the |
| 208 // relevant services, characteristics, and descriptors. | 243 // relevant services, characteristics, and descriptors. |
| 209 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 244 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 210 GetGenericAccessDevice( | 245 GetGenericAccessDevice( |
| 211 device::MockBluetoothAdapter* adapter, | 246 device::MockBluetoothAdapter* adapter, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 229 // - IsLocal: | 264 // - IsLocal: |
| 230 // Returns: false | 265 // Returns: false |
| 231 // - IsPrimary: | 266 // - IsPrimary: |
| 232 // Returns: true | 267 // Returns: true |
| 233 // - GetDevice: | 268 // - GetDevice: |
| 234 // Returns: device | 269 // Returns: device |
| 235 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 270 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 236 GetBaseGATTService(device::MockBluetoothDevice* device, | 271 GetBaseGATTService(device::MockBluetoothDevice* device, |
| 237 const std::string& uuid); | 272 const std::string& uuid); |
| 238 | 273 |
| 274 // Helper functions: |
| 275 |
| 276 // errorUUID(alias) returns a UUID with the top 32 bits of |
| 277 // "00000000-97e5-4cd7-b9f1-f5a427670c59" replaced with the bits of |alias|. |
| 278 // For example, errorUUID(0xDEADBEEF) returns |
| 279 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". The bottom 96 bits of error UUIDs |
| 280 // were generated as a type 4 (random) UUID. |
| 281 static std::string errorUUID(uint32_t alias); |
| 282 |
| 283 // Function to turn an integer into an MAC address of the form |
| 284 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) |
| 285 // returns "00:00:DE:AD:BE:EF". |
| 286 static std::string makeMACAddress(uint64_t addr); |
| 287 |
| 239 // The functions after this haven't been updated to the new design yet. | 288 // The functions after this haven't been updated to the new design yet. |
| 240 | 289 |
| 241 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following | 290 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following |
| 242 // characteristics: | 291 // characteristics: |
| 243 // - |StartDiscoverySessionWithFilter| runs the success callback with | 292 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 244 // |DiscoverySession| | 293 // |DiscoverySession| |
| 245 // as argument. | 294 // as argument. |
| 246 // - |GetDevices| returns a list with an |EmptyDevice|. | 295 // - |GetDevices| returns a list with an |EmptyDevice|. |
| 247 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 296 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 248 GetSingleEmptyDeviceAdapter(); | 297 GetSingleEmptyDeviceAdapter(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 // - |GetService| returns |service|. | 356 // - |GetService| returns |service|. |
| 308 // - |IsNotifying| returns false. | 357 // - |IsNotifying| returns false. |
| 309 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 358 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
| 310 GetGattCharacteristic(device::MockBluetoothGattService* service, | 359 GetGattCharacteristic(device::MockBluetoothGattService* service, |
| 311 const std::string& uuid); | 360 const std::string& uuid); |
| 312 }; | 361 }; |
| 313 | 362 |
| 314 } // namespace content | 363 } // namespace content |
| 315 | 364 |
| 316 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 365 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
| OLD | NEW |