summaryrefslogtreecommitdiffstats
path: root/ui/base/ime/mock_input_method.cc
blob: 3a8e57e1898724b8be02d3abc42b7837bdb90757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/ime/mock_input_method.h"

#include "ui/base/ime/text_input_client.h"

namespace ui {

MockInputMethod::MockInputMethod(internal::InputMethodDelegate* delegate)
    : delegate_(NULL),
      text_input_client_(NULL),
      init_callcount_(0),
      on_focus_callcount_(0),
      on_blur_callcaount_(0),
      set_focused_text_input_client_callcount_(0),
      dispatch_keyevent_callcount_(0),
      dispatch_fabricated_keyevent_callcount_(0),
      on_text_input_type_changed_callcount_(0),
      on_caret_bounds_changed_callcount_(0),
      cancel_composition_callcount_(0),
      get_input_locale_callcount_(0),
      get_input_text_direction_callcount_(0),
      is_active_callcount_(0),
      latest_text_input_type_(ui::TEXT_INPUT_TYPE_NONE) {
  SetDelegate(delegate);
}

MockInputMethod::~MockInputMethod() {
}

void MockInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) {
  delegate_ = delegate;
}

void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) {
  text_input_client_ = client;
  ++set_focused_text_input_client_callcount_;
}

TextInputClient* MockInputMethod::GetTextInputClient() const {
  return text_input_client_;
}

void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
  ++dispatch_keyevent_callcount_;
}

void MockInputMethod::DispatchFabricatedKeyEvent(const ui::KeyEvent& event) {
  ++dispatch_fabricated_keyevent_callcount_;
}

void MockInputMethod::Init(bool focused) {
  ++init_callcount_;
}

void MockInputMethod::OnFocus() {
  ++on_focus_callcount_;
}

void MockInputMethod::OnBlur() {
  ++on_blur_callcaount_;
}

void MockInputMethod::OnTextInputTypeChanged(const TextInputClient* client) {
  ++on_text_input_type_changed_callcount_;
  latest_text_input_type_ = client->GetTextInputType();
}

void MockInputMethod::OnCaretBoundsChanged(const TextInputClient* client) {
  ++on_caret_bounds_changed_callcount_;
}

void MockInputMethod::CancelComposition(const TextInputClient* client) {
  ++cancel_composition_callcount_;
}


std::string MockInputMethod::GetInputLocale() {
  ++get_input_locale_callcount_;
  return "";
}

base::i18n::TextDirection MockInputMethod::GetInputTextDirection() {
  ++get_input_text_direction_callcount_;
  return base::i18n::UNKNOWN_DIRECTION;
}

bool MockInputMethod::IsActive() {
  ++is_active_callcount_;
  return true;
}

ui::TextInputType MockInputMethod::GetTextInputType() const {
  return ui::TEXT_INPUT_TYPE_NONE;
}

bool MockInputMethod::CanComposeInline() const {
  return true;
}

}  // namespace ui