Chromium Code Reviews| 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_service.h" | 14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
| 15 | |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 // 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 |
| 17 // result of layout tests calling testRunner.setBluetoothMockDataSet. | 19 // result of layout tests calling testRunner.setBluetoothMockDataSet. |
| 18 class LayoutTestBluetoothAdapterProvider { | 20 class LayoutTestBluetoothAdapterProvider { |
| 19 public: | 21 public: |
| 20 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. | 22 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. |
| 21 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( | 23 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( |
| 22 const std::string& fake_adapter_name); | 24 const std::string& fake_adapter_name); |
| 23 | 25 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // - |GetAddress| returns "Empty Mock Device instanceID". | 65 // - |GetAddress| returns "Empty Mock Device instanceID". |
| 64 // - |GetName| returns "Empty Mock Device name". | 66 // - |GetName| returns "Empty Mock Device name". |
| 65 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see | 67 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see |
| 66 // bluetooth.org/en-us/specification/assigned-numbers/baseband | 68 // bluetooth.org/en-us/specification/assigned-numbers/baseband |
| 67 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. | 69 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. |
| 68 // - |GetVendorID| returns 0xFFFF. | 70 // - |GetVendorID| returns 0xFFFF. |
| 69 // - |GetProductID| returns 1. | 71 // - |GetProductID| returns 1. |
| 70 // - |GetDeviceID| returns 2. | 72 // - |GetDeviceID| returns 2. |
| 71 // - |IsPaired| returns true. | 73 // - |IsPaired| returns true. |
| 72 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". | 74 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". |
| 73 // - |GetGattServices| returns a list with two services "Generic Access" and | 75 // - |GetGattServices| returns a list with two services "Generic Access" and |
|
Jeffrey Yasskin
2015/06/03 00:13:50
Please mention the characteristics on these servic
ortuno
2015/06/03 20:27:23
Done.
| |
| 74 // "Generic Attribute". | 76 // "Generic Attribute". |
| 75 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 77 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 76 GetEmptyDevice(device::MockBluetoothAdapter* adapter); | 78 GetEmptyDevice(device::MockBluetoothAdapter* adapter); |
| 77 | 79 |
| 78 // Returns a fake |ConnectableDevice| with the same characteristics as | 80 // Returns a fake |ConnectableDevice| with the same characteristics as |
| 79 // |EmptyDevice| except: | 81 // |EmptyDevice| except: |
| 80 // - |CreateGattConnection| runs success callback with a | 82 // - |CreateGattConnection| runs success callback with a |
| 81 // fake BluetoothGattConnection as argument. | 83 // fake BluetoothGattConnection as argument. |
| 82 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 84 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 83 GetConnectableDevice(device::MockBluetoothAdapter* adapter); | 85 GetConnectableDevice(device::MockBluetoothAdapter* adapter); |
| 84 | 86 |
| 85 // Returns a fake |UnconnectableDevice| with the same characteristics as | 87 // Returns a fake |UnconnectableDevice| with the same characteristics as |
| 86 // |EmptyDevice| except: | 88 // |EmptyDevice| except: |
| 87 // - |CreateGattConnection| runs error callback with | 89 // - |CreateGattConnection| runs error callback with |
| 88 // |BluetoothDevice::ERROR_FAILED| as argument. | 90 // |BluetoothDevice::ERROR_FAILED| as argument. |
| 89 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | 91 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| 90 GetUnconnectableDevice(device::MockBluetoothAdapter* adapter); | 92 GetUnconnectableDevice(device::MockBluetoothAdapter* adapter); |
| 91 | 93 |
| 92 // Returns a fake BluetoothGattService with the following characteristics: | 94 // Returns a fake BluetoothGattService with the following characteristics: |
| 93 // - |GetIdentifier| returns |uuid|. | 95 // - |GetIdentifier| returns |uuid|. |
| 94 // - |GetUUID| returns BluetoothUUID(|uuid|). | 96 // - |GetUUID| returns BluetoothUUID(|uuid|). |
| 95 // - |IsLocal| returns false. | 97 // - |IsLocal| returns false. |
| 96 // - |IsPrimary| returns true. | 98 // - |IsPrimary| returns true. |
| 97 // - |GetDevice| returns |device|. | 99 // - |GetDevice| returns |device|. |
| 98 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattService>> | 100 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattService>> |
| 99 GetMockService(device::MockBluetoothDevice* device, const std::string& uuid); | 101 GetMockService(device::MockBluetoothDevice* device, const std::string& uuid); |
| 102 | |
| 103 // Returns a fake BluetoothGattCharacteristic with the following | |
| 104 // characteristics: | |
| 105 // - |GetIdentifier| returns |uuid|. | |
| 106 // - |GetUUID| returns BluetoothUUID(|uuid|). | |
| 107 // - |IsLocal| returns false. | |
| 108 // - |GetService| returns |service|. | |
| 109 // - |IsNotifying| returns false. | |
| 110 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>> | |
| 111 GetMockCharacteristic(device::MockBluetoothGattService* service, | |
| 112 const std::string& uuid); | |
| 100 }; | 113 }; |
| 101 | 114 |
| 102 } // namespace content | 115 } // namespace content |
| 103 | 116 |
| 104 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ | 117 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ |
| OLD | NEW |