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 | |
21 // We have a complete “GenericAccessAdapter”, meaning it has a device which has | |
22 // a Generic Access service with a Device Name characteristic with a descriptor. | |
23 // The other adapters are named based on their particular non-expected behavior. | |
24 | |
20 class LayoutTestBluetoothAdapterProvider { | 25 class LayoutTestBluetoothAdapterProvider { |
21 public: | 26 public: |
22 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. | 27 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. |
23 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( | 28 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( |
24 const std::string& fake_adapter_name); | 29 const std::string& fake_adapter_name); |
25 | 30 |
26 private: | 31 private: |
27 // Returns "EmptyAdapter" fake BluetoothAdapter with the following | 32 // Adapters |
28 // characteristics: | 33 |
29 // - |StartDiscoverySessionWithFilter| runs the success callback with | 34 // |BaseAdapter| |
30 // |DiscoverySession| | 35 // Devices Added: |
31 // as argument. | 36 // None. |
32 // - |GetDevices| returns an empty list of devices. | 37 // Mock Functions: |
38 // - GetDevices: | |
39 // Returns a list of devices added to the adapter. | |
40 // - GetDevice: | |
41 // Returns a device matching the address provided if the device was | |
42 // added to the adapter. | |
43 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
44 GetBaseAdapter(); | |
45 | |
46 // |FailStartDiscoveryAdapter| | |
47 // Inherits from |BaseAdapter| | |
48 // Devices added: | |
49 // None. | |
50 // Mock Functions: | |
51 // - StartDiscoverySessionWithFilter: | |
52 // Run error callback. | |
53 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
54 GetFailStartDiscoveryAdapter(); | |
55 | |
56 // |EmptyAdapter| | |
57 // Inhertis from |BaseAdapter| | |
Jeffrey Yasskin
2015/07/18 00:18:25
sp: Inhertis
ortuno
2015/07/20 16:55:42
Done.
| |
58 // Devices added: | |
59 // None. | |
60 // Mock Functions: | |
61 // - StartDiscoverySessionWithFilter: | |
62 // Run success callback with |DiscoverySession|. | |
33 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 63 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
34 GetEmptyAdapter(); | 64 GetEmptyAdapter(); |
35 | 65 |
66 // Discovery Sessions | |
67 | |
68 // |DiscoverySession| | |
69 // Mock Functions: | |
70 // - Stop: | |
71 // Run success callback. | |
72 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | |
73 GetDiscoverySession(); | |
74 | |
75 // End of updated code. | |
Jeffrey Yasskin
2015/07/18 00:18:25
Probably comment this something like "The function
ortuno
2015/07/20 16:55:42
Done.
| |
76 | |
36 // Returns a fake BluetoothAdapter that asserts that its | 77 // Returns a fake BluetoothAdapter that asserts that its |
37 // StartDiscoverySessionWithFilter() method is called with a filter consisting | 78 // StartDiscoverySessionWithFilter() method is called with a filter consisting |
38 // of the standard battery, heart rate, and glucose services. | 79 // of the standard battery, heart rate, and glucose services. |
39 // - |StartDiscoverySessionWithFilter(correct arguments)| runs the success | 80 // - |StartDiscoverySessionWithFilter(correct arguments)| runs the success |
40 // callback with |DiscoverySession| as the argument. With incorrect | 81 // callback with |DiscoverySession| as the argument. With incorrect |
41 // arguments, it runs the failure callback. | 82 // arguments, it runs the failure callback. |
42 // - |GetDevices| returns a device with a Battery service. | 83 // - |GetDevices| returns a device with a Battery service. |
43 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 84 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
44 GetScanFilterCheckingAdapter(); | 85 GetScanFilterCheckingAdapter(); |
45 | 86 |
(...skipping 30 matching lines...) Expand all Loading... | |
76 | 117 |
77 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the | 118 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the |
78 // following characteristics: | 119 // following characteristics: |
79 // - |StartDiscoverySessionWithFilter| runs the success callback with | 120 // - |StartDiscoverySessionWithFilter| runs the success callback with |
80 // |DiscoverySession| | 121 // |DiscoverySession| |
81 // as argument. | 122 // as argument. |
82 // - |GetDevices| returns a list with an |UnconnectableDevice|. | 123 // - |GetDevices| returns a list with an |UnconnectableDevice|. |
83 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | 124 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
84 GetUnconnectableDeviceAdapter(); | 125 GetUnconnectableDeviceAdapter(); |
85 | 126 |
86 // Returns a fake |DiscoverySession| with the following characteristics: | |
87 // - |Stop| runs the success callback. | |
88 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>> | |
89 GetDiscoverySession(); | |
90 | |
91 // Returns an |EmptyDevice| with the following characeteristics: | 127 // Returns an |EmptyDevice| with the following characeteristics: |
92 // - |GetAddress| returns "Empty Mock Device instanceID". | 128 // - |GetAddress| returns "Empty Mock Device instanceID". |
93 // - |GetName| returns "Empty Mock Device name". | 129 // - |GetName| returns "Empty Mock Device name". |
94 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see | 130 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see |
95 // bluetooth.org/en-us/specification/assigned-numbers/baseband | 131 // bluetooth.org/en-us/specification/assigned-numbers/baseband |
96 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. | 132 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. |
97 // - |GetVendorID| returns 0xFFFF. | 133 // - |GetVendorID| returns 0xFFFF. |
98 // - |GetProductID| returns 1. | 134 // - |GetProductID| returns 1. |
99 // - |GetDeviceID| returns 2. | 135 // - |GetDeviceID| returns 2. |
100 // - |IsPaired| returns true. | 136 // - |IsPaired| returns true. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 // - |GetService| returns |service|. | 175 // - |GetService| returns |service|. |
140 // - |IsNotifying| returns false. | 176 // - |IsNotifying| returns false. |
141 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | 177 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> |
142 GetGattCharacteristic(device::MockBluetoothGattService* service, | 178 GetGattCharacteristic(device::MockBluetoothGattService* service, |
143 const std::string& uuid); | 179 const std::string& uuid); |
144 }; | 180 }; |
145 | 181 |
146 } // namespace content | 182 } // namespace content |
147 | 183 |
148 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ | 184 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ |
OLD | NEW |