Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h

Issue 1138913006: bluetooth: Refactor LayoutTestBluetoothAdapterProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-testing-remove-mocking
Patch Set: Use lambdas for creating a discovery session. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13
13 namespace content { 14 namespace content {
14 15
15 // Implements fake adapters with named mock data set for use in tests as a 16 // Implements fake adapters with named mock data set for use in tests as a
16 // result of layout tests calling testRunner.setBluetoothMockDataSet. 17 // result of layout tests calling testRunner.setBluetoothMockDataSet.
17 class LayoutTestBluetoothAdapterProvider { 18 class LayoutTestBluetoothAdapterProvider {
18 public: 19 public:
19 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|. 20 // Returns a BluetoothAdapter. Its behavior depends on |fake_adapter_name|.
20 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter( 21 static scoped_refptr<device::BluetoothAdapter> GetBluetoothAdapter(
21 const std::string& fake_adapter_name); 22 const std::string& fake_adapter_name);
22 23
23 private: 24 private:
24 // Returns "EmptyAdapter" fake BluetoothAdapter with the following 25 // Returns "EmptyAdapter" fake BluetoothAdapter with the following
25 // characteristics: 26 // characteristics:
26 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. 27 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|.
scheib 2015/05/20 04:17:06 SuccessfulDiscoverySession name has changed.
27 // - |GetDevices| returns an empty list of devices. 28 // - |GetDevices| returns an empty list of devices.
28 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> 29 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
29 GetEmptyAdapter(); 30 GetEmptyAdapter();
30 31
31 // Returns "SingleEmptyDevice" fake BluetoothAdapter with the following 32 // Returns "SingleEmptyDevice" fake BluetoothAdapter with the following
32 // characteristics: 33 // characteristics:
33 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|. 34 // - |StartDiscoverySession| invokes |SuccessfulDiscoverySession|.
34 // - |GetDevices| returns a list with an |EmptyDevice|. 35 // - |GetDevices| returns a list with an |EmptyDevice|.
35 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> 36 static scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>>
36 GetSingleEmptyDeviceAdapter(); 37 GetSingleEmptyDeviceAdapter();
37 38
38 // Calls |callback| with a DiscoverySession with the following 39 // Returns a fake DiscoverySession with the following
39 // characteristics: 40 // characteristics:
40 // - |Stop| will invoke |SuccessfulDiscoverySessionStop|. 41 // - |Stop(callback, error_callback)| will run callback.
41 static void SuccessfulDiscoverySession( 42 static scoped_ptr<testing::NiceMock<device::MockBluetoothDiscoverySession>>
42 const device::BluetoothAdapter::DiscoverySessionCallback& callback, 43 GetDiscoverySession();
43 const device::BluetoothAdapter::ErrorCallback& error_callback);
44
45 // Calls |callback|.
46 static void SuccessfulDiscoverySessionStop(
47 const base::Closure& callback,
48 const base::Closure& error_callback);
49 44
50 // Returns an |EmptyDevice| with the following characeteristics: 45 // Returns an |EmptyDevice| with the following characeteristics:
51 // - |GetAddress| returns "Empty Mock Device instanceID". 46 // - |GetAddress| returns "Empty Mock Device instanceID".
52 // - |GetName| returns "Empty Mock Device name". 47 // - |GetName| returns "Empty Mock Device name".
53 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see 48 // - |GetBluetoothClass| returns 0x1F00. "Unspecified Device Class": see
54 // bluetooth.org/en-us/specification/assigned-numbers/baseband 49 // bluetooth.org/en-us/specification/assigned-numbers/baseband
55 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|. 50 // - |GetVendorIDSource| returns |BluetoothDevice::VENDOR_ID_BLUETOOTH|.
56 // - |GetVendorID| returns 0xFFFF. 51 // - |GetVendorID| returns 0xFFFF.
57 // - |GetProductID| returns 1. 52 // - |GetProductID| returns 1.
58 // - |GetDeviceID| returns 2. 53 // - |GetDeviceID| returns 2.
59 // - |IsPaired| returns true. 54 // - |IsPaired| returns true.
60 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801". 55 // - |GetUUIDs| returns a list with two UUIDs: "1800" and "1801".
61 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>> 56 static scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
62 GetEmptyDevice(device::MockBluetoothAdapter* adapter); 57 GetEmptyDevice(device::MockBluetoothAdapter* adapter);
63 }; 58 };
64 59
65 } // namespace content 60 } // namespace content
66 61
67 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_ 62 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_BLUETOOTH_ADAPTER_PROVI DER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698