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