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 #include "ui/base/ime/remote_input_method_win.h" | 5 #include "ui/base/ime/remote_input_method_win.h" |
6 | 6 |
7 #include <InputScope.h> | 7 #include <InputScope.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const std::vector<gfx::Rect>& composition_character_bounds) { | 80 const std::vector<gfx::Rect>& composition_character_bounds) { |
81 composition_character_bounds_ = composition_character_bounds; | 81 composition_character_bounds_ = composition_character_bounds; |
82 } | 82 } |
83 void set_emulate_pepper_flash(bool enabled) { | 83 void set_emulate_pepper_flash(bool enabled) { |
84 emulate_pepper_flash_ = enabled; | 84 emulate_pepper_flash_ = enabled; |
85 } | 85 } |
86 | 86 |
87 private: | 87 private: |
88 // Overriden from DummyTextInputClient. | 88 // Overriden from DummyTextInputClient. |
89 virtual void SetCompositionText( | 89 virtual void SetCompositionText( |
90 const ui::CompositionText& composition) OVERRIDE { | 90 const ui::CompositionText& composition) override { |
91 ++call_count_set_composition_text_; | 91 ++call_count_set_composition_text_; |
92 } | 92 } |
93 virtual void InsertChar(base::char16 ch, int flags) OVERRIDE { | 93 virtual void InsertChar(base::char16 ch, int flags) override { |
94 inserted_text_.append(1, ch); | 94 inserted_text_.append(1, ch); |
95 ++call_count_insert_char_; | 95 ++call_count_insert_char_; |
96 } | 96 } |
97 virtual void InsertText(const base::string16& text) OVERRIDE { | 97 virtual void InsertText(const base::string16& text) override { |
98 inserted_text_.append(text); | 98 inserted_text_.append(text); |
99 ++call_count_insert_text_; | 99 ++call_count_insert_text_; |
100 } | 100 } |
101 virtual ui::TextInputType GetTextInputType() const OVERRIDE { | 101 virtual ui::TextInputType GetTextInputType() const override { |
102 return text_input_type_; | 102 return text_input_type_; |
103 } | 103 } |
104 virtual ui::TextInputMode GetTextInputMode() const OVERRIDE { | 104 virtual ui::TextInputMode GetTextInputMode() const override { |
105 return text_input_mode_; | 105 return text_input_mode_; |
106 } | 106 } |
107 virtual gfx::Rect GetCaretBounds() const { | 107 virtual gfx::Rect GetCaretBounds() const { |
108 return caret_bounds_; | 108 return caret_bounds_; |
109 } | 109 } |
110 virtual bool GetCompositionCharacterBounds(uint32 index, | 110 virtual bool GetCompositionCharacterBounds(uint32 index, |
111 gfx::Rect* rect) const OVERRIDE { | 111 gfx::Rect* rect) const override { |
112 // Emulate the situation of crbug.com/328237. | 112 // Emulate the situation of crbug.com/328237. |
113 if (emulate_pepper_flash_) | 113 if (emulate_pepper_flash_) |
114 return false; | 114 return false; |
115 if (!rect || composition_character_bounds_.size() <= index) | 115 if (!rect || composition_character_bounds_.size() <= index) |
116 return false; | 116 return false; |
117 *rect = composition_character_bounds_[index]; | 117 *rect = composition_character_bounds_[index]; |
118 return true; | 118 return true; |
119 } | 119 } |
120 virtual bool HasCompositionText() const OVERRIDE { | 120 virtual bool HasCompositionText() const override { |
121 return !composition_character_bounds_.empty(); | 121 return !composition_character_bounds_.empty(); |
122 } | 122 } |
123 virtual bool GetCompositionTextRange(gfx::Range* range) const OVERRIDE { | 123 virtual bool GetCompositionTextRange(gfx::Range* range) const override { |
124 if (composition_character_bounds_.empty()) | 124 if (composition_character_bounds_.empty()) |
125 return false; | 125 return false; |
126 *range = gfx::Range(0, composition_character_bounds_.size()); | 126 *range = gfx::Range(0, composition_character_bounds_.size()); |
127 return true; | 127 return true; |
128 } | 128 } |
129 virtual void OnCandidateWindowShown() OVERRIDE { | 129 virtual void OnCandidateWindowShown() override { |
130 is_candidate_window_shown_called_ = true; | 130 is_candidate_window_shown_called_ = true; |
131 } | 131 } |
132 virtual void OnCandidateWindowHidden() OVERRIDE { | 132 virtual void OnCandidateWindowHidden() override { |
133 is_candidate_window_hidden_called_ = true; | 133 is_candidate_window_hidden_called_ = true; |
134 } | 134 } |
135 | 135 |
136 ui::TextInputType text_input_type_; | 136 ui::TextInputType text_input_type_; |
137 ui::TextInputMode text_input_mode_; | 137 ui::TextInputMode text_input_mode_; |
138 gfx::Rect caret_bounds_; | 138 gfx::Rect caret_bounds_; |
139 std::vector<gfx::Rect> composition_character_bounds_; | 139 std::vector<gfx::Rect> composition_character_bounds_; |
140 base::string16 inserted_text_; | 140 base::string16 inserted_text_; |
141 size_t call_count_set_composition_text_; | 141 size_t call_count_set_composition_text_; |
142 size_t call_count_insert_char_; | 142 size_t call_count_insert_char_; |
143 size_t call_count_insert_text_; | 143 size_t call_count_insert_text_; |
144 bool emulate_pepper_flash_; | 144 bool emulate_pepper_flash_; |
145 bool is_candidate_window_shown_called_; | 145 bool is_candidate_window_shown_called_; |
146 bool is_candidate_window_hidden_called_; | 146 bool is_candidate_window_hidden_called_; |
147 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); | 147 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
148 }; | 148 }; |
149 | 149 |
150 class MockInputMethodDelegate : public internal::InputMethodDelegate { | 150 class MockInputMethodDelegate : public internal::InputMethodDelegate { |
151 public: | 151 public: |
152 MockInputMethodDelegate() {} | 152 MockInputMethodDelegate() {} |
153 | 153 |
154 const std::vector<ui::KeyboardCode>& fabricated_key_events() const { | 154 const std::vector<ui::KeyboardCode>& fabricated_key_events() const { |
155 return fabricated_key_events_; | 155 return fabricated_key_events_; |
156 } | 156 } |
157 void Reset() { | 157 void Reset() { |
158 fabricated_key_events_.clear(); | 158 fabricated_key_events_.clear(); |
159 } | 159 } |
160 | 160 |
161 private: | 161 private: |
162 virtual bool DispatchKeyEventPostIME(const ui::KeyEvent& event) OVERRIDE { | 162 virtual bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override { |
163 EXPECT_FALSE(event.HasNativeEvent()); | 163 EXPECT_FALSE(event.HasNativeEvent()); |
164 fabricated_key_events_.push_back(event.key_code()); | 164 fabricated_key_events_.push_back(event.key_code()); |
165 return true; | 165 return true; |
166 } | 166 } |
167 | 167 |
168 std::vector<ui::KeyboardCode> fabricated_key_events_; | 168 std::vector<ui::KeyboardCode> fabricated_key_events_; |
169 DISALLOW_COPY_AND_ASSIGN(MockInputMethodDelegate); | 169 DISALLOW_COPY_AND_ASSIGN(MockInputMethodDelegate); |
170 }; | 170 }; |
171 | 171 |
172 class MockRemoteInputMethodDelegateWin | 172 class MockRemoteInputMethodDelegateWin |
(...skipping 17 matching lines...) Expand all Loading... |
190 return composition_character_bounds_; | 190 return composition_character_bounds_; |
191 } | 191 } |
192 void Reset() { | 192 void Reset() { |
193 cancel_composition_called_ = false; | 193 cancel_composition_called_ = false; |
194 text_input_client_updated_called_ = false; | 194 text_input_client_updated_called_ = false; |
195 input_scopes_.clear(); | 195 input_scopes_.clear(); |
196 composition_character_bounds_.clear(); | 196 composition_character_bounds_.clear(); |
197 } | 197 } |
198 | 198 |
199 private: | 199 private: |
200 virtual void CancelComposition() OVERRIDE { | 200 virtual void CancelComposition() override { |
201 cancel_composition_called_ = true; | 201 cancel_composition_called_ = true; |
202 } | 202 } |
203 | 203 |
204 virtual void OnTextInputClientUpdated( | 204 virtual void OnTextInputClientUpdated( |
205 const std::vector<int32>& input_scopes, | 205 const std::vector<int32>& input_scopes, |
206 const std::vector<gfx::Rect>& composition_character_bounds) OVERRIDE { | 206 const std::vector<gfx::Rect>& composition_character_bounds) override { |
207 text_input_client_updated_called_ = true; | 207 text_input_client_updated_called_ = true; |
208 input_scopes_ = input_scopes; | 208 input_scopes_ = input_scopes; |
209 composition_character_bounds_ = composition_character_bounds; | 209 composition_character_bounds_ = composition_character_bounds; |
210 } | 210 } |
211 | 211 |
212 bool cancel_composition_called_; | 212 bool cancel_composition_called_; |
213 bool text_input_client_updated_called_; | 213 bool text_input_client_updated_called_; |
214 std::vector<int32> input_scopes_; | 214 std::vector<int32> input_scopes_; |
215 std::vector<gfx::Rect> composition_character_bounds_; | 215 std::vector<gfx::Rect> composition_character_bounds_; |
216 DISALLOW_COPY_AND_ASSIGN(MockRemoteInputMethodDelegateWin); | 216 DISALLOW_COPY_AND_ASSIGN(MockRemoteInputMethodDelegateWin); |
(...skipping 13 matching lines...) Expand all Loading... |
230 } | 230 } |
231 size_t on_text_input_state_changed() const { | 231 size_t on_text_input_state_changed() const { |
232 return on_text_input_state_changed_; | 232 return on_text_input_state_changed_; |
233 } | 233 } |
234 size_t on_input_method_destroyed_changed() const { | 234 size_t on_input_method_destroyed_changed() const { |
235 return on_input_method_destroyed_changed_; | 235 return on_input_method_destroyed_changed_; |
236 } | 236 } |
237 | 237 |
238 private: | 238 private: |
239 // Overriden from InputMethodObserver. | 239 // Overriden from InputMethodObserver. |
240 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE { | 240 virtual void OnTextInputTypeChanged(const TextInputClient* client) override { |
241 } | 241 } |
242 virtual void OnFocus() OVERRIDE { | 242 virtual void OnFocus() override { |
243 } | 243 } |
244 virtual void OnBlur() OVERRIDE { | 244 virtual void OnBlur() override { |
245 } | 245 } |
246 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE { | 246 virtual void OnCaretBoundsChanged(const TextInputClient* client) override { |
247 } | 247 } |
248 virtual void OnTextInputStateChanged(const TextInputClient* client) OVERRIDE { | 248 virtual void OnTextInputStateChanged(const TextInputClient* client) override { |
249 ++on_text_input_state_changed_; | 249 ++on_text_input_state_changed_; |
250 } | 250 } |
251 virtual void OnInputMethodDestroyed(const InputMethod* client) OVERRIDE { | 251 virtual void OnInputMethodDestroyed(const InputMethod* client) override { |
252 ++on_input_method_destroyed_changed_; | 252 ++on_input_method_destroyed_changed_; |
253 } | 253 } |
254 virtual void OnShowImeIfNeeded() { | 254 virtual void OnShowImeIfNeeded() { |
255 } | 255 } |
256 | 256 |
257 size_t on_text_input_state_changed_; | 257 size_t on_text_input_state_changed_; |
258 size_t on_input_method_destroyed_changed_; | 258 size_t on_input_method_destroyed_changed_; |
259 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); | 259 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); |
260 }; | 260 }; |
261 | 261 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 837 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
838 input_method->AddObserver(&input_method_observer); | 838 input_method->AddObserver(&input_method_observer); |
839 | 839 |
840 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed()); | 840 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed()); |
841 input_method.reset(); | 841 input_method.reset(); |
842 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed()); | 842 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed()); |
843 } | 843 } |
844 | 844 |
845 } // namespace | 845 } // namespace |
846 } // namespace ui | 846 } // namespace ui |
OLD | NEW |