| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/ime/mock_input_method.h" | 5 #include "ui/views/ime/mock_input_method.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 #include "ui/base/ime/text_input_client.h" | 10 #include "ui/base/ime/text_input_client.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) | 27 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate) |
| 28 : composition_changed_(false), | 28 : composition_changed_(false), |
| 29 focus_changed_(false), | 29 focus_changed_(false), |
| 30 text_input_type_changed_(false), | 30 text_input_type_changed_(false), |
| 31 caret_bounds_changed_(false), | 31 caret_bounds_changed_(false), |
| 32 cancel_composition_called_(false), | 32 cancel_composition_called_(false), |
| 33 locale_("en-US"), | 33 locale_("en-US"), |
| 34 direction_(base::i18n::LEFT_TO_RIGHT), | 34 direction_(base::i18n::LEFT_TO_RIGHT), |
| 35 active_(true) { | 35 active_(true) { |
| 36 set_delegate(delegate); | 36 SetDelegate(delegate); |
| 37 } | 37 } |
| 38 | 38 |
| 39 MockInputMethod::~MockInputMethod() { | 39 MockInputMethod::~MockInputMethod() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void MockInputMethod::Init(Widget* widget) { | 42 void MockInputMethod::Init(Widget* widget) { |
| 43 InputMethodBase::Init(widget); | 43 InputMethodBase::Init(widget); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void MockInputMethod::OnFocus() {} |
| 47 |
| 48 void MockInputMethod::OnBlur() {} |
| 49 |
| 46 void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) { | 50 void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) { |
| 47 bool handled = (composition_changed_ || result_text_.length()) && | 51 bool handled = (composition_changed_ || result_text_.length()) && |
| 48 !IsTextInputTypeNone(); | 52 !IsTextInputTypeNone(); |
| 49 | 53 |
| 50 ClearStates(); | 54 ClearStates(); |
| 51 if (handled) { | 55 if (handled) { |
| 52 ui::KeyEvent mock_key(ui::ET_KEY_PRESSED, | 56 ui::KeyEvent mock_key(ui::ET_KEY_PRESSED, |
| 53 ui::VKEY_PROCESSKEY, | 57 ui::VKEY_PROCESSKEY, |
| 54 key.flags(), | 58 key.flags(), |
| 55 key.is_char()); | 59 key.is_char()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 cancel_composition_called_ = false; | 171 cancel_composition_called_ = false; |
| 168 } | 172 } |
| 169 | 173 |
| 170 void MockInputMethod::ClearResult() { | 174 void MockInputMethod::ClearResult() { |
| 171 composition_.Clear(); | 175 composition_.Clear(); |
| 172 composition_changed_ = false; | 176 composition_changed_ = false; |
| 173 result_text_.clear(); | 177 result_text_.clear(); |
| 174 } | 178 } |
| 175 | 179 |
| 176 } // namespace views | 180 } // namespace views |
| OLD | NEW |