- add sources.
[platform/framework/web/crosswalk.git] / src / ui / base / ime / win / mock_tsf_bridge.cc
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/win/mock_tsf_bridge.h"
6
7 #include "ui/base/ime/text_input_client.h"
8 #include "base/logging.h"
9
10 namespace ui {
11
12 MockTSFBridge::MockTSFBridge()
13   : enable_ime_call_count_(0),
14     disalbe_ime_call_count_(0),
15     cancel_composition_call_count_(0),
16     confirm_composition_call_count_(0),
17     on_text_layout_changed_(0),
18     associate_focus_call_count_(0),
19     set_focused_client_call_count_(0),
20     remove_focused_client_call_count_(0),
21     text_input_client_(NULL),
22     focused_window_(NULL),
23     latest_text_input_type_(TEXT_INPUT_TYPE_NONE) {
24 }
25
26 MockTSFBridge::~MockTSFBridge() {
27 }
28
29 bool MockTSFBridge::CancelComposition() {
30   ++cancel_composition_call_count_;
31   return true;
32 }
33
34 bool MockTSFBridge::ConfirmComposition() {
35   ++confirm_composition_call_count_;
36   return true;
37 }
38
39 void MockTSFBridge::OnTextInputTypeChanged(const TextInputClient* client) {
40   latest_text_input_type_ = client->GetTextInputType();
41 }
42
43 void MockTSFBridge::OnTextLayoutChanged() {
44   ++on_text_layout_changed_;
45 }
46
47 void MockTSFBridge::SetFocusedClient(HWND focused_window,
48                                      TextInputClient* client) {
49   ++set_focused_client_call_count_;
50   focused_window_ = focused_window;
51   text_input_client_ = client;
52 }
53
54 void MockTSFBridge::RemoveFocusedClient(TextInputClient* client) {
55   ++remove_focused_client_call_count_;
56   DCHECK_EQ(client, text_input_client_);
57   text_input_client_ = NULL;
58   focused_window_ = NULL;
59 }
60
61 base::win::ScopedComPtr<ITfThreadMgr> MockTSFBridge::GetThreadManager() {
62   return thread_manager_;
63 }
64
65 TextInputClient* MockTSFBridge::GetFocusedTextInputClient() const {
66   return text_input_client_;
67 }
68
69 void MockTSFBridge::Reset() {
70   enable_ime_call_count_ = 0;
71   disalbe_ime_call_count_ = 0;
72   cancel_composition_call_count_ = 0;
73   confirm_composition_call_count_ = 0;
74   on_text_layout_changed_ = 0;
75   associate_focus_call_count_ = 0;
76   set_focused_client_call_count_ = 0;
77   remove_focused_client_call_count_ = 0;
78   text_input_client_ = NULL;
79   focused_window_ = NULL;
80   latest_text_input_type_ = TEXT_INPUT_TYPE_NONE;
81 }
82
83 }  // namespace ui