Home | History | Annotate | Download | only in dbus
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_WITHOUT_GMOCK_H_
      6 #define CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_WITHOUT_GMOCK_H_
      7 
      8 #include <string>
      9 
     10 #include "base/logging.h"
     11 #include "base/observer_list.h"
     12 #include "chromeos/dbus/dbus_thread_manager.h"
     13 
     14 namespace dbus {
     15 class Bus;
     16 class ObjectPath;
     17 }  // namespace dbus
     18 
     19 namespace chromeos {
     20 
     21 class DBusThreadManagerObserver;
     22 class FakeBluetoothAdapterClient;
     23 class FakeBluetoothAgentManagerClient;
     24 class FakeBluetoothDeviceClient;
     25 class FakeBluetoothInputClient;
     26 class FakeBluetoothProfileManagerClient;
     27 class FakeCrosDisksClient;
     28 class FakeCryptohomeClient;
     29 class FakeGsmSMSClient;
     30 class FakePowerManagerClient;
     31 class FakeImageBurnerClient;
     32 class FakeSessionManagerClient;
     33 class FakeShillDeviceClient;
     34 class FakeShillManagerClient;
     35 class FakeSystemClockClient;
     36 class FakeUpdateEngineClient;
     37 class MockIBusClient;
     38 class MockIBusConfigClient;
     39 class MockIBusEngineFactoryService;
     40 class MockIBusEngineService;
     41 class MockIBusInputContextClient;
     42 class MockIBusPanelService;
     43 
     44 // This class provides an another mock DBusThreadManager without gmock
     45 // dependency. This class is used for places where GMock is not allowed
     46 // (ex. ui/) or is not used.
     47 // TODO(haruki): Along with crbug.com/223061, we can rename this class to
     48 // clarify that this can also provides fakes and stubs.
     49 class MockDBusThreadManagerWithoutGMock : public DBusThreadManager {
     50  public:
     51   MockDBusThreadManagerWithoutGMock();
     52   virtual ~MockDBusThreadManagerWithoutGMock();
     53 
     54   virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE;
     55   virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE;
     56   virtual void InitIBusBus(const std::string& ibus_address,
     57                            const base::Closure& closure) OVERRIDE;
     58   virtual dbus::Bus* GetSystemBus() OVERRIDE;
     59   virtual dbus::Bus* GetIBusBus() OVERRIDE;
     60 
     61   virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE;
     62   virtual BluetoothAgentManagerClient*
     63       GetBluetoothAgentManagerClient() OVERRIDE;
     64   virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE;
     65   virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE;
     66   virtual BluetoothProfileManagerClient*
     67       GetBluetoothProfileManagerClient() OVERRIDE;
     68   virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE;
     69   virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE;
     70   virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE;
     71   virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE;
     72   virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE;
     73   virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE;
     74   virtual ShillManagerClient* GetShillManagerClient() OVERRIDE;
     75   virtual ShillProfileClient* GetShillProfileClient() OVERRIDE;
     76   virtual ShillServiceClient* GetShillServiceClient() OVERRIDE;
     77   virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE;
     78   virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE;
     79   virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE;
     80   virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE;
     81   virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE;
     82   virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE;
     83   virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE;
     84   virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE;
     85   virtual SMSClient* GetSMSClient() OVERRIDE;
     86   virtual SystemClockClient* GetSystemClockClient() OVERRIDE;
     87   virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE;
     88   virtual IBusClient* GetIBusClient() OVERRIDE;
     89   virtual IBusConfigClient* GetIBusConfigClient() OVERRIDE;
     90   virtual IBusInputContextClient* GetIBusInputContextClient() OVERRIDE;
     91   virtual IBusEngineFactoryService* GetIBusEngineFactoryService() OVERRIDE;
     92   virtual IBusEngineService* GetIBusEngineService(
     93       const dbus::ObjectPath& object_path) OVERRIDE;
     94   virtual void RemoveIBusEngineService(
     95       const dbus::ObjectPath& object_path) OVERRIDE;
     96   virtual IBusPanelService* GetIBusPanelService() OVERRIDE;
     97 
     98   FakeBluetoothAdapterClient* fake_bluetooth_adapter_client() {
     99     return fake_bluetooth_adapter_client_.get();
    100   }
    101 
    102   FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client() {
    103     return fake_bluetooth_agent_manager_client_.get();
    104   }
    105 
    106   FakeBluetoothDeviceClient* fake_bluetooth_device_client() {
    107     return fake_bluetooth_device_client_.get();
    108   }
    109 
    110   FakeBluetoothInputClient* fake_bluetooth_input_client() {
    111     return fake_bluetooth_input_client_.get();
    112   }
    113 
    114   FakeBluetoothProfileManagerClient* fake_bluetooth_profile_manager_client() {
    115     return fake_bluetooth_profile_manager_client_.get();
    116   }
    117 
    118   FakeCrosDisksClient* fake_cros_disks_client() {
    119     return fake_cros_disks_client_.get();
    120   }
    121 
    122   FakeCryptohomeClient* fake_cryptohome_client() {
    123     return fake_cryptohome_client_.get();
    124   }
    125 
    126   FakeGsmSMSClient* fake_gsm_sms_client() {
    127     return fake_gsm_sms_client_.get();
    128   }
    129 
    130   FakeImageBurnerClient* fake_image_burner_client() {
    131     return fake_image_burner_client_.get();
    132   }
    133 
    134   FakeSessionManagerClient* fake_session_manager_client() {
    135     return fake_session_manager_client_.get();
    136   }
    137 
    138   FakeShillDeviceClient* fake_shill_device_client() {
    139     return fake_shill_device_client_.get();
    140   }
    141 
    142   FakeShillManagerClient* fake_shill_manager_client() {
    143     return fake_shill_manager_client_.get();
    144   }
    145 
    146   FakeSystemClockClient* fake_system_clock_client() {
    147     return fake_system_clock_client_.get();
    148   }
    149 
    150   FakePowerManagerClient* fake_power_manager_client() {
    151     return fake_power_manager_client_.get();
    152   }
    153 
    154   FakeUpdateEngineClient* fake_update_engine_client() {
    155     return fake_update_engine_client_.get();
    156   }
    157 
    158   MockIBusClient* mock_ibus_client() {
    159     return mock_ibus_client_.get();
    160   }
    161 
    162   MockIBusConfigClient* mock_ibus_config_client() {
    163     return mock_ibus_config_client_.get();
    164   }
    165 
    166   MockIBusInputContextClient* mock_ibus_input_context_client() {
    167     return mock_ibus_input_context_client_.get();
    168   }
    169 
    170   MockIBusEngineService* mock_ibus_engine_service() {
    171     return mock_ibus_engine_service_.get();
    172   }
    173 
    174   MockIBusEngineFactoryService* mock_ibus_engine_factory_service() {
    175     return mock_ibus_engine_factory_service_.get();
    176   }
    177 
    178   MockIBusPanelService* mock_ibus_panel_service() {
    179     return mock_ibus_panel_service_.get();
    180   }
    181 
    182   void set_ibus_bus(dbus::Bus* ibus_bus) {
    183     ibus_bus_ = ibus_bus;
    184   }
    185 
    186  private:
    187   // Note: Keep this before other members so they can call AddObserver() in
    188   // their c'tors.
    189   ObserverList<DBusThreadManagerObserver> observers_;
    190 
    191   scoped_ptr<FakeBluetoothAdapterClient> fake_bluetooth_adapter_client_;
    192   scoped_ptr<FakeBluetoothAgentManagerClient>
    193       fake_bluetooth_agent_manager_client_;
    194   scoped_ptr<FakeBluetoothDeviceClient> fake_bluetooth_device_client_;
    195   scoped_ptr<FakeBluetoothInputClient> fake_bluetooth_input_client_;
    196   scoped_ptr<FakeBluetoothProfileManagerClient>
    197       fake_bluetooth_profile_manager_client_;
    198   scoped_ptr<FakeCrosDisksClient> fake_cros_disks_client_;
    199   scoped_ptr<FakeCryptohomeClient> fake_cryptohome_client_;
    200   scoped_ptr<FakeGsmSMSClient> fake_gsm_sms_client_;
    201   scoped_ptr<FakeImageBurnerClient> fake_image_burner_client_;
    202   scoped_ptr<FakeSessionManagerClient> fake_session_manager_client_;
    203   scoped_ptr<FakeShillDeviceClient> fake_shill_device_client_;
    204   scoped_ptr<FakeShillManagerClient> fake_shill_manager_client_;
    205   scoped_ptr<FakeSystemClockClient> fake_system_clock_client_;
    206   scoped_ptr<FakePowerManagerClient> fake_power_manager_client_;
    207   scoped_ptr<FakeUpdateEngineClient> fake_update_engine_client_;
    208 
    209   scoped_ptr<MockIBusClient> mock_ibus_client_;
    210   scoped_ptr<MockIBusConfigClient> mock_ibus_config_client_;
    211   scoped_ptr<MockIBusInputContextClient> mock_ibus_input_context_client_;
    212   scoped_ptr<MockIBusEngineService> mock_ibus_engine_service_;
    213   scoped_ptr<MockIBusEngineFactoryService> mock_ibus_engine_factory_service_;
    214   scoped_ptr<MockIBusPanelService> mock_ibus_panel_service_;
    215 
    216   scoped_ptr<PowerPolicyController> power_policy_controller_;
    217   dbus::Bus* ibus_bus_;
    218 
    219   DISALLOW_COPY_AND_ASSIGN(MockDBusThreadManagerWithoutGMock);
    220 };
    221 
    222 }  // namespace chromeos
    223 
    224 #endif  // CHROMEOS_DBUS_MOCK_DBUS_THREAD_MANAGER_WITHOUT_GMOCK_H_
    225