Convert browser_tests to Swarming.
[chromium-blink-merge.git] / content / shell / browser / layout_test / layout_test_bluetooth_adapter_provider.h
blob2ef2df31c37492ee08de023807e45665aa6d2b43
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.
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_
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 #include "device/bluetooth/test/mock_bluetooth_discovery_session.h"
13 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h"
14 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h"
16 namespace content {
18 // Implements fake adapters with named mock data set for use in tests as a
19 // result of layout tests calling testRunner.setBluetoothMockDataSet.
20 class LayoutTestBluetoothAdapterProvider {
21 public:
22 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|.
23 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter(
24 const std::string& fake_adapter_name);
26 private:
27 // Returns "EmptyAdapter" fake BluetoothAdapter with the following
28 // characteristics:
29 // - |StartDiscoverySession| runs the first argument with |DiscoverySession|
30 // as argument.
31 // - |GetDevices| returns an empty list of devices.
32 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
33 GetEmptyAdapter();
35 // Returns "SingleEmptyDeviceAdapter" fake BluetoothAdapter with the following
36 // characteristics:
37 // - |StartDiscoverySession| runs the first argument with |DiscoverySession|
38 // as argument.
39 // - |GetDevices| returns a list with an |EmptyDevice|.
40 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
41 GetSingleEmptyDeviceAdapter();
43 // Returns "ConnectableDeviceAdapter" fake BluetoothAdapter with the
44 // following characteristics:
45 // - |StartDiscoverySession| runs the first argument with |DiscoverySession|
46 // as argument.
47 // - |GetDevices| returns a list with a |ConnectableDevice|.
48 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
49 GetConnectableDeviceAdapter();
51 // Returns "UnconnectableDeviceAdapter" fake BluetoothAdapter with the
52 // following characteristics:
53 // - |StartDiscoverySession| runs the first argument with |DiscoverySession|
54 // as argument.
55 // - |GetDevices| returns a list with an |UnconnectableDevice|.
56 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
57 GetUnconnectableDeviceAdapter();
59 // Returns a fake |DiscoverySession| with the following characteristics:
60 // - |Stop| runs the first argument.
61 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>>
62 GetDiscoverySession();
64 // Returns an |EmptyDevice| with the following characeteristics:
65 // - |GetAddress| returns "Empty Mock Device instanceID".
66 // - |GetName| returns "Empty Mock Device name".
67 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see
68 // bluetooth.org/en-us/specification/assigned-numbers/baseband
69 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|.
70 // - |GetVendorID| returns 0xFFFF.
71 // - |GetProductID| returns 1.
72 // - |GetDeviceID| returns 2.
73 // - |IsPaired| returns true.
74 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801".
75 // - |GetGattServices| returns a list with one service "Generic Access".
76 // "Generic Access" has a "Device Name" characteristic, with a value of
77 // "Empty Mock Device Name", and a "Reconnection Address" characteristic
78 // which can't be read.
79 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
80 GetEmptyDevice(device::MockBluetoothAdapter* adapter);
82 // Returns a fake |ConnectableDevice| with the same characteristics as
83 // |EmptyDevice| except:
84 // - |CreateGattConnection| runs success callback with a
85 // fake BluetoothGattConnection as argument.
86 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
87 GetConnectableDevice(device::MockBluetoothAdapter* adapter);
89 // Returns a fake |UnconnectableDevice| with the same characteristics as
90 // |EmptyDevice| except:
91 // - |CreateGattConnection| runs error callback with
92 // |BluetoothDevice::ERROR_FAILED| as argument.
93 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
94 GetUnconnectableDevice(device::MockBluetoothAdapter* adapter);
96 // Returns a fake BluetoothGattService with the following characteristics:
97 // - |GetIdentifier| returns |uuid|.
98 // - |GetUUID| returns BluetoothUUID(|uuid|).
99 // - |IsLocal| returns false.
100 // - |IsPrimary| returns true.
101 // - |GetDevice| returns |device|.
102 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattService>>
103 GetGattService(device::MockBluetoothDevice* device, const std::string& uuid);
105 // Returns a fake BluetoothGattCharacteristic with the following
106 // characteristics:
107 // - |GetIdentifier| returns |uuid|.
108 // - |GetUUID| returns BluetoothUUID(|uuid|).
109 // - |IsLocal| returns false.
110 // - |GetService| returns |service|.
111 // - |IsNotifying| returns false.
112 static scoped_ptr<testing::NiceMock<device::MockBluetoothGattCharacteristic>>
113 GetGattCharacteristic(device::MockBluetoothGattService* service,
114 const std::string& uuid);
117 } // namespace content
119 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVIDER_H_