1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/base/ime/mock_input_method.h"
9 MockInputMethod::MockInputMethod(internal::InputMethodDelegate
* delegate
)
10 : text_input_client_(NULL
) {
13 MockInputMethod::~MockInputMethod() {
16 void MockInputMethod::SetDelegate(internal::InputMethodDelegate
* delegate
) {
19 void MockInputMethod::SetFocusedTextInputClient(TextInputClient
* client
) {
20 if (text_input_client_
== client
)
22 text_input_client_
= client
;
24 OnTextInputTypeChanged(client
);
27 void MockInputMethod::DetachTextInputClient(TextInputClient
* client
) {
28 if (text_input_client_
== client
) {
29 text_input_client_
= NULL
;
33 TextInputClient
* MockInputMethod::GetTextInputClient() const {
34 return text_input_client_
;
37 bool MockInputMethod::DispatchKeyEvent(const ui::KeyEvent
& event
) {
41 void MockInputMethod::Init(bool focused
) {
44 void MockInputMethod::OnFocus() {
45 FOR_EACH_OBSERVER(InputMethodObserver
, observer_list_
, OnFocus());
48 void MockInputMethod::OnBlur() {
49 FOR_EACH_OBSERVER(InputMethodObserver
, observer_list_
, OnBlur());
52 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent
& event
,
53 NativeEventResult
* result
) {
55 *result
= NativeEventResult();
59 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient
* client
) {
60 FOR_EACH_OBSERVER(InputMethodObserver
,
62 OnTextInputTypeChanged(client
));
63 FOR_EACH_OBSERVER(InputMethodObserver
,
65 OnTextInputStateChanged(client
));
68 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient
* client
) {
69 FOR_EACH_OBSERVER(InputMethodObserver
,
71 OnCaretBoundsChanged(client
));
74 void MockInputMethod::CancelComposition(const TextInputClient
* client
) {
77 void MockInputMethod::OnInputLocaleChanged() {
80 std::string
MockInputMethod::GetInputLocale() {
84 bool MockInputMethod::IsActive() {
88 TextInputType
MockInputMethod::GetTextInputType() const {
89 return TEXT_INPUT_TYPE_NONE
;
92 TextInputMode
MockInputMethod::GetTextInputMode() const {
93 return TEXT_INPUT_MODE_DEFAULT
;
96 bool MockInputMethod::CanComposeInline() const {
100 bool MockInputMethod::IsCandidatePopupOpen() const {
104 void MockInputMethod::ShowImeIfNeeded() {
105 FOR_EACH_OBSERVER(InputMethodObserver
, observer_list_
, OnShowImeIfNeeded());
108 void MockInputMethod::AddObserver(InputMethodObserver
* observer
) {
109 observer_list_
.AddObserver(observer
);
112 void MockInputMethod::RemoveObserver(InputMethodObserver
* observer
) {
113 observer_list_
.RemoveObserver(observer
);