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_IBUS_MOCK_IBUS_CLIENT_H_ 6 #define CHROMEOS_DBUS_IBUS_MOCK_IBUS_CLIENT_H_ 7 8 #include <string> 9 #include "base/callback.h" 10 #include "chromeos/dbus/ibus/ibus_client.h" 11 12 namespace chromeos { 13 14 class MockIBusClient : public IBusClient { 15 public: 16 MockIBusClient(); 17 virtual ~MockIBusClient(); 18 19 typedef base::Callback<void(const std::string& client_name, 20 const CreateInputContextCallback& callback, 21 const ErrorCallback& error_callback)> 22 CreateInputContextHandler; 23 typedef base::Callback<void(const IBusComponent& ibus_component, 24 const RegisterComponentCallback& callback, 25 const ErrorCallback& error_callback)> 26 RegisterComponentHandler; 27 28 // IBusClient override. 29 virtual void CreateInputContext(const std::string& client_name, 30 const CreateInputContextCallback& callback, 31 const ErrorCallback& error_callback) OVERRIDE; 32 33 // IBusClient override. 34 virtual void RegisterComponent(const IBusComponent& ibus_component, 35 const RegisterComponentCallback& callback, 36 const ErrorCallback& error_callback) OVERRIDE; 37 38 // IBusClient override. 39 virtual void SetGlobalEngine(const std::string& engine_name, 40 const ErrorCallback& error_callback) OVERRIDE; 41 42 // IBusClient override. 43 virtual void Exit(ExitOption option, 44 const ErrorCallback& error_callback) OVERRIDE; 45 46 // Function handler for CreateInputContext. The CreateInputContext function 47 // invokes |create_input_context_handler_| unless it's not null. 48 void set_create_input_context_handler( 49 const CreateInputContextHandler& handler) { 50 create_input_context_handler_ = handler; 51 } 52 53 // Function handler for RegisterComponent. The RegisterComponent function 54 // invokes |register_component_handler_| unless it's not null. 55 void set_register_component_handler( 56 const RegisterComponentHandler& handler) { 57 register_component_handler_ = handler; 58 } 59 60 // Call count of CreateInputContext(). 61 int create_input_context_call_count() const { 62 return create_input_context_call_count_; 63 } 64 65 // Call count of RegisterComponent(). 66 int register_component_call_count() const { 67 return register_component_call_count_; 68 } 69 70 int set_global_engine_call_count() const { 71 return set_global_engine_call_count_; 72 } 73 74 const std::string& latest_global_engine_name() const { 75 return latest_global_engine_name_; 76 } 77 78 private: 79 CreateInputContextHandler create_input_context_handler_; 80 RegisterComponentHandler register_component_handler_; 81 int create_input_context_call_count_; 82 int register_component_call_count_; 83 int set_global_engine_call_count_; 84 std::string latest_global_engine_name_; 85 86 DISALLOW_COPY_AND_ASSIGN(MockIBusClient); 87 }; 88 89 } // namespace chromeos 90 91 #endif // CHROMEOS_DBUS_IBUS_MOCK_IBUS_CLIENT_H_ 92