hashimoto@chromium.org | fa9918b6 | 2012-01-16 06:36:26 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
hashimoto@chromium.org | 64e1992 | 2012-04-06 01:54:36 | [diff] [blame] | 5 | #ifndef CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_H_ |
| 6 | #define CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_H_ |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
derat@chromium.org | 52c086e | 2012-10-08 20:50:07 | [diff] [blame] | 10 | #include "base/observer_list.h" |
hashimoto@chromium.org | 64e1992 | 2012-04-06 01:54:36 | [diff] [blame] | 11 | #include "chromeos/dbus/dbus_thread_manager.h" |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 12 | #include "testing/gmock/include/gmock/gmock.h" |
| 13 | |
keybuk@chromium.org | 24414ff | 2012-03-13 22:41:11 | [diff] [blame] | 14 | namespace dbus { |
| 15 | |
| 16 | class Bus; |
| 17 | |
| 18 | } // namespace dbus |
| 19 | |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 20 | namespace chromeos { |
| 21 | |
derat@chromium.org | 52c086e | 2012-10-08 20:50:07 | [diff] [blame] | 22 | class DBusThreadManagerObserver; |
keybuk@chromium.org | 30c80d5 | 2013-05-23 20:00:10 | [diff] [blame] | 23 | class FakeBluetoothAdapterClient; |
| 24 | class FakeBluetoothAgentManagerClient; |
| 25 | class FakeBluetoothDeviceClient; |
| 26 | class FakeBluetoothInputClient; |
| 27 | class FakeBluetoothProfileManagerClient; |
gdk@chromium.org | 3392da3 | 2012-09-07 04:26:53 | [diff] [blame] | 28 | class MockCryptohomeClient; |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 29 | class MockShillDeviceClient; |
| 30 | class MockShillIPConfigClient; |
| 31 | class MockShillManagerClient; |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 32 | class MockShillProfileClient; |
| 33 | class MockShillServiceClient; |
gdk@chromium.org | 3392da3 | 2012-09-07 04:26:53 | [diff] [blame] | 34 | class MockGsmSMSClient; |
gdk@chromium.org | 3392da3 | 2012-09-07 04:26:53 | [diff] [blame] | 35 | class MockPowerManagerClient; |
| 36 | class MockSessionManagerClient; |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 37 | |
| 38 | // This class provides a mock DBusThreadManager with mock clients |
| 39 | // installed. You can customize the behaviors of mock clients with |
| 40 | // mock_foo_client() functions. |
haruki@chromium.org | cc92d43 | 2013-04-23 05:11:12 | [diff] [blame] | 41 | // Please avoid adding more GMock in this class. We have an ongoing effort to |
| 42 | // remove GMock dependency. TODO(haruki): crbug.com/223061. |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 43 | class MockDBusThreadManager : public DBusThreadManager { |
| 44 | public: |
| 45 | MockDBusThreadManager(); |
| 46 | virtual ~MockDBusThreadManager(); |
| 47 | |
derat@chromium.org | 52c086e | 2012-10-08 20:50:07 | [diff] [blame] | 48 | void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE; |
| 49 | void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE; |
nona@chromium.org | fba4c31 | 2013-02-20 15:09:30 | [diff] [blame] | 50 | MOCK_METHOD2(InitIBusBus, void(const std::string& ibus_address, |
| 51 | const base::Closure& closure)); |
keybuk@chromium.org | 24414ff | 2012-03-13 22:41:11 | [diff] [blame] | 52 | MOCK_METHOD0(GetSystemBus, dbus::Bus*(void)); |
nona@chromium.org | a9732456 | 2012-05-18 16:37:05 | [diff] [blame] | 53 | MOCK_METHOD0(GetIBusBus, dbus::Bus*(void)); |
keybuk@chromium.org | 627f4f4 | 2013-06-12 14:47:32 | [diff] [blame] | 54 | MOCK_METHOD0(GetBluetoothAdapterClient, BluetoothAdapterClient*(void)); |
| 55 | MOCK_METHOD0(GetBluetoothAgentManagerClient, |
| 56 | BluetoothAgentManagerClient*(void)); |
| 57 | MOCK_METHOD0(GetBluetoothDeviceClient, BluetoothDeviceClient*(void)); |
| 58 | MOCK_METHOD0(GetBluetoothInputClient, BluetoothInputClient*(void)); |
| 59 | MOCK_METHOD0(GetBluetoothProfileManagerClient, |
| 60 | BluetoothProfileManagerClient*(void)); |
jennyz@chromium.org | 1ae56b7f | 2013-03-28 07:28:14 | [diff] [blame] | 61 | MOCK_METHOD0(GetCrasAudioClient, CrasAudioClient*(void)); |
hashimoto@chromium.org | 4ae7329 | 2011-11-15 05:20:18 | [diff] [blame] | 62 | MOCK_METHOD0(GetCrosDisksClient, CrosDisksClient*(void)); |
hashimoto@chromium.org | b6d19b1 | 2012-02-14 02:57:28 | [diff] [blame] | 63 | MOCK_METHOD0(GetCryptohomeClient, CryptohomeClient*(void)); |
sleffler@chromium.org | ee0d7ddd | 2012-04-05 20:04:30 | [diff] [blame] | 64 | MOCK_METHOD0(GetDebugDaemonClient, DebugDaemonClient*(void)); |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 65 | MOCK_METHOD0(GetShillDeviceClient, ShillDeviceClient*(void)); |
| 66 | MOCK_METHOD0(GetShillIPConfigClient, ShillIPConfigClient*(void)); |
| 67 | MOCK_METHOD0(GetShillManagerClient, ShillManagerClient*(void)); |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 68 | MOCK_METHOD0(GetShillProfileClient, ShillProfileClient*(void)); |
| 69 | MOCK_METHOD0(GetShillServiceClient, ShillServiceClient*(void)); |
hashimoto@chromium.org | 3e87a6c | 2012-04-19 08:18:48 | [diff] [blame] | 70 | MOCK_METHOD0(GetGsmSMSClient, GsmSMSClient*(void)); |
hashimoto@chromium.org | fa9918b6 | 2012-01-16 06:36:26 | [diff] [blame] | 71 | MOCK_METHOD0(GetImageBurnerClient, ImageBurnerClient*(void)); |
keybuk@google.com | 39666aac | 2012-03-15 21:40:47 | [diff] [blame] | 72 | MOCK_METHOD0(GetIntrospectableClient, IntrospectableClient*(void)); |
benchan@chromium.org | 88d6fc2 | 2012-06-12 08:57:52 | [diff] [blame] | 73 | MOCK_METHOD0(GetModemMessagingClient, ModemMessagingClient*(void)); |
gdk@chromium.org | 3392da3 | 2012-09-07 04:26:53 | [diff] [blame] | 74 | MOCK_METHOD0(GetPermissionBrokerClient, PermissionBrokerClient*(void)); |
satorux@chromium.org | 089e3035 | 2011-10-29 05:25:51 | [diff] [blame] | 75 | MOCK_METHOD0(GetPowerManagerClient, PowerManagerClient*(void)); |
derat@chromium.org | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 76 | MOCK_METHOD0(GetPowerPolicyController, PowerPolicyController*(void)); |
satorux@chromium.org | 089e3035 | 2011-10-29 05:25:51 | [diff] [blame] | 77 | MOCK_METHOD0(GetSessionManagerClient, SessionManagerClient*(void)); |
benchan@chromium.org | 88d6fc2 | 2012-06-12 08:57:52 | [diff] [blame] | 78 | MOCK_METHOD0(GetSMSClient, SMSClient*(void)); |
jennyz@chromium.org | ce3b13ab | 2013-03-14 14:54:19 | [diff] [blame] | 79 | MOCK_METHOD0(GetSystemClockClient, SystemClockClient*(void)); |
satorux@chromium.org | 85c04ce | 2011-11-22 19:13:13 | [diff] [blame] | 80 | MOCK_METHOD0(GetUpdateEngineClient, UpdateEngineClient*(void)); |
nona@chromium.org | 14a1f25 | 2012-05-23 23:17:39 | [diff] [blame] | 81 | MOCK_METHOD0(GetIBusClient, IBusClient*(void)); |
| 82 | MOCK_METHOD0(GetIBusInputContextClient, IBusInputContextClient*(void)); |
nona@chromium.org | 85a966c | 2012-07-18 19:10:52 | [diff] [blame] | 83 | MOCK_METHOD0(GetIBusEngineFactoryService, IBusEngineFactoryService*(void)); |
| 84 | MOCK_METHOD1(GetIBusEngineService, |
| 85 | IBusEngineService*(const dbus::ObjectPath& object_path)); |
nona@chromium.org | 60f50ed | 2012-08-02 04:43:25 | [diff] [blame] | 86 | MOCK_METHOD1(RemoveIBusEngineService, |
| 87 | void(const dbus::ObjectPath& object_path)); |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 88 | |
keybuk@chromium.org | 30c80d5 | 2013-05-23 20:00:10 | [diff] [blame] | 89 | FakeBluetoothAdapterClient* fake_bluetooth_adapter_client() { |
| 90 | return fake_bluetooth_adapter_client_.get(); |
| 91 | } |
| 92 | FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client() { |
| 93 | return fake_bluetooth_agent_manager_client_.get(); |
| 94 | } |
| 95 | FakeBluetoothDeviceClient* fake_bluetooth_device_client() { |
| 96 | return fake_bluetooth_device_client_.get(); |
| 97 | } |
| 98 | FakeBluetoothInputClient* fake_bluetooth_input_client() { |
| 99 | return fake_bluetooth_input_client_.get(); |
| 100 | } |
| 101 | FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client() { |
| 102 | return fake_bluetooth_profile_manager_client_.get(); |
| 103 | } |
hashimoto@chromium.org | b6d19b1 | 2012-02-14 02:57:28 | [diff] [blame] | 104 | MockCryptohomeClient* mock_cryptohome_client() { |
| 105 | return mock_cryptohome_client_.get(); |
sleffler@chromium.org | ee0d7ddd | 2012-04-05 20:04:30 | [diff] [blame] | 106 | } |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 107 | MockShillDeviceClient* mock_shill_device_client() { |
| 108 | return mock_shill_device_client_.get(); |
hashimoto@chromium.org | fa9918b6 | 2012-01-16 06:36:26 | [diff] [blame] | 109 | } |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 110 | MockShillIPConfigClient* mock_shill_ipconfig_client() { |
| 111 | return mock_shill_ipconfig_client_.get(); |
hashimoto@chromium.org | e607239 | 2012-03-30 01:37:23 | [diff] [blame] | 112 | } |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 113 | MockShillManagerClient* mock_shill_manager_client() { |
| 114 | return mock_shill_manager_client_.get(); |
hashimoto@chromium.org | 5c40dce | 2012-04-11 08:01:59 | [diff] [blame] | 115 | } |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 116 | MockShillProfileClient* mock_shill_profile_client() { |
| 117 | return mock_shill_profile_client_.get(); |
hashimoto@chromium.org | 480e227 | 2012-03-30 04:16:56 | [diff] [blame] | 118 | } |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 119 | MockShillServiceClient* mock_shill_service_client() { |
| 120 | return mock_shill_service_client_.get(); |
hashimoto@chromium.org | d4c6bf0 | 2012-04-18 06:10:38 | [diff] [blame] | 121 | } |
hashimoto@chromium.org | 3e87a6c | 2012-04-19 08:18:48 | [diff] [blame] | 122 | MockGsmSMSClient* mock_gsm_sms_client() { |
| 123 | return mock_gsm_sms_client_.get(); |
| 124 | } |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 125 | MockSessionManagerClient* mock_session_manager_client() { |
| 126 | return mock_session_manager_client_.get(); |
satorux@chromium.org | 85c04ce | 2011-11-22 19:13:13 | [diff] [blame] | 127 | } |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 128 | |
| 129 | private: |
derat@chromium.org | 3a229f4 | 2013-02-07 03:09:26 | [diff] [blame] | 130 | // Note: Keep this before other members so they can call AddObserver() in |
| 131 | // their c'tors. |
| 132 | ObserverList<DBusThreadManagerObserver> observers_; |
| 133 | |
keybuk@chromium.org | 30c80d5 | 2013-05-23 20:00:10 | [diff] [blame] | 134 | scoped_ptr<FakeBluetoothAdapterClient> fake_bluetooth_adapter_client_; |
| 135 | scoped_ptr<FakeBluetoothAgentManagerClient> |
| 136 | fake_bluetooth_agent_manager_client_; |
| 137 | scoped_ptr<FakeBluetoothDeviceClient> fake_bluetooth_device_client_; |
| 138 | scoped_ptr<FakeBluetoothInputClient> fake_bluetooth_input_client_; |
| 139 | scoped_ptr<FakeBluetoothProfileManagerClient> |
| 140 | fake_bluetooth_profile_manager_client_; |
hashimoto@chromium.org | b6d19b1 | 2012-02-14 02:57:28 | [diff] [blame] | 141 | scoped_ptr<MockCryptohomeClient> mock_cryptohome_client_; |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 142 | scoped_ptr<MockShillDeviceClient> mock_shill_device_client_; |
| 143 | scoped_ptr<MockShillIPConfigClient> mock_shill_ipconfig_client_; |
| 144 | scoped_ptr<MockShillManagerClient> mock_shill_manager_client_; |
gspencer@chromium.org | 07c674cd | 2012-09-07 20:53:56 | [diff] [blame] | 145 | scoped_ptr<MockShillProfileClient> mock_shill_profile_client_; |
| 146 | scoped_ptr<MockShillServiceClient> mock_shill_service_client_; |
hashimoto@chromium.org | 3e87a6c | 2012-04-19 08:18:48 | [diff] [blame] | 147 | scoped_ptr<MockGsmSMSClient> mock_gsm_sms_client_; |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 148 | scoped_ptr<MockSessionManagerClient> mock_session_manager_client_; |
derat@chromium.org | 52c086e | 2012-10-08 20:50:07 | [diff] [blame] | 149 | |
satorux@chromium.org | d96e7e9 | 2011-10-29 02:30:43 | [diff] [blame] | 150 | DISALLOW_COPY_AND_ASSIGN(MockDBusThreadManager); |
| 151 | }; |
| 152 | |
| 153 | } // namespace chromeos |
| 154 | |
hashimoto@chromium.org | 64e1992 | 2012-04-06 01:54:36 | [diff] [blame] | 155 | #endif // CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_H_ |