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 25 matching lines...) Expand all Loading... |
36 // None. | 36 // None. |
37 // Mock Functions: | 37 // Mock Functions: |
38 // - GetDevices: | 38 // - GetDevices: |
39 // Returns a list of devices added to the adapter. | 39 // Returns a list of devices added to the adapter. |
40 // - GetDevice: | 40 // - GetDevice: |
41 // Returns a device matching the address provided if the device was | 41 // Returns a device matching the address provided if the device was |
42 // added to the adapter. | 42 // added to the adapter. |
43 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 43 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
44 GetBaseAdapter(); | 44 GetBaseAdapter(); |
45 | 45 |
| 46 // |ScanFilterCheckingAdapter| |
| 47 // Inherits from |BaseAdapter| |
| 48 // BluetoothAdapter that asserts that its StartDiscoverySessionWithFilter() |
| 49 // method is called with a filter consisting of the standard battery, heart |
| 50 // rate, and glucose services. |
| 51 // Devices added: |
| 52 // - BatteryDevice |
| 53 // Mock Functions: |
| 54 // - StartDiscoverySessionWithFilter: |
| 55 // - With correct arguments: Run success callback. |
| 56 // - With incorrect arguments: Mock complains that function with |
| 57 // correct arguments was never called and error callback is called. |
| 58 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 59 GetScanFilterCheckingAdapter(); |
| 60 |
46 // |FailStartDiscoveryAdapter| | 61 // |FailStartDiscoveryAdapter| |
47 // Inherits from |BaseAdapter| | 62 // Inherits from |BaseAdapter| |
48 // Devices added: | 63 // Devices added: |
49 // None. | 64 // None. |
50 // Mock Functions: | 65 // Mock Functions: |
51 // - StartDiscoverySessionWithFilter: | 66 // - StartDiscoverySessionWithFilter: |
52 // Run error callback. | 67 // Run error callback. |
53 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 68 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
54 GetFailStartDiscoveryAdapter(); | 69 GetFailStartDiscoveryAdapter(); |
55 | 70 |
56 // |EmptyAdapter| | 71 // |EmptyAdapter| |
57 // Inherits from |BaseAdapter| | 72 // Inherits from |BaseAdapter| |
58 // Devices added: | 73 // Devices Added: |
59 // None. | 74 // None. |
60 // Mock Functions: | 75 // Mock Functions: |
61 // - StartDiscoverySessionWithFilter: | 76 // - StartDiscoverySessionWithFilter: |
62 // Run success callback with |DiscoverySession|. | 77 // Run success callback with |DiscoverySession|. |
63 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 78 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
64 GetEmptyAdapter(); | 79 GetEmptyAdapter(); |
65 | 80 |
| 81 // |GlucoseHeartRateAdapter| |
| 82 // Inherits from |EmptyAdapter| |
| 83 // Devices added: |
| 84 // - |GlucoseDevice| |
| 85 // - |HeartRateDevice| |
| 86 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| 87 GetGlucoseHeartRateAdapter(); |
| 88 |
66 // Discovery Sessions | 89 // Discovery Sessions |
67 | 90 |
68 // |DiscoverySession| | 91 // |DiscoverySession| |
69 // Mock Functions: | 92 // Mock Functions: |
70 // - Stop: | 93 // - Stop: |
71 // Run success callback. | 94 // Run success callback. |
72 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | 95 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> |
73 GetDiscoverySession(); | 96 GetDiscoverySession(); |
74 | 97 |
| 98 // Devices |
| 99 |
| 100 // |BaseDevice| |
| 101 // Adv UUIDs added: |
| 102 // None. |
| 103 // Services added: |
| 104 // None. |
| 105 // MockFunctions: |
| 106 // - GetUUIDs: |
| 107 // Returns uuids |
| 108 // - GetGattServices: |
| 109 // Returns a list of all services added to the device. |
| 110 // - GetGattService: |
| 111 // Return a service matching the identifier provided if the service was |
| 112 // added to the mock. |
| 113 // - GetAddress: |
| 114 // Returns: address |
| 115 // - GetName: |
| 116 // Returns: device_name. |
| 117 // - GetBluetoothClass: |
| 118 // Returns: 0x1F00. “Unspecified Device Class” see |
| 119 // bluetooth.org/en-us/specification/assigned-numbers/baseband |
| 120 // - GetVendorIDSource: |
| 121 // Returns: BluetoothDevice::VENDOR_ID_BLUETOOTH. |
| 122 // - GetVendorID: |
| 123 // Returns: 0xFFFF. |
| 124 // - GetProductID: |
| 125 // Returns: 1. |
| 126 // - GetDeviceID: |
| 127 // Returns: 2. |
| 128 // - IsPaired: |
| 129 // Returns true. |
| 130 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 131 GetBaseDevice(device::MockBluetoothAdapter* adapter, |
| 132 const std::string& device_name = "Base Device", |
| 133 device::BluetoothDevice::UUIDList uuids = |
| 134 device::BluetoothDevice::UUIDList(), |
| 135 const std::string& address = "00:00:00:00:00"); |
| 136 |
| 137 // |BatteryDevice| |
| 138 // Inherits from BaseDevice(adapter, "Battery Device", uuids, |
| 139 // "00:00:00:00:01") |
| 140 // Adv UUIDs added: |
| 141 // - Generic Access (0x1800) |
| 142 // - Battery Service UUID (0x180F) |
| 143 // Services added: |
| 144 // None. |
| 145 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 146 GetBatteryDevice(device::MockBluetoothAdapter* adapter); |
| 147 |
| 148 // |GlucoseDevice| |
| 149 // Inherits from BaseDevice(adapter, "Glucose Device", uuids, |
| 150 // "00:00:00:00:02") |
| 151 // Adv UUIDs added: |
| 152 // - Generic Access (0x1800) |
| 153 // - Glucose UUID (0x1808) |
| 154 // Services added: |
| 155 // None. |
| 156 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 157 GetGlucoseDevice(device::MockBluetoothAdapter* adapter); |
| 158 |
| 159 // |HeartRateDevice| |
| 160 // Inherits from BaseDevice(adapter, "Heart Rate Device", uuids, |
| 161 // "00:00:00:00:03") |
| 162 // Adv UUIDs added: |
| 163 // - Generic Access (0x1800) |
| 164 // - Heart Rate UUID (0x180D) |
| 165 // Services added: |
| 166 // None. |
| 167 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 168 GetHeartRateDevice(device::MockBluetoothAdapter* adapter); |
| 169 |
75 // The functions after this haven't been updated to the new design yet. | 170 // The functions after this haven't been updated to the new design yet. |
76 | 171 |
77 // Returns a fake BluetoothAdapter that asserts that its | |
78 // StartDiscoverySessionWithFilter() method is called with a filter consisting | |
79 // of the standard battery, heart rate, and glucose services. | |
80 // - |StartDiscoverySessionWithFilter(correct arguments)| runs the success | |
81 // callback with |DiscoverySession| as the argument. With incorrect | |
82 // arguments, it runs the failure callback. | |
83 // - |GetDevices| returns a device with a Battery service. | |
84 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
85 GetScanFilterCheckingAdapter(); | |
86 | |
87 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following | 172 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following |
88 // characteristics: | 173 // characteristics: |
89 // - |StartDiscoverySessionWithFilter| runs the success callback with | 174 // - |StartDiscoverySessionWithFilter| runs the success callback with |
90 // |DiscoverySession| | 175 // |DiscoverySession| |
91 // as argument. | 176 // as argument. |
92 // - |GetDevices| returns a list with an |EmptyDevice|. | 177 // - |GetDevices| returns a list with an |EmptyDevice|. |
93 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 178 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
94 GetSingleEmptyDeviceAdapter(); | 179 GetSingleEmptyDeviceAdapter(); |
95 | 180 |
96 // Returns "MultiDeviceAdapter", a fake BluetoothAdapter with the following | |
97 // characteristics: | |
98 // - |StartDiscoverySessionWithFilter| runs the success callback with | |
99 // |DiscoverySession| | |
100 // as argument. | |
101 // - |GetDevices| returns a list with 2 devices: | |
102 // - GetUUIDs() returns a Heart Rate Service, | |
103 // and GetName() returns "Heart Rate Device". | |
104 // - GetUUIDs() returns a Glucose Service, | |
105 // and GetName() returns "Glucose Device". | |
106 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
107 GetMultiDeviceAdapter(); | |
108 | |
109 // Returns "ConnectableDeviceAdapter" fake BluetoothAdapter with the | 181 // Returns "ConnectableDeviceAdapter" fake BluetoothAdapter with the |
110 // following characteristics: | 182 // following characteristics: |
111 // - |StartDiscoverySessionWithFilter| runs the success callback with | 183 // - |StartDiscoverySessionWithFilter| runs the success callback with |
112 // |DiscoverySession| | 184 // |DiscoverySession| |
113 // as argument. | 185 // as argument. |
114 // - |GetDevices| returns a list with a |ConnectableDevice|. | 186 // - |GetDevices| returns a list with a |ConnectableDevice|. |
115 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 187 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
116 GetConnectableDeviceAdapter(); | 188 GetConnectableDeviceAdapter(); |
117 | 189 |
118 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the | 190 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // - |GetService| returns |service|. | 247 // - |GetService| returns |service|. |
176 // - |IsNotifying| returns false. | 248 // - |IsNotifying| returns false. |
177 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 249 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
178 GetGattCharacteristic(device::MockBluetoothGattService* service, | 250 GetGattCharacteristic(device::MockBluetoothGattService* service, |
179 const std::string& uuid); | 251 const std::string& uuid); |
180 }; | 252 }; |
181 | 253 |
182 } // namespace content | 254 } // namespace content |
183 | 255 |
184 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ | 256 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI
DER_H_ |
OLD | NEW |