| 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/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 *result = InputMethod::NativeEventResult(); | 57 *result = InputMethod::NativeEventResult(); |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) { | 61 void MockInputMethod::DispatchKeyEvent(const ui::KeyEvent& key) { |
| 62 bool handled = (composition_changed_ || result_text_.length()) && | 62 bool handled = (composition_changed_ || result_text_.length()) && |
| 63 !IsTextInputTypeNone(); | 63 !IsTextInputTypeNone(); |
| 64 | 64 |
| 65 ClearStates(); | 65 ClearStates(); |
| 66 if (handled) { | 66 if (handled) { |
| 67 DCHECK(!key.is_char()); |
| 67 ui::KeyEvent mock_key(ui::ET_KEY_PRESSED, | 68 ui::KeyEvent mock_key(ui::ET_KEY_PRESSED, |
| 68 ui::VKEY_PROCESSKEY, | 69 ui::VKEY_PROCESSKEY, |
| 69 key.flags(), | 70 key.flags()); |
| 70 key.is_char()); | |
| 71 DispatchKeyEventPostIME(mock_key); | 71 DispatchKeyEventPostIME(mock_key); |
| 72 } else { | 72 } else { |
| 73 DispatchKeyEventPostIME(key); | 73 DispatchKeyEventPostIME(key); |
| 74 } | 74 } |
| 75 | 75 |
| 76 if (focus_changed_) | 76 if (focus_changed_) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 ui::TextInputClient* client = GetTextInputClient(); | 79 ui::TextInputClient* client = GetTextInputClient(); |
| 80 if (client) { | 80 if (client) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 input_locale_changed_ = false; | 183 input_locale_changed_ = false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 void MockInputMethod::ClearResult() { | 186 void MockInputMethod::ClearResult() { |
| 187 composition_.Clear(); | 187 composition_.Clear(); |
| 188 composition_changed_ = false; | 188 composition_changed_ = false; |
| 189 result_text_.clear(); | 189 result_text_.clear(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace views | 192 } // namespace views |
| OLD | NEW |