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

Side by Side Diff: device/bluetooth/test/mock_bluetooth_adapter.h

Issue 1132943002: bluetooth: Move mock creation out of BluetoothDispatcherHost to LayoutTestBluetoothAdapterProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-testing-layout-tests
Patch Set: Add non const method 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_
6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_ 6 #define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_vector.h"
11 #include "device/bluetooth/bluetooth_adapter.h" 12 #include "device/bluetooth/bluetooth_adapter.h"
12 #include "device/bluetooth/bluetooth_audio_sink.h" 13 #include "device/bluetooth/bluetooth_audio_sink.h"
13 #include "device/bluetooth/bluetooth_device.h" 14 #include "device/bluetooth/bluetooth_device.h"
14 #include "device/bluetooth/bluetooth_discovery_session.h" 15 #include "device/bluetooth/bluetooth_discovery_session.h"
16 #include "device/bluetooth/test/mock_bluetooth_device.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 18
17 namespace device { 19 namespace device {
18 20
19 class MockBluetoothAdapter : public BluetoothAdapter { 21 class MockBluetoothAdapter : public BluetoothAdapter {
20 public: 22 public:
21 class Observer : public BluetoothAdapter::Observer { 23 class Observer : public BluetoothAdapter::Observer {
22 public: 24 public:
23 Observer(); 25 Observer();
24 virtual ~Observer(); 26 virtual ~Observer();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void(const DiscoverySessionCallback& callback, 64 void(const DiscoverySessionCallback& callback,
63 const ErrorCallback& error_callback)); 65 const ErrorCallback& error_callback));
64 MOCK_METHOD3(StartDiscoverySessionWithFilterRaw, 66 MOCK_METHOD3(StartDiscoverySessionWithFilterRaw,
65 void(const BluetoothDiscoveryFilter*, 67 void(const BluetoothDiscoveryFilter*,
66 const DiscoverySessionCallback& callback, 68 const DiscoverySessionCallback& callback,
67 const ErrorCallback& error_callback)); 69 const ErrorCallback& error_callback));
68 MOCK_METHOD3(SetDiscoveryFilterRaw, 70 MOCK_METHOD3(SetDiscoveryFilterRaw,
69 void(const BluetoothDiscoveryFilter*, 71 void(const BluetoothDiscoveryFilter*,
70 const base::Closure& callback, 72 const base::Closure& callback,
71 const ErrorCallback& error_callback)); 73 const ErrorCallback& error_callback));
74 MOCK_METHOD0(GetDevices, BluetoothAdapter::DeviceList());
72 MOCK_CONST_METHOD0(GetDevices, BluetoothAdapter::ConstDeviceList()); 75 MOCK_CONST_METHOD0(GetDevices, BluetoothAdapter::ConstDeviceList());
73 MOCK_METHOD1(GetDevice, BluetoothDevice*(const std::string& address)); 76 MOCK_METHOD1(GetDevice, BluetoothDevice*(const std::string& address));
74 MOCK_CONST_METHOD1(GetDevice, 77 MOCK_CONST_METHOD1(GetDevice,
75 const BluetoothDevice*(const std::string& address)); 78 const BluetoothDevice*(const std::string& address));
76 MOCK_METHOD2(AddPairingDelegate, 79 MOCK_METHOD2(AddPairingDelegate,
77 void(BluetoothDevice::PairingDelegate* pairing_delegate, 80 void(BluetoothDevice::PairingDelegate* pairing_delegate,
78 enum PairingDelegatePriority priority)); 81 enum PairingDelegatePriority priority));
79 MOCK_METHOD1(RemovePairingDelegate, 82 MOCK_METHOD1(RemovePairingDelegate,
80 void(BluetoothDevice::PairingDelegate* pairing_delegate)); 83 void(BluetoothDevice::PairingDelegate* pairing_delegate));
81 MOCK_METHOD0(DefaultPairingDelegate, BluetoothDevice::PairingDelegate*()); 84 MOCK_METHOD0(DefaultPairingDelegate, BluetoothDevice::PairingDelegate*());
(...skipping 10 matching lines...) Expand all
92 MOCK_METHOD3(RegisterAudioSink, 95 MOCK_METHOD3(RegisterAudioSink,
93 void(const BluetoothAudioSink::Options& options, 96 void(const BluetoothAudioSink::Options& options,
94 const AcquiredCallback& callback, 97 const AcquiredCallback& callback,
95 const BluetoothAudioSink::ErrorCallback& error_callback)); 98 const BluetoothAudioSink::ErrorCallback& error_callback));
96 99
97 void StartDiscoverySessionWithFilter( 100 void StartDiscoverySessionWithFilter(
98 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, 101 scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
99 const DiscoverySessionCallback& callback, 102 const DiscoverySessionCallback& callback,
100 const ErrorCallback& error_callback); 103 const ErrorCallback& error_callback);
101 104
105 // BluetoothAdapter is supposed to manage the lifetime of BluetoothDevices.
106 // This methods takes ownership of the BluetoothDevices.
armansito 2015/05/19 20:18:33 I would mention here that this is only for conveni
ortuno 2015/05/19 22:25:00 Done.
107 void AddMockDevice(scoped_ptr<MockBluetoothDevice> mock_device);
108 BluetoothAdapter::DeviceList GetMockDevices();
109
102 protected: 110 protected:
103 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 111 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
104 const base::Closure& callback, 112 const base::Closure& callback,
105 const ErrorCallback& error_callback) override; 113 const ErrorCallback& error_callback) override;
106 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 114 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
107 const base::Closure& callback, 115 const base::Closure& callback,
108 const ErrorCallback& error_callback) override; 116 const ErrorCallback& error_callback) override;
109 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, 117 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
110 const base::Closure& callback, 118 const base::Closure& callback,
111 const ErrorCallback& error_callback) override; 119 const ErrorCallback& error_callback) override;
112 void RegisterAdvertisement( 120 void RegisterAdvertisement(
113 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, 121 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
114 const CreateAdvertisementCallback& callback, 122 const CreateAdvertisementCallback& callback,
115 const CreateAdvertisementErrorCallback& error_callback) override; 123 const CreateAdvertisementErrorCallback& error_callback) override;
116 virtual ~MockBluetoothAdapter(); 124 virtual ~MockBluetoothAdapter();
117 125
118 MOCK_METHOD1(RemovePairingDelegateInternal, 126 MOCK_METHOD1(RemovePairingDelegateInternal,
119 void(BluetoothDevice::PairingDelegate* pairing_delegate)); 127 void(BluetoothDevice::PairingDelegate* pairing_delegate));
128
129 ScopedVector<MockBluetoothDevice> mock_devices_;
120 }; 130 };
121 131
122 } // namespace device 132 } // namespace device
123 133
124 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_ 134 #endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698