Chromium Code Reviews| Index: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h |
| diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a094c0f3cd734459057434d6e28408d387b016f8 |
| --- /dev/null |
| +++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER_H_ |
| +#define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER_H_ |
| + |
| +#include "base/callback.h" |
| +#include "device/bluetooth/bluetooth_adapter_factory.h" |
| +#include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| +#include "device/bluetooth/test/mock_bluetooth_device.h" |
| + |
| +namespace content { |
| + |
| +// Implements fake adapters with named mock data set for use in tests as a |
| +// result of layout tests calling testRunner.setBluetoothMockDataSet. |
| +class LayoutTestBluetoothAdapterProvider { |
| + public: |
| + // Calls |callback| with a fake BluetoothAdapter. |adapter|'s |
| + // behavior depends on |fake_adapter_name|. |
| + 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.
|
| + const std::string& fake_adapter_name); |
| + |
| + private: |
| + // Provides the "EmptyAdapter" fake BluetoothAdapter to |callback| with the |
| + // following characteristics: |
| + // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. |
| + // - |GetDevices| returns an empty list of devices. |
| + static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| + GetEmptyAdapter(); |
| + |
| + // Provides the "SingleEmptyDevice" fake BluetoothAdapter to |callback| with |
| + // the following characteristics: |
| + // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. |
| + // - |GetDevices| returns a list with an |EmptyDevice|. |
| + static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> |
| + GetSingleEmptyDeviceAdapter(); |
| + |
| + // Calls |callback| with a DiscoverySession with the following |
| + // characteristics: |
| + // - |Stop| will invoke |SuccessfulDiscoverySessionStop|. |
| + static void SuccessfulDiscoverySession( |
| + const device::BluetoothAdapter::DiscoverySessionCallback& callback, |
| + const device::BluetoothAdapter::ErrorCallback& error_callback); |
| + |
| + // Calls |callback|. |
| + static void SuccessfulDiscoverySessionStop( |
| + const base::Closure& callback, |
| + const base::Closure& error_callback); |
| + |
| + // Returns an |EmptyDevice| with the following characeteristics: |
| + // - |GetAddress| returns "Empty Mock Device instanceID". |
| + // - |GetName| returns "Empty Mock Device name". |
| + // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see |
| + // bluetooth.org/en-us/specification/assigned-numbers/baseband |
| + // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. |
| + // - |GetVendorID| returns 0xFFFF. |
| + // - |GetProductID| returns 1. |
| + // - |GetDeviceID| returns 2. |
| + // - |IsPaired| returns true. |
| + // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". |
| + static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> |
| + GetEmptyDevice(device::MockBluetoothAdapter* adapter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER_H_ |