1// Copyright 2013 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/chromeos/mock_ime_engine_handler.h"
6
7namespace chromeos {
8
9MockIMEEngineHandler::MockIMEEngineHandler()
10    : focus_in_call_count_(0),
11      focus_out_call_count_(0),
12      set_surrounding_text_call_count_(0),
13      process_key_event_call_count_(0),
14      reset_call_count_(0),
15      last_text_input_context_(ui::TEXT_INPUT_TYPE_NONE,
16                               ui::TEXT_INPUT_MODE_DEFAULT),
17      last_set_surrounding_cursor_pos_(0),
18      last_set_surrounding_anchor_pos_(0) {
19}
20
21MockIMEEngineHandler::~MockIMEEngineHandler() {
22}
23
24void MockIMEEngineHandler::FocusIn(const InputContext& input_context) {
25  last_text_input_context_ = input_context;
26  if (last_text_input_context_.type != ui::TEXT_INPUT_TYPE_NONE)
27    ++focus_in_call_count_;
28}
29
30void MockIMEEngineHandler::FocusOut() {
31  if (last_text_input_context_.type != ui::TEXT_INPUT_TYPE_NONE)
32    ++focus_out_call_count_;
33  last_text_input_context_.type = ui::TEXT_INPUT_TYPE_NONE;
34}
35
36void MockIMEEngineHandler::Enable(const std::string& component_id) {
37}
38
39void MockIMEEngineHandler::Disable() {
40}
41
42void MockIMEEngineHandler::PropertyActivate(const std::string& property_name) {
43  last_activated_property_ = property_name;
44}
45
46void MockIMEEngineHandler::Reset() {
47  ++reset_call_count_;
48}
49
50void MockIMEEngineHandler::ProcessKeyEvent(
51    const ui::KeyEvent& key_event,
52    const KeyEventDoneCallback& callback) {
53  ++process_key_event_call_count_;
54  last_processed_key_event_.reset(new ui::KeyEvent(key_event));
55  last_passed_callback_ = callback;
56}
57
58void MockIMEEngineHandler::CandidateClicked(uint32 index) {
59}
60
61void MockIMEEngineHandler::SetSurroundingText(const std::string& text,
62                                              uint32 cursor_pos,
63                                              uint32 anchor_pos) {
64  ++set_surrounding_text_call_count_;
65  last_set_surrounding_text_ = text;
66  last_set_surrounding_cursor_pos_ = cursor_pos;
67  last_set_surrounding_anchor_pos_ = anchor_pos;
68}
69
70} // namespace chromeos
71