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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // - Generic Access Device | 145 // - Generic Access Device |
145 // - Generic Access UUID (0x1800) | 146 // - Generic Access UUID (0x1800) |
146 // - Generic Access Service | 147 // - Generic Access Service |
147 // - Device Name Characteristic: | 148 // - Device Name Characteristic: |
148 // - Mock Functions: | 149 // - Mock Functions: |
149 // - Read: Calls success callback with device's name. | 150 // - Read: Calls success callback with device's name. |
150 // - Write: Calls success callback. | 151 // - Write: Calls success callback. |
151 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 152 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
152 GetGenericAccessAdapter(); | 153 GetGenericAccessAdapter(); |
153 | 154 |
| 155 // |HeartRateAdapter| |
| 156 // Inherits from |EmptyAdapter| |
| 157 // Internal Structure: |
| 158 // - Heart Rate Device |
| 159 // - Generic Access UUID (0x1800) |
| 160 // - Heart Rate UUID (0x180D) |
| 161 // - Heart Rate Service |
| 162 // - Heart Rate Measurement Characteristic: |
| 163 // - Mock Functions: |
| 164 // - StartNotifySession: Calls success callback with a |
| 165 // BaseGATTNotifySession(characteristic_instance_id) |
| 166 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 167 GetHeartRateAdapter(); |
| 168 |
154 // |FailingConnectionsAdapter| | 169 // |FailingConnectionsAdapter| |
155 // Inherits from |EmptyAdapter| | 170 // Inherits from |EmptyAdapter| |
156 // FailingConnectionsAdapter holds a device for each type of connection error | 171 // FailingConnectionsAdapter holds a device for each type of connection error |
157 // that can occur. This way we don’t need to create an adapter for each type | 172 // that can occur. This way we don’t need to create an adapter for each type |
158 // of error. Each of the devices has a service with a different UUID so that | 173 // of error. Each of the devices has a service with a different UUID so that |
159 // they can be accessed by using different filters. | 174 // they can be accessed by using different filters. |
160 // See errorUUID() declaration below. | 175 // See errorUUID() declaration below. |
161 // Internal Structure: | 176 // Internal Structure: |
162 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) | 177 // - UnconnectableDevice(BluetoothDevice::ERROR_UNKNOWN) errorUUID(0x0) |
163 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) | 178 // - UnconnectableDevice(BluetoothDevice::ERROR_INPROGRESS) errorUUID(0x1) |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // "00:00:00:00:00:03") | 297 // "00:00:00:00:00:03") |
283 // Adv UUIDs added: | 298 // Adv UUIDs added: |
284 // - Generic Access (0x1800) | 299 // - Generic Access (0x1800) |
285 // - Heart Rate UUID (0x180D) | 300 // - Heart Rate UUID (0x180D) |
286 // Services added: | 301 // Services added: |
287 // None. | 302 // None. |
288 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 303 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
289 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); | 304 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); |
290 | 305 |
291 // |ConnectableDevice| | 306 // |ConnectableDevice| |
292 // Inherits from |BaseDevice|(adapter, device_name) | 307 // Inherits from |BaseDevice|(adapter, device_name, uuids, address) |
293 // Adv UUIDs added: | 308 // Adv UUIDs added: |
294 // None. | 309 // None. |
295 // Services added: | 310 // Services added: |
296 // None. | 311 // None. |
297 // Mock Functions: | 312 // Mock Functions: |
298 // - CreateGattConnection: | 313 // - CreateGattConnection: |
299 // - Run success callback with BaseGATTConnection | 314 // - Run success callback with BaseGATTConnection |
300 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 315 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
301 GetConnectableDevice( | 316 GetConnectableDevice( |
302 device::MockBluetoothAdapter* adapter, | 317 device::MockBluetoothAdapter* adapter, |
303 const std::string& device_name = "Connectable Device", | 318 const std::string& device_name = "Connectable Device", |
304 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList()); | 319 device::BluetoothDevice::UUIDList = device::BluetoothDevice::UUIDList(), |
| 320 const std::string& address = "00:00:00:00:00:00"); |
305 | 321 |
306 // |UnconnectableDevice| | 322 // |UnconnectableDevice| |
307 // Inherits from |BaseDevice|(adapter, device_name) | 323 // Inherits from |BaseDevice|(adapter, device_name) |
308 // Adv UUIDs added: | 324 // Adv UUIDs added: |
309 // - errorUUID(error_code) | 325 // - errorUUID(error_code) |
310 // Services added: | 326 // Services added: |
311 // None. | 327 // None. |
312 // Mock Functions: | 328 // Mock Functions: |
313 // - CreateGATTConnection: | 329 // - CreateGATTConnection: |
314 // - Run error callback with error_type | 330 // - Run error callback with error_type |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // - GetService: | 391 // - GetService: |
376 // Returns: service | 392 // Returns: service |
377 // - GetProperties: | 393 // - GetProperties: |
378 // Returns: NULL | 394 // Returns: NULL |
379 // - GetPermissions: | 395 // - GetPermissions: |
380 // Returns: NULL | 396 // Returns: NULL |
381 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 397 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
382 GetBaseGATTCharacteristic(device::MockBluetoothGattService* service, | 398 GetBaseGATTCharacteristic(device::MockBluetoothGattService* service, |
383 const std::string& uuid); | 399 const std::string& uuid); |
384 | 400 |
| 401 // Notify Sessions |
| 402 |
| 403 // |BaseGATTNotifySession|(characteristic_identifier) |
| 404 // Mock Functions: |
| 405 // - GetCharacteristicIdentifier: |
| 406 // Returns: characteristic_identifier |
| 407 // - IsActive: |
| 408 // Returns: true |
| 409 // - Stop: |
| 410 // Run callback. |
| 411 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattNotifySession>> |
| 412 GetBaseGATTNotifySession(const std::string& characteristic_identifier); |
| 413 |
385 // |ErrorCharacteristic|(service, error_type) | 414 // |ErrorCharacteristic|(service, error_type) |
386 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) | 415 // Inherits from BaseCharacteristic(service, errorUUID(error_type + 0xA1)) |
387 // Descriptors added: | 416 // Descriptors added: |
388 // None. | 417 // None. |
389 // Mock Functions: | 418 // Mock Functions: |
390 // - ReadRemoteCharacteristic: | 419 // - ReadRemoteCharacteristic: |
391 // Run error callback with error_type | 420 // Run error callback with error_type |
392 // - WriteRemoteCharacteristic: | 421 // - WriteRemoteCharacteristic: |
393 // Run error callback with error_type | 422 // Run error callback with error_type |
| 423 // - StartNotifySession: |
| 424 // Run error callback with error_type |
394 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 425 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
395 GetErrorCharacteristic( | 426 GetErrorCharacteristic( |
396 device::MockBluetoothGattService* service, | 427 device::MockBluetoothGattService* service, |
397 device::BluetoothGattService::GattErrorCode error_code); | 428 device::BluetoothGattService::GattErrorCode error_code); |
398 | 429 |
399 // Helper functions: | 430 // Helper functions: |
400 | 431 |
401 // errorUUID(alias) returns a UUID with the top 32 bits of | 432 // errorUUID(alias) returns a UUID with the top 32 bits of |
402 // "00000000-97e5-4cd7-b9f1-f5a427670c59" replaced with the bits of |alias|. | 433 // "00000000-97e5-4cd7-b9f1-f5a427670c59" replaced with the bits of |alias|. |
403 // For example, errorUUID(0xDEADBEEF) returns | 434 // For example, errorUUID(0xDEADBEEF) returns |
404 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". The bottom 96 bits of error UUIDs | 435 // "deadbeef-97e5-4cd7-b9f1-f5a427670c59". The bottom 96 bits of error UUIDs |
405 // were generated as a type 4 (random) UUID. | 436 // were generated as a type 4 (random) UUID. |
406 static std::string errorUUID(uint32_t alias); | 437 static std::string errorUUID(uint32_t alias); |
407 | 438 |
408 // Function to turn an integer into an MAC address of the form | 439 // Function to turn an integer into an MAC address of the form |
409 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) | 440 // XX:XX:XX:XX:XX:XX. For example makeMACAddress(0xdeadbeef) |
410 // returns "00:00:DE:AD:BE:EF". | 441 // returns "00:00:DE:AD:BE:EF". |
411 static std::string makeMACAddress(uint64_t addr); | 442 static std::string makeMACAddress(uint64_t addr); |
412 }; | 443 }; |
413 | 444 |
414 } // namespace content | 445 } // namespace content |
415 | 446 |
416 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 447 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
OLD | NEW |