Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "device/bluetooth/bluetooth_adapter_factory.h" | |
| 10 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | |
| 11 #include "device/bluetooth/test/mock_bluetooth_device.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 // Implements fake adapters with named mock data set for use in tests as a | |
| 16 // result of layout tests calling testRunner.setBluetoothMockDataSet. | |
| 17 class LayoutTestBluetoothAdapterProvider { | |
| 18 public: | |
| 19 // Calls |callback| with a fake BluetoothAdapter. |adapter|'s | |
| 20 // behavior depends on |fake_adapter_name|. | |
| 21 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( | |
|
Jeffrey Yasskin
2015/05/15 23:38:01
Yay for fewer callbacks!
ortuno
2015/05/15 23:53:36
Ah forgot to update the documentation. Done.
| |
| 22 const std::string& fake_adapter_name); | |
| 23 | |
| 24 private: | |
| 25 // Provides the "EmptyAdapter" fake BluetoothAdapter to |callback| with the | |
| 26 // following characteristics: | |
| 27 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. | |
| 28 // - |GetDevices| returns an empty list of devices. | |
| 29 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
| 30 GetEmptyAdapter(); | |
| 31 | |
| 32 // Provides the "SingleEmptyDevice" fake BluetoothAdapter to |callback| with | |
| 33 // the following characteristics: | |
| 34 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. | |
| 35 // - |GetDevices| returns a list with an |EmptyDevice|. | |
| 36 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> | |
| 37 GetSingleEmptyDeviceAdapter(); | |
| 38 | |
| 39 // Calls |callback| with a DiscoverySession with the following | |
| 40 // characteristics: | |
| 41 // - |Stop| will invoke |SuccessfulDiscoverySessionStop|. | |
| 42 static void SuccessfulDiscoverySession( | |
| 43 const device::BluetoothAdapter::DiscoverySessionCallback& callback, | |
| 44 const device::BluetoothAdapter::ErrorCallback& error_callback); | |
| 45 | |
| 46 // Calls |callback|. | |
| 47 static void SuccessfulDiscoverySessionStop( | |
| 48 const base::Closure& callback, | |
| 49 const base::Closure& error_callback); | |
| 50 | |
| 51 // Returns an |EmptyDevice| with the following characeteristics: | |
| 52 // - |GetAddress| returns "Empty Mock Device instanceID". | |
| 53 // - |GetName| returns "Empty Mock Device name". | |
| 54 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see | |
| 55 // bluetooth.org/en-us/specification/assigned-numbers/baseband | |
| 56 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. | |
| 57 // - |GetVendorID| returns 0xFFFF. | |
| 58 // - |GetProductID| returns 1. | |
| 59 // - |GetDeviceID| returns 2. | |
| 60 // - |IsPaired| returns true. | |
| 61 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". | |
| 62 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> | |
| 63 GetEmptyDevice(device::MockBluetoothAdapter* adapter); | |
| 64 }; | |
| 65 | |
| 66 } // namespace content | |
| 67 | |
| 68 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ | |
| OLD | NEW |