Home | History | Annotate | Download | only in ime
      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.
      4 
      5 #include "ui/base/ime/mock_input_method.h"
      6 
      7 namespace ui {
      8 
      9 MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
     10     : text_input_client_(NULL) {
     11 }
     12 
     13 MockInputMethod::~MockInputMethod() {
     14 }
     15 
     16 void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
     17 }
     18 
     19 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
     20   if (text_input_client_ == client)
     21     return;
     22   text_input_client_ = client;
     23   if (client)
     24     OnTextInputTypeChanged(client);
     25 }
     26 
     27 TextInputClient* MockInputMethod::GetTextInputClient() const {
     28   return text_input_client_;
     29 }
     30 
     31 bool MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
     32   return false;
     33 }
     34 
     35 bool MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
     36   return false;
     37 }
     38 
     39 void MockInputMethod::Init(bool focused) {
     40 }
     41 
     42 void MockInputMethod::OnFocus() {
     43   FOR_EACH_OBSERVER(Observer, observer_list_, OnFocus());
     44 }
     45 
     46 void MockInputMethod::OnBlur() {
     47   FOR_EACH_OBSERVER(Observer, observer_list_, OnBlur());
     48 }
     49 
     50 bool MockInputMethod::OnUntranslatedIMEMessage(const base::NativeEvent& event,
     51                                                NativeEventResult* result) {
     52   FOR_EACH_OBSERVER(Observer, observer_list_, OnUntranslatedIMEMessage(event));
     53   if (result)
     54     *result = NativeEventResult();
     55   return false;
     56 }
     57 
     58 void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
     59   FOR_EACH_OBSERVER(Observer, observer_list_, OnTextInputTypeChanged(client));
     60   FOR_EACH_OBSERVER(Observer, observer_list_, OnTextInputStateChanged(client));
     61 }
     62 
     63 void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
     64   FOR_EACH_OBSERVER(Observer, observer_list_, OnCaretBoundsChanged(client));
     65 }
     66 
     67 void MockInputMethod::CancelComposition(const TextInputClient* client) {
     68 }
     69 
     70 void MockInputMethod::OnInputLocaleChanged() {
     71   FOR_EACH_OBSERVER(Observer, observer_list_, OnInputLocaleChanged());
     72 }
     73 
     74 std::string MockInputMethod::GetInputLocale() {
     75   return "";
     76 }
     77 
     78 base::i18n::TextDirection MockInputMethod::GetInputTextDirection() {
     79   return base::i18n::UNKNOWN_DIRECTION;
     80 }
     81 
     82 bool MockInputMethod::IsActive() {
     83   return true;
     84 }
     85 
     86 ui::TextInputType MockInputMethod::GetTextInputType() const {
     87   return ui::TEXT_INPUT_TYPE_NONE;
     88 }
     89 
     90 bool MockInputMethod::CanComposeInline() const {
     91   return true;
     92 }
     93 
     94 bool MockInputMethod::IsCandidatePopupOpen() const {
     95   return false;
     96 }
     97 
     98 void MockInputMethod::AddObserver(InputMethodObserver* observer) {
     99   observer_list_.AddObserver(static_cast<Observer*>(observer));
    100 }
    101 
    102 void MockInputMethod::RemoveObserver(InputMethodObserver* observer) {
    103   observer_list_.RemoveObserver(static_cast<Observer*>(observer));
    104 }
    105 
    106 }  // namespace ui
    107