| 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 class LayoutTestBluetoothAdapterProvider { | 20 class LayoutTestBluetoothAdapterProvider { |
| 21 public: | 21 public: |
| 22 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. | 22 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. |
| 23 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( | 23 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( |
| 24 const std::string& fake_adapter_name); | 24 const std::string& fake_adapter_name); |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 // Returns "EmptyAdapter" fake BluetoothAdapter with the following | 27 // Returns "EmptyAdapter" fake BluetoothAdapter with the following |
| 28 // characteristics: | 28 // characteristics: |
| 29 // - |StartDiscoverySession| runs the first argument with |DiscoverySession| | 29 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 30 // |DiscoverySession| |
| 30 // as argument. | 31 // as argument. |
| 31 // - |GetDevices| returns an empty list of devices. | 32 // - |GetDevices| returns an empty list of devices. |
| 32 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 33 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 33 GetEmptyAdapter(); | 34 GetEmptyAdapter(); |
| 34 | 35 |
| 36 // Returns a fake BluetoothAdapter that asserts that its |
| 37 // StartDiscoverySessionWithFilter() method is called with a filter consisting |
| 38 // of the standard battery, heart rate, and glucose services. |
| 39 // - |StartDiscoverySessionWithFilter(correct arguments)| runs the success |
| 40 // callback with |DiscoverySession| as the argument. With incorrect |
| 41 // arguments, it runs the failure callback. |
| 42 // - |GetDevices| returns a device with a Battery service. |
| 43 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 44 GetScanFilterCheckingAdapter(); |
| 45 |
| 35 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following | 46 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following |
| 36 // characteristics: | 47 // characteristics: |
| 37 // - |StartDiscoverySession| runs the first argument with |DiscoverySession| | 48 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 49 // |DiscoverySession| |
| 38 // as argument. | 50 // as argument. |
| 39 // - |GetDevices| returns a list with an |EmptyDevice|. | 51 // - |GetDevices| returns a list with an |EmptyDevice|. |
| 40 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 52 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 41 GetSingleEmptyDeviceAdapter(); | 53 GetSingleEmptyDeviceAdapter(); |
| 42 | 54 |
| 55 // Returns "MultiDeviceAdapter", a fake BluetoothAdapter with the following |
| 56 // characteristics: |
| 57 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 58 // |DiscoverySession| |
| 59 // as argument. |
| 60 // - |GetDevices| returns a list with 2 devices: |
| 61 // - GetUUIDs() returns a Heart Rate Service, |
| 62 // and GetName() returns "Heart Rate Device". |
| 63 // - GetUUIDs() returns a Glucose Service, |
| 64 // and GetName() returns "Glucose Device". |
| 65 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 66 GetMultiDeviceAdapter(); |
| 67 |
| 43 // Returns "ConnectableDeviceAdapter" fake BluetoothAdapter with the | 68 // Returns "ConnectableDeviceAdapter" fake BluetoothAdapter with the |
| 44 // following characteristics: | 69 // following characteristics: |
| 45 // - |StartDiscoverySession| runs the first argument with |DiscoverySession| | 70 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 71 // |DiscoverySession| |
| 46 // as argument. | 72 // as argument. |
| 47 // - |GetDevices| returns a list with a |ConnectableDevice|. | 73 // - |GetDevices| returns a list with a |ConnectableDevice|. |
| 48 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 74 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 49 GetConnectableDeviceAdapter(); | 75 GetConnectableDeviceAdapter(); |
| 50 | 76 |
| 51 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the | 77 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the |
| 52 // following characteristics: | 78 // following characteristics: |
| 53 // - |StartDiscoverySession| runs the first argument with |DiscoverySession| | 79 // - |StartDiscoverySessionWithFilter| runs the success callback with |
| 80 // |DiscoverySession| |
| 54 // as argument. | 81 // as argument. |
| 55 // - |GetDevices| returns a list with an |UnconnectableDevice|. | 82 // - |GetDevices| returns a list with an |UnconnectableDevice|. |
| 56 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 83 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 57 GetUnconnectableDeviceAdapter(); | 84 GetUnconnectableDeviceAdapter(); |
| 58 | 85 |
| 59 // Returns a fake |DiscoverySession| with the following characteristics: | 86 // Returns a fake |DiscoverySession| with the following characteristics: |
| 60 // - |Stop| runs the first argument. | 87 // - |Stop| runs the success callback. |
| 61 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | 88 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> |
| 62 GetDiscoverySession(); | 89 GetDiscoverySession(); |
| 63 | 90 |
| 64 // Returns an |EmptyDevice| with the following characeteristics: | 91 // Returns an |EmptyDevice| with the following characeteristics: |
| 65 // - |GetAddress| returns "Empty Mock Device instanceID". | 92 // - |GetAddress| returns "Empty Mock Device instanceID". |
| 66 // - |GetName| returns "Empty Mock Device name". | 93 // - |GetName| returns "Empty Mock Device name". |
| 67 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see | 94 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see |
| 68 // bluetooth.org/en-us/specification/assigned-numbers/baseband | 95 // bluetooth.org/en-us/specification/assigned-numbers/baseband |
| 69 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. | 96 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. |
| 70 // - |GetVendorID| returns 0xFFFF. | 97 // - |GetVendorID| returns 0xFFFF. |
| 71 // - |GetProductID| returns 1. | 98 // - |GetProductID| returns 1. |
| 72 // - |GetDeviceID| returns 2. | 99 // - |GetDeviceID| returns 2. |
| 73 // - |IsPaired| returns true. | 100 // - |IsPaired| returns true. |
| 74 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". | 101 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". |
| 75 // - |GetGattServices| returns a list with one service "Generic Access". | 102 // - |GetGattServices| returns a list with one service "Generic Access". |
| 76 // "Generic Access" has a "Device Name" characteristic, with a value of | 103 // "Generic Access" has a "Device Name" characteristic, with a value of |
| 77 // "Empty Mock Device Name", and a "Reconnection Address" characteristic | 104 // "Empty Mock Device Name", and a "Reconnection Address" characteristic |
| 78 // which can't be read. | 105 // which can't be read. |
| 79 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 106 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 80 GetEmptyDevice(device::MockBluetoothAdapter* adapter); | 107 GetEmptyDevice(device::MockBluetoothAdapter* adapter, |
| 108 const std::string& device_name = "Empty Mock Device"); |
| 81 | 109 |
| 82 // Returns a fake |ConnectableDevice| with the same characteristics as | 110 // Returns a fake |ConnectableDevice| with the same characteristics as |
| 83 // |EmptyDevice| except: | 111 // |EmptyDevice| except: |
| 84 // - |CreateGattConnection| runs success callback with a | 112 // - |CreateGattConnection| runs success callback with a |
| 85 // fake BluetoothGattConnection as argument. | 113 // fake BluetoothGattConnection as argument. |
| 86 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 114 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 87 GetConnectableDevice(device::MockBluetoothAdapter* adapter); | 115 GetConnectableDevice(device::MockBluetoothAdapter* adapter); |
| 88 | 116 |
| 89 // Returns a fake |UnconnectableDevice| with the same characteristics as | 117 // Returns a fake |UnconnectableDevice| with the same characteristics as |
| 90 // |EmptyDevice| except: | 118 // |EmptyDevice| except: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 // - |GetService| returns |service|. | 138 // - |GetService| returns |service|. |
| 111 // - |IsNotifying| returns false. | 139 // - |IsNotifying| returns false. |
| 112 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 140 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
| 113 GetGattCharacteristic(device::MockBluetoothGattService* service, | 141 GetGattCharacteristic(device::MockBluetoothGattService* service, |
| 114 const std::string& uuid); | 142 const std::string& uuid); |
| 115 }; | 143 }; |
| 116 | 144 |
| 117 } // namespace content | 145 } // namespace content |
| 118 | 146 |
| 119 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 147 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
| OLD | NEW |