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_ENGINE_SERVICE_H_ | |
6 #define CHROMEOS_DBUS_IBUS_MOCK_IBUS_ENGINE_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 #include "chromeos/dbus/ibus/ibus_engine_service.h" | |
10 #include "chromeos/dbus/ibus/ibus_text.h" | |
11 | |
12 namespace chromeos { | |
13 | |
14 class IBusText; | |
15 | |
16 class MockIBusEngineService : public IBusEngineService { | |
17 public: | |
18 | |
19 struct UpdatePreeditArg { | |
20 UpdatePreeditArg() : is_visible(false) {} | |
21 IBusText ibus_text; | |
22 uint32 cursor_pos; | |
23 bool is_visible; | |
24 }; | |
25 | |
26 struct UpdateAuxiliaryTextArg { | |
27 UpdateAuxiliaryTextArg() : is_visible(false) {} | |
28 IBusText ibus_text; | |
29 bool is_visible; | |
30 }; | |
31 | |
32 struct DeleteSurroundingTextArg { | |
33 int32 offset; | |
34 uint32 length; | |
35 }; | |
36 | |
37 MockIBusEngineService(); | |
38 virtual ~MockIBusEngineService(); | |
39 | |
40 // IBusEngineService overrides. | |
41 virtual void SetEngine(IBusEngineHandlerInterface* handler) OVERRIDE; | |
42 virtual void UnsetEngine(IBusEngineHandlerInterface* handler) OVERRIDE; | |
43 virtual void UpdatePreedit(const IBusText& ibus_text, | |
44 uint32 cursor_pos, | |
45 bool is_visible, | |
46 IBusEnginePreeditFocusOutMode mode) OVERRIDE; | |
47 virtual void UpdateAuxiliaryText(const IBusText& ibus_text, | |
48 bool is_visible) OVERRIDE; | |
49 virtual void ForwardKeyEvent(uint32 keyval, uint32 keycode, | |
50 uint32 state) OVERRIDE; | |
51 virtual void RequireSurroundingText() OVERRIDE; | |
52 virtual void DeleteSurroundingText(int32 offset, uint32 length) OVERRIDE; | |
53 | |
54 IBusEngineHandlerInterface* GetEngine() const; | |
55 | |
56 void Clear(); | |
57 | |
58 int update_preedit_call_count() const { return update_preedit_call_count_; } | |
59 const UpdatePreeditArg& last_update_preedit_arg() const { | |
60 return *last_update_preedit_arg_.get(); | |
61 } | |
62 | |
63 int update_auxiliary_text_call_count() const { | |
64 return update_auxiliary_text_call_count_; | |
65 } | |
66 const UpdateAuxiliaryTextArg& last_update_aux_text_arg() const { | |
67 return *last_update_aux_text_arg_.get(); | |
68 } | |
69 | |
70 int delete_surrounding_text_call_count() const { | |
71 return delete_surrounding_text_call_count_; | |
72 } | |
73 const DeleteSurroundingTextArg& last_delete_surrounding_text_arg() const { | |
74 return *last_delete_surrounding_text_arg_.get(); | |
75 } | |
76 | |
77 private: | |
78 int update_preedit_call_count_; | |
79 int update_auxiliary_text_call_count_; | |
80 int forward_key_event_call_count_; | |
81 int delete_surrounding_text_call_count_; | |
82 | |
83 scoped_ptr<UpdatePreeditArg> last_update_preedit_arg_; | |
84 scoped_ptr<UpdateAuxiliaryTextArg> last_update_aux_text_arg_; | |
85 scoped_ptr<DeleteSurroundingTextArg> last_delete_surrounding_text_arg_; | |
86 | |
87 IBusEngineHandlerInterface* current_engine_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(MockIBusEngineService); | |
90 }; | |
91 | |
92 } // namespace chromeos | |
93 | |
94 #endif // CHROMEOS_DBUS_IBUS_MOCK_IBUS_ENGINE_SERVICE_H_ | |
OLD | NEW |