OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_ |
7 | 7 |
8 #include <map> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" | 10 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" |
| 11 #include "chromeos/ime/input_method_descriptor.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 class KeyEvent; | 15 class KeyEvent; |
16 } // namespace ui | 16 } // namespace ui |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 class IBusText; | 20 class IBusText; |
21 | 21 |
22 namespace input_method { | 22 namespace input_method { |
23 class CandidateWindow; | 23 class CandidateWindow; |
24 struct InputMethodProperty; | 24 struct InputMethodProperty; |
25 struct KeyEventHandle; | 25 struct KeyEventHandle; |
26 } // namespace input_method | 26 } // namespace input_method |
27 | 27 |
28 class InputMethodEngine : public InputMethodEngineInterface { | 28 class MockInputMethodEngine : public InputMethodEngineInterface { |
29 public: | 29 public: |
30 InputMethodEngine(); | 30 explicit MockInputMethodEngine( |
31 | 31 const input_method::InputMethodDescriptor& descriptor); |
32 virtual ~InputMethodEngine(); | 32 virtual ~MockInputMethodEngine(); |
33 | |
34 void Initialize( | |
35 InputMethodEngineInterface::Observer* observer, | |
36 const char* engine_name, | |
37 const char* extension_id, | |
38 const char* engine_id, | |
39 const std::vector<std::string>& languages, | |
40 const std::vector<std::string>& layouts, | |
41 const GURL& options_page, | |
42 const GURL& input_view); | |
43 | 33 |
44 // InputMethodEngineInterface overrides. | 34 // InputMethodEngineInterface overrides. |
| 35 virtual const input_method::InputMethodDescriptor& GetDescriptor() |
| 36 const OVERRIDE; |
45 virtual void StartIme() OVERRIDE; | 37 virtual void StartIme() OVERRIDE; |
46 virtual bool SetComposition(int context_id, | 38 virtual bool SetComposition(int context_id, |
47 const char* text, | 39 const char* text, |
48 int selection_start, | 40 int selection_start, |
49 int selection_end, | 41 int selection_end, |
50 int cursor, | 42 int cursor, |
51 const std::vector<SegmentInfo>& segments, | 43 const std::vector<SegmentInfo>& segments, |
52 std::string* error) OVERRIDE; | 44 std::string* error) OVERRIDE; |
53 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE; | 45 virtual bool ClearComposition(int context_id, std::string* error) OVERRIDE; |
54 virtual bool CommitText(int context_id, const char* text, | 46 virtual bool CommitText(int context_id, const char* text, |
(...skipping 30 matching lines...) Expand all Loading... |
85 virtual void PropertyActivate(const std::string& property_name) OVERRIDE; | 77 virtual void PropertyActivate(const std::string& property_name) OVERRIDE; |
86 virtual void Reset() OVERRIDE; | 78 virtual void Reset() OVERRIDE; |
87 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event, | 79 virtual void ProcessKeyEvent(const ui::KeyEvent& key_event, |
88 const KeyEventDoneCallback& callback) OVERRIDE; | 80 const KeyEventDoneCallback& callback) OVERRIDE; |
89 virtual void CandidateClicked(uint32 index) OVERRIDE; | 81 virtual void CandidateClicked(uint32 index) OVERRIDE; |
90 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, | 82 virtual void SetSurroundingText(const std::string& text, uint32 cursor_pos, |
91 uint32 anchor_pos) OVERRIDE; | 83 uint32 anchor_pos) OVERRIDE; |
92 virtual void HideInputView() OVERRIDE; | 84 virtual void HideInputView() OVERRIDE; |
93 | 85 |
94 private: | 86 private: |
95 // Converts MenuItem to InputMethodProperty. | 87 // Descriptor of this input method. |
96 void MenuItemToProperty(const MenuItem& item, | 88 input_method::InputMethodDescriptor descriptor_; |
97 input_method::InputMethodProperty* property); | |
98 | |
99 // True if the current context has focus. | |
100 bool focused_; | |
101 | |
102 // True if this engine is active. | |
103 bool active_; | |
104 | |
105 // ID that is used for the current input context. False if there is no focus. | |
106 int context_id_; | |
107 | |
108 // Next id that will be assigned to a context. | |
109 int next_context_id_; | |
110 | |
111 // This IME ID in Chrome Extension. | |
112 std::string engine_id_; | |
113 | |
114 // This IME ID in ibus. | |
115 std::string ibus_id_; | |
116 | |
117 // Pointer to the object recieving events for this IME. | |
118 InputMethodEngineInterface::Observer* observer_; | |
119 | |
120 // The current preedit text, and it's cursor position. | |
121 scoped_ptr<IBusText> preedit_text_; | |
122 int preedit_cursor_; | |
123 | |
124 // The current candidate window. | |
125 scoped_ptr<input_method::CandidateWindow> candidate_window_; | |
126 | 89 |
127 // The current candidate window property. | 90 // The current candidate window property. |
128 CandidateWindowProperty candidate_window_property_; | 91 CandidateWindowProperty candidate_window_property_; |
129 | |
130 // Indicates whether the candidate window is visible. | |
131 bool window_visible_; | |
132 | |
133 // Mapping of candidate index to candidate id. | |
134 std::vector<int> candidate_ids_; | |
135 | |
136 // Mapping of candidate id to index. | |
137 std::map<int, int> candidate_indexes_; | |
138 | |
139 // Used for input view window. | |
140 GURL input_view_url_; | |
141 }; | 92 }; |
142 | 93 |
143 } // namespace chromeos | 94 } // namespace chromeos |
144 | 95 |
145 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 96 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_ |
OLD | NEW |