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 #ifndef UI_BASE_IME_WIN_MOCK_TSF_BRIDGE_H_ 6 #define UI_BASE_IME_WIN_MOCK_TSF_BRIDGE_H_ 7 8 #include <msctf.h> 9 10 #include "base/compiler_specific.h" 11 #include "base/win/scoped_comptr.h" 12 #include "ui/base/ime/text_input_type.h" 13 #include "ui/base/ime/win/tsf_bridge.h" 14 15 namespace ui { 16 17 class MockTSFBridge : public TSFBridge { 18 public: 19 MockTSFBridge(); 20 virtual ~MockTSFBridge(); 21 22 // TSFBridge: 23 virtual bool CancelComposition() OVERRIDE; 24 virtual bool ConfirmComposition() OVERRIDE; 25 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; 26 virtual void OnTextLayoutChanged() OVERRIDE; 27 virtual void SetFocusedClient(HWND focused_window, 28 TextInputClient* client) OVERRIDE; 29 virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE; 30 virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE; 31 virtual TextInputClient* GetFocusedTextInputClient() const OVERRIDE; 32 33 // Resets MockTSFBridge state including function call counter. 34 void Reset(); 35 36 // Call count of EnableIME(). 37 int enable_ime_call_count() const { return enable_ime_call_count_; } 38 39 // Call count of DisableIME(). 40 int disalbe_ime_call_count() const { return disalbe_ime_call_count_; } 41 42 // Call count of CancelComposition(). 43 int cancel_composition_call_count() const { 44 return cancel_composition_call_count_; 45 } 46 47 // Call count of ConfirmComposition(). 48 int confirm_composition_call_count() const { 49 return confirm_composition_call_count_; 50 } 51 52 // Call count of OnTextLayoutChanged(). 53 int on_text_layout_changed() const { 54 return on_text_layout_changed_; 55 } 56 57 // Call count of AssociateFocus(). 58 int associate_focus_call_count() const { return associate_focus_call_count_; } 59 60 // Call count of SetFocusClient(). 61 int set_focused_client_call_count() const { 62 return set_focused_client_call_count_; 63 } 64 65 // Call count of RemoveFocusedClient(). 66 int remove_focused_client_call_count() const { 67 return remove_focused_client_call_count_; 68 } 69 70 // Returns current TextInputClient. 71 TextInputClient* text_input_clinet() const { return text_input_client_; } 72 73 // Returns currently focused window handle. 74 HWND focused_window() const { return focused_window_; } 75 76 // Returns latest text input type. 77 TextInputType latest_text_iput_type() const { 78 return latest_text_input_type_; 79 } 80 81 private: 82 int enable_ime_call_count_; 83 int disalbe_ime_call_count_; 84 int cancel_composition_call_count_; 85 int confirm_composition_call_count_; 86 int on_text_layout_changed_; 87 int associate_focus_call_count_; 88 int set_focused_client_call_count_; 89 int remove_focused_client_call_count_; 90 TextInputClient* text_input_client_; 91 HWND focused_window_; 92 TextInputType latest_text_input_type_; 93 base::win::ScopedComPtr<ITfThreadMgr> thread_manager_; 94 95 DISALLOW_COPY_AND_ASSIGN(MockTSFBridge); 96 }; 97 98 } // namespace ui 99 100 #endif // UI_BASE_IME_WIN_MOCK_TSF_BRIDGE_H_ 101