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