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