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..10ae4d8a3261790d7c7ed1b34b4ed927100ef923 |
--- /dev/null |
+++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h |
@@ -0,0 +1,75 @@ |
+// 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: |
+ LayoutTestBluetoothAdapterProvider(); |
+ ~LayoutTestBluetoothAdapterProvider(); |
+ |
+ // Calls |callback| with a fake BluetoothAdapter. |adapter|'s |
+ // behavior depends on |fake_adapter_name|. |
+ void GetBluetoothAdapter( |
+ const std::string& fake_adapter_name, |
+ const device::BluetoothAdapterFactory::AdapterCallback& callback); |
+ |
+ private: |
+ // Provides "EmptyAdapter" fake BluetoothAdapter to |callback| with following |
+ // characteristics: |
+ // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. |
+ // - |GetDevices| returns an empty list of devices. |
+ void GetEmptyAdapter( |
+ const device::BluetoothAdapterFactory::AdapterCallback& callback); |
+ |
+ // Provides "SingleEmptyDevice" fake BluetoothAdapter to |callback with the |
+ // following characteristics: |
+ // - |StartDiscoverySession| invokes |SuccessfulDiscoverySessionCallback|. |
+ // - |GetDevices| returns a list with an |EmptyDevice|. |
+ void GetSingleEmptyDeviceAdapter( |
+ const device::BluetoothAdapterFactory::AdapterCallback& callback); |
+ |
+ // Calls |callback| with a DiscoverySession with the following |
+ // characteristics: |
+ // - |Stop| will invoke |SuccessfulStopDiscoverySession|. |
+ 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); |
+ |
+ // Sets up 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". |
+ |
scheib
2015/05/12 20:15:06
Has extra blank line here.
ortuno
2015/05/12 20:49:08
Done.
|
+ void SetupEmptyDevice(); |
+ |
+ scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> adapter_; |
+ scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> empty_device_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER_H_ |