• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
MockTSFBridge()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 
~MockTSFBridge()26 MockTSFBridge::~MockTSFBridge() {
27 }
28 
CancelComposition()29 bool MockTSFBridge::CancelComposition() {
30   ++cancel_composition_call_count_;
31   return true;
32 }
33 
ConfirmComposition()34 bool MockTSFBridge::ConfirmComposition() {
35   ++confirm_composition_call_count_;
36   return true;
37 }
38 
OnTextInputTypeChanged(const TextInputClient * client)39 void MockTSFBridge::OnTextInputTypeChanged(const TextInputClient* client) {
40   latest_text_input_type_ = client->GetTextInputType();
41 }
42 
OnTextLayoutChanged()43 void MockTSFBridge::OnTextLayoutChanged() {
44   ++on_text_layout_changed_;
45 }
46 
SetFocusedClient(HWND focused_window,TextInputClient * client)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 
RemoveFocusedClient(TextInputClient * client)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 
GetThreadManager()61 base::win::ScopedComPtr<ITfThreadMgr> MockTSFBridge::GetThreadManager() {
62   return thread_manager_;
63 }
64 
GetFocusedTextInputClient() const65 TextInputClient* MockTSFBridge::GetFocusedTextInputClient() const {
66   return text_input_client_;
67 }
68 
Reset()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
84