Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: ui/base/ime/input_method_chromeos_unittest.cc

Issue 853073002: Update {virtual,override,final} to follow C++11 style in ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_chromeos.h ('k') | ui/chromeos/network/network_icon.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/input_method_chromeos.h" 5 #include "ui/base/ime/input_method_chromeos.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #undef Bool 8 #undef Bool
9 #undef FocusIn 9 #undef FocusIn
10 #undef FocusOut 10 #undef FocusOut
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 process_key_event_post_ime_call_count_(0) { 73 process_key_event_post_ime_call_count_(0) {
74 } 74 }
75 75
76 struct ProcessKeyEventPostIMEArgs { 76 struct ProcessKeyEventPostIMEArgs {
77 ProcessKeyEventPostIMEArgs() : event(NULL), handled(false) {} 77 ProcessKeyEventPostIMEArgs() : event(NULL), handled(false) {}
78 const ui::KeyEvent* event; 78 const ui::KeyEvent* event;
79 bool handled; 79 bool handled;
80 }; 80 };
81 81
82 // Overridden from InputMethodChromeOS: 82 // Overridden from InputMethodChromeOS:
83 virtual void ProcessKeyEventPostIME(const ui::KeyEvent& key_event, 83 void ProcessKeyEventPostIME(const ui::KeyEvent& key_event,
84 bool handled) override { 84 bool handled) override {
85 process_key_event_post_ime_args_.event = &key_event; 85 process_key_event_post_ime_args_.event = &key_event;
86 process_key_event_post_ime_args_.handled = handled; 86 process_key_event_post_ime_args_.handled = handled;
87 ++process_key_event_post_ime_call_count_; 87 ++process_key_event_post_ime_call_count_;
88 } 88 }
89 89
90 void ResetCallCount() { 90 void ResetCallCount() {
91 process_key_event_post_ime_call_count_ = 0; 91 process_key_event_post_ime_call_count_ = 0;
92 } 92 }
93 93
94 const ProcessKeyEventPostIMEArgs& process_key_event_post_ime_args() const { 94 const ProcessKeyEventPostIMEArgs& process_key_event_post_ime_args() const {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 class InputMethodChromeOSTest : public internal::InputMethodDelegate, 202 class InputMethodChromeOSTest : public internal::InputMethodDelegate,
203 public testing::Test, 203 public testing::Test,
204 public TextInputClient { 204 public TextInputClient {
205 public: 205 public:
206 InputMethodChromeOSTest() 206 InputMethodChromeOSTest()
207 : dispatched_key_event_(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, ui::EF_NONE) { 207 : dispatched_key_event_(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, ui::EF_NONE) {
208 ResetFlags(); 208 ResetFlags();
209 } 209 }
210 210
211 virtual ~InputMethodChromeOSTest() { 211 ~InputMethodChromeOSTest() override {}
212 }
213 212
214 virtual void SetUp() override { 213 void SetUp() override {
215 chromeos::IMEBridge::Initialize(); 214 chromeos::IMEBridge::Initialize();
216 215
217 mock_ime_engine_handler_.reset( 216 mock_ime_engine_handler_.reset(
218 new chromeos::MockIMEEngineHandler()); 217 new chromeos::MockIMEEngineHandler());
219 chromeos::IMEBridge::Get()->SetCurrentEngineHandler( 218 chromeos::IMEBridge::Get()->SetCurrentEngineHandler(
220 mock_ime_engine_handler_.get()); 219 mock_ime_engine_handler_.get());
221 220
222 mock_ime_candidate_window_handler_.reset( 221 mock_ime_candidate_window_handler_.reset(
223 new chromeos::MockIMECandidateWindowHandler()); 222 new chromeos::MockIMECandidateWindowHandler());
224 chromeos::IMEBridge::Get()->SetCandidateWindowHandler( 223 chromeos::IMEBridge::Get()->SetCandidateWindowHandler(
225 mock_ime_candidate_window_handler_.get()); 224 mock_ime_candidate_window_handler_.get());
226 225
227 ime_.reset(new TestableInputMethodChromeOS(this)); 226 ime_.reset(new TestableInputMethodChromeOS(this));
228 if (switches::IsTextInputFocusManagerEnabled()) 227 if (switches::IsTextInputFocusManagerEnabled())
229 TextInputFocusManager::GetInstance()->FocusTextInputClient(this); 228 TextInputFocusManager::GetInstance()->FocusTextInputClient(this);
230 else 229 else
231 ime_->SetFocusedTextInputClient(this); 230 ime_->SetFocusedTextInputClient(this);
232 } 231 }
233 232
234 virtual void TearDown() override { 233 void TearDown() override {
235 if (ime_.get()) { 234 if (ime_.get()) {
236 if (switches::IsTextInputFocusManagerEnabled()) 235 if (switches::IsTextInputFocusManagerEnabled())
237 TextInputFocusManager::GetInstance()->BlurTextInputClient(this); 236 TextInputFocusManager::GetInstance()->BlurTextInputClient(this);
238 else 237 else
239 ime_->SetFocusedTextInputClient(NULL); 238 ime_->SetFocusedTextInputClient(NULL);
240 } 239 }
241 ime_.reset(); 240 ime_.reset();
242 chromeos::IMEBridge::Get()->SetCurrentEngineHandler(NULL); 241 chromeos::IMEBridge::Get()->SetCurrentEngineHandler(NULL);
243 chromeos::IMEBridge::Get()->SetCandidateWindowHandler(NULL); 242 chromeos::IMEBridge::Get()->SetCandidateWindowHandler(NULL);
244 mock_ime_engine_handler_.reset(); 243 mock_ime_engine_handler_.reset();
245 mock_ime_candidate_window_handler_.reset(); 244 mock_ime_candidate_window_handler_.reset();
246 chromeos::IMEBridge::Shutdown(); 245 chromeos::IMEBridge::Shutdown();
247 } 246 }
248 247
249 // Overridden from ui::internal::InputMethodDelegate: 248 // Overridden from ui::internal::InputMethodDelegate:
250 virtual bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override { 249 bool DispatchKeyEventPostIME(const ui::KeyEvent& event) override {
251 dispatched_key_event_ = event; 250 dispatched_key_event_ = event;
252 return false; 251 return false;
253 } 252 }
254 253
255 // Overridden from ui::TextInputClient: 254 // Overridden from ui::TextInputClient:
256 virtual void SetCompositionText( 255 void SetCompositionText(const CompositionText& composition) override {
257 const CompositionText& composition) override {
258 composition_text_ = composition; 256 composition_text_ = composition;
259 } 257 }
260 virtual void ConfirmCompositionText() override { 258 void ConfirmCompositionText() override {
261 confirmed_text_ = composition_text_; 259 confirmed_text_ = composition_text_;
262 composition_text_.Clear(); 260 composition_text_.Clear();
263 } 261 }
264 virtual void ClearCompositionText() override { 262 void ClearCompositionText() override { composition_text_.Clear(); }
265 composition_text_.Clear(); 263 void InsertText(const base::string16& text) override {
266 }
267 virtual void InsertText(const base::string16& text) override {
268 inserted_text_ = text; 264 inserted_text_ = text;
269 } 265 }
270 virtual void InsertChar(base::char16 ch, int flags) override { 266 void InsertChar(base::char16 ch, int flags) override {
271 inserted_char_ = ch; 267 inserted_char_ = ch;
272 inserted_char_flags_ = flags; 268 inserted_char_flags_ = flags;
273 } 269 }
274 virtual gfx::NativeWindow GetAttachedWindow() const override { 270 gfx::NativeWindow GetAttachedWindow() const override {
275 return static_cast<gfx::NativeWindow>(NULL); 271 return static_cast<gfx::NativeWindow>(NULL);
276 } 272 }
277 virtual TextInputType GetTextInputType() const override { 273 TextInputType GetTextInputType() const override { return input_type_; }
278 return input_type_; 274 TextInputMode GetTextInputMode() const override { return input_mode_; }
279 } 275 int GetTextInputFlags() const override { return 0; }
280 virtual TextInputMode GetTextInputMode() const override { 276 bool CanComposeInline() const override { return can_compose_inline_; }
281 return input_mode_; 277 gfx::Rect GetCaretBounds() const override { return caret_bounds_; }
282 } 278 bool GetCompositionCharacterBounds(uint32 index,
283 virtual int GetTextInputFlags() const override { 279 gfx::Rect* rect) const override {
284 return 0;
285 }
286 virtual bool CanComposeInline() const override {
287 return can_compose_inline_;
288 }
289 virtual gfx::Rect GetCaretBounds() const override {
290 return caret_bounds_;
291 }
292 virtual bool GetCompositionCharacterBounds(uint32 index,
293 gfx::Rect* rect) const override {
294 return false; 280 return false;
295 } 281 }
296 virtual bool HasCompositionText() const override { 282 bool HasCompositionText() const override {
297 CompositionText empty; 283 CompositionText empty;
298 return composition_text_ != empty; 284 return composition_text_ != empty;
299 } 285 }
300 virtual bool GetTextRange(gfx::Range* range) const override { 286 bool GetTextRange(gfx::Range* range) const override {
301 *range = text_range_; 287 *range = text_range_;
302 return true; 288 return true;
303 } 289 }
304 virtual bool GetCompositionTextRange(gfx::Range* range) const override { 290 bool GetCompositionTextRange(gfx::Range* range) const override {
305 return false; 291 return false;
306 } 292 }
307 virtual bool GetSelectionRange(gfx::Range* range) const override { 293 bool GetSelectionRange(gfx::Range* range) const override {
308 *range = selection_range_; 294 *range = selection_range_;
309 return true; 295 return true;
310 } 296 }
311 297
312 virtual bool SetSelectionRange(const gfx::Range& range) override { 298 bool SetSelectionRange(const gfx::Range& range) override { return false; }
313 return false; 299 bool DeleteRange(const gfx::Range& range) override { return false; }
314 } 300 bool GetTextFromRange(const gfx::Range& range,
315 virtual bool DeleteRange(const gfx::Range& range) override { return false; } 301 base::string16* text) const override {
316 virtual bool GetTextFromRange(const gfx::Range& range,
317 base::string16* text) const override {
318 *text = surrounding_text_.substr(range.GetMin(), range.length()); 302 *text = surrounding_text_.substr(range.GetMin(), range.length());
319 return true; 303 return true;
320 } 304 }
321 virtual void OnInputMethodChanged() override { 305 void OnInputMethodChanged() override {
322 ++on_input_method_changed_call_count_; 306 ++on_input_method_changed_call_count_;
323 } 307 }
324 virtual bool ChangeTextDirectionAndLayoutAlignment( 308 bool ChangeTextDirectionAndLayoutAlignment(
325 base::i18n::TextDirection direction) override { return false; } 309 base::i18n::TextDirection direction) override {
326 virtual void ExtendSelectionAndDelete(size_t before,
327 size_t after) override {}
328 virtual void EnsureCaretInRect(const gfx::Rect& rect) override {}
329 virtual void OnCandidateWindowShown() override {}
330 virtual void OnCandidateWindowUpdated() override {}
331 virtual void OnCandidateWindowHidden() override {}
332 virtual bool IsEditingCommandEnabled(int command_id) override {
333 return false; 310 return false;
334 } 311 }
335 virtual void ExecuteEditingCommand(int command_id) override {} 312 void ExtendSelectionAndDelete(size_t before, size_t after) override {}
313 void EnsureCaretInRect(const gfx::Rect& rect) override {}
314 void OnCandidateWindowShown() override {}
315 void OnCandidateWindowUpdated() override {}
316 void OnCandidateWindowHidden() override {}
317 bool IsEditingCommandEnabled(int command_id) override { return false; }
318 void ExecuteEditingCommand(int command_id) override {}
336 319
337 bool HasNativeEvent() const { 320 bool HasNativeEvent() const {
338 return dispatched_key_event_.HasNativeEvent(); 321 return dispatched_key_event_.HasNativeEvent();
339 } 322 }
340 323
341 void ResetFlags() { 324 void ResetFlags() {
342 dispatched_key_event_ = ui::KeyEvent(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN, 325 dispatched_key_event_ = ui::KeyEvent(ui::ET_UNKNOWN, ui::VKEY_UNKNOWN,
343 ui::EF_NONE); 326 ui::EF_NONE);
344 327
345 composition_text_.Clear(); 328 composition_text_.Clear();
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 923
941 // Should not be called twice with same condition. 924 // Should not be called twice with same condition.
942 ime_->OnCaretBoundsChanged(this); 925 ime_->OnCaretBoundsChanged(this);
943 EXPECT_EQ(0, 926 EXPECT_EQ(0,
944 mock_ime_engine_handler_->set_surrounding_text_call_count()); 927 mock_ime_engine_handler_->set_surrounding_text_call_count());
945 } 928 }
946 929
947 class InputMethodChromeOSKeyEventTest : public InputMethodChromeOSTest { 930 class InputMethodChromeOSKeyEventTest : public InputMethodChromeOSTest {
948 public: 931 public:
949 InputMethodChromeOSKeyEventTest() {} 932 InputMethodChromeOSKeyEventTest() {}
950 virtual ~InputMethodChromeOSKeyEventTest() {} 933 ~InputMethodChromeOSKeyEventTest() override {}
951 934
952 virtual void SetUp() override { 935 void SetUp() override {
953 InputMethodChromeOSTest::SetUp(); 936 InputMethodChromeOSTest::SetUp();
954 ime_->Init(true); 937 ime_->Init(true);
955 } 938 }
956 939
957 DISALLOW_COPY_AND_ASSIGN(InputMethodChromeOSKeyEventTest); 940 DISALLOW_COPY_AND_ASSIGN(InputMethodChromeOSKeyEventTest);
958 }; 941 };
959 942
960 TEST_F(InputMethodChromeOSKeyEventTest, KeyEventDelayResponseTest) { 943 TEST_F(InputMethodChromeOSKeyEventTest, KeyEventDelayResponseTest) {
961 const int kFlags = ui::EF_SHIFT_DOWN; 944 const int kFlags = ui::EF_SHIFT_DOWN;
962 ScopedXI2Event xevent; 945 ScopedXI2Event xevent;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 ime_->ResetContext(); 1049 ime_->ResetContext();
1067 1050
1068 // Do callback. 1051 // Do callback.
1069 mock_ime_engine_handler_->last_passed_callback().Run(true); 1052 mock_ime_engine_handler_->last_passed_callback().Run(true);
1070 1053
1071 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count()); 1054 EXPECT_EQ(0, ime_->process_key_event_post_ime_call_count());
1072 } 1055 }
1073 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593). 1056 // TODO(nona): Introduce ProcessKeyEventPostIME tests(crbug.com/156593).
1074 1057
1075 } // namespace ui 1058 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_chromeos.h ('k') | ui/chromeos/network/network_icon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698