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/test/mock_bluetooth_adapter.h" | 9 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
10 #include "device/bluetooth/test/mock_bluetooth_device.h" | 10 #include "device/bluetooth/test/mock_bluetooth_device.h" |
11 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" | 11 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h" |
12 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | 12 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
| 13 #include "device/bluetooth/test/mock_bluetooth_gatt_notify_session.h" |
13 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 // 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 |
18 // result of layout tests calling testRunner.setBluetoothMockDataSet. | 19 // result of layout tests calling testRunner.setBluetoothMockDataSet. |
19 | 20 |
20 // 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 |
21 // 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. |
22 // 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. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // - Generic Access Device | 154 // - Generic Access Device |
154 // - Generic Access UUID (0x1800) | 155 // - Generic Access UUID (0x1800) |
155 // - Generic Access Service | 156 // - Generic Access Service |
156 // - Device Name Characteristic: | 157 // - Device Name Characteristic: |
157 // - Mock Functions: | 158 // - Mock Functions: |
158 // - Read: Calls success callback with device's name. | 159 // - Read: Calls success callback with device's name. |
159 // - Write: Calls success callback. | 160 // - Write: Calls success callback. |
160 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 161 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
161 GetGenericAccessAdapter(); | 162 GetGenericAccessAdapter(); |
162 | 163 |
| 164 // |HeartRateAdapter| |
| 165 // Inherits from |EmptyAdapter| |
| 166 // Internal Structure: |
| 167 // - Heart Rate Device |
| 168 // - Generic Access UUID (0x1800) |
| 169 // - Heart Rate UUID (0x180D) |
| 170 // - Heart Rate Service |
| 171 // - Heart Rate Measurement Characteristic: |
| 172 // - Mock Functions: |
| 173 // - StartNotifySession: Calls success callback with a |
| 174 // BaseGATTNotifySession(characteristic_instance_id) |
| 175 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 176 GetHeartRateAdapter(); |
| 177 |
163 // |FailingConnectionsAdapter| | 178 // |FailingConnectionsAdapter| |
164 // Inherits from |EmptyAdapter| | 179 // Inherits from |EmptyAdapter| |
165 // FailingConnectionsAdapter holds a device for each type of connection error | 180 // FailingConnectionsAdapter holds a device for each type of connection error |
166 // that can occur. This way we don’t need to create an adapter for each type | 181 // that can occur. This way we don’t need to create an adapter for each type |
167 // of error. Each of the devices has a service with a different UUID so that | 182 // of error. Each of the devices has a service with a different UUID so that |
168 // they can be accessed by using different filters. | 183 // they can be accessed by using different filters. |
169 // See errorUUID() declaration below. | 184 // See errorUUID() declaration below. |
170 // Internal Structure: | 185 // Internal Structure: |
171 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) | 186 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) |
172 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) | 187 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // "00:00:00:00:00:02") | 295 // "00:00:00:00:00:02") |
281 // Adv UUIDs added: | 296 // Adv UUIDs added: |
282 // - Generic Access (0x1800) | 297 // - Generic Access (0x1800) |
283 // - Glucose UUID (0x1808) | 298 // - Glucose UUID (0x1808) |
284 // Services added: | 299 // Services added: |
285 // None. | 300 // None. |
286 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 301 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
287 GetGlucoseDevice(device::MockBluetoothAdapter* adapter); | 302 GetGlucoseDevice(device::MockBluetoothAdapter* adapter); |
288 | 303 |
289 // |HeartRateDevice| | 304 // |HeartRateDevice| |
290 // Inherits from |BaseDevice|(adapter, "Heart Rate Device", uuids, | 305 // Inherits from |ConnectableDevice|(adapter, "Heart Rate Device", uuids, |
291 // "00:00:00:00:00:03") | 306 // "00:00:00:00:00:03") |
292 // Adv UUIDs added: | 307 // Adv UUIDs added: |
293 // - Generic Access (0x1800) | 308 // - Generic Access (0x1800) |
294 // - Heart Rate UUID (0x180D) | 309 // - Heart Rate UUID (0x180D) |
295 // Services added: | 310 // Services added: |
296 // None. | 311 // None. |
297 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 312 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
298 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); | 313 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); |
299 | 314 |
300 // |ConnectableDevice| | 315 // |ConnectableDevice| |
301 // Inherits from |BaseDevice|(adapter, device_name) | 316 // Inherits from |BaseDevice|(adapter, device_name) |
302 // Adv UUIDs added: | 317 // Adv UUIDs added: |
303 // None. | 318 // None. |
304 // Services added: | 319 // Services added: |
305 // None. | 320 // None. |
306 // Mock Functions: | 321 // Mock Functions: |
307 // - CreateGattConnection: | 322 // - CreateGattConnection: |
308 // - Run success callback with BaseGATTConnection | 323 // - Run success callback with BaseGATTConnection |
309 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 324 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
310 GetConnectableDevice( | 325 GetConnectableDevice( |
311 device::MockBluetoothAdapter* adapter, | 326 device::MockBluetoothAdapter* adapter, |
312 const std::string& device_name = "Connectable Device", | 327 const std::string& device_name = "Connectable Device", |
313 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); | 328 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList(), |
| 329 const std::string& address = "00:00:00:00:00:00"); |
314 | 330 |
315 // |UnconnectableDevice| | 331 // |UnconnectableDevice| |
316 // Inherits from |BaseDevice|(adapter, device_name) | 332 // Inherits from |BaseDevice|(adapter, device_name) |
317 // Adv UUIDs added: | 333 // Adv UUIDs added: |
318 // - errorUUID(error_code) | 334 // - errorUUID(error_code) |
319 // Services added: | 335 // Services added: |
320 // None. | 336 // None. |
321 // Mock Functions: | 337 // Mock Functions: |
322 // - CreateGATTConnection: | 338 // - CreateGATTConnection: |
323 // - Run error callback with error_type | 339 // - Run error callback with error_type |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 409 |
394 // |ErrorCharacteristic|(service, error_type) | 410 // |ErrorCharacteristic|(service, error_type) |
395 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) | 411 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) |
396 // Descriptors added: | 412 // Descriptors added: |
397 // None. | 413 // None. |
398 // Mock Functions: | 414 // Mock Functions: |
399 // - ReadRemoteCharacteristic: | 415 // - ReadRemoteCharacteristic: |
400 // Run error callback with error_type | 416 // Run error callback with error_type |
401 // - WriteRemoteCharacteristic: | 417 // - WriteRemoteCharacteristic: |
402 // Run error callback with error_type | 418 // Run error callback with error_type |
| 419 // - StartNotifySession: |
| 420 // Run error callback with error_type |
403 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 421 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
404 GetErrorCharacteristic( | 422 GetErrorCharacteristic( |
405 device::MockBluetoothGattService* service, | 423 device::MockBluetoothGattService* service, |
406 device::BluetoothGattService::GattErrorCode error_code); | 424 device::BluetoothGattService::GattErrorCode error_code); |
407 | 425 |
| 426 // Notify Sessions |
| 427 |
| 428 // |BaseGATTNotifySession|(characteristic_identifier) |
| 429 // Mock Functions: |
| 430 // - GetCharacteristicIdentifier: |
| 431 // Returns: characteristic_identifier |
| 432 // - IsActive: |
| 433 // Returns: true |
| 434 // - Stop: |
| 435 // Run callback. |
| 436 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattNotifySession>> |
| 437 GetBaseGATTNotifySession(const std::string& characteristic_identifier); |
| 438 |
408 // Helper functions: | 439 // Helper functions: |
409 | 440 |
410 // errorUUID(alias) returns a UUID with the top 32 bits of | 441 // errorUUID(alias) returns a UUID with the top 32 bits of |
411 // "00000000-97e5-4cd7-b9f1-f5a427670c59" replaced with the bits of |alias|. | 442 // "00000000-97e5-4cd7-b9f1-f5a427670c59" replaced with the bits of |alias|. |
412 // For example, errorUUID(0xDEADBEEF) returns | 443 // For example, errorUUID(0xDEADBEEF) returns |
413 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". The bottom 96 bits of error UUIDs | 444 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". The bottom 96 bits of error UUIDs |
414 // were generated as a type 4 (random) UUID. | 445 // were generated as a type 4 (random) UUID. |
415 static std::string errorUUID(uint32_t alias); | 446 static std::string errorUUID(uint32_t alias); |
416 | 447 |
417 // Function to turn an integer into an MAC address of the form | 448 // Function to turn an integer into an MAC address of the form |
418 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) | 449 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) |
419 // returns "00:00:DE:AD:BE:EF". | 450 // returns "00:00:DE:AD:BE:EF". |
420 static std::string makeMACAddress(uint64_t addr); | 451 static std::string makeMACAddress(uint64_t addr); |
421 }; | 452 }; |
422 | 453 |
423 } // namespace content | 454 } // namespace content |
424 | 455 |
425 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 456 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
OLD | NEW |