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; |
26 virtual void SetFocusedClient(HWND focused_window, | 27 virtual void SetFocusedClient(HWND focused_window, |
27 TextInputClient* client) OVERRIDE; | 28 TextInputClient* client) OVERRIDE; |
28 virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE; | 29 virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE; |
29 virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE; | 30 virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE; |
30 virtual TextInputClient* GetFocusedTextInputClient() const OVERRIDE; | 31 virtual TextInputClient* GetFocusedTextInputClient() const OVERRIDE; |
31 | 32 |
32 // Resets MockTSFBridge state including function call counter. | 33 // Resets MockTSFBridge state including function call counter. |
33 void Reset(); | 34 void Reset(); |
34 | 35 |
35 // Call count of Shutdown(). | 36 // Call count of Shutdown(). |
36 int shutdown_call_count() const { return shutdown_call_count_; } | 37 int shutdown_call_count() const { return shutdown_call_count_; } |
37 | 38 |
38 // Call count of EnableIME(). | 39 // Call count of EnableIME(). |
39 int enable_ime_call_count() const { return enable_ime_call_count_; } | 40 int enable_ime_call_count() const { return enable_ime_call_count_; } |
40 | 41 |
41 // Call count of DisableIME(). | 42 // Call count of DisableIME(). |
42 int disalbe_ime_call_count() const { return disalbe_ime_call_count_; } | 43 int disalbe_ime_call_count() const { return disalbe_ime_call_count_; } |
43 | 44 |
44 // Call count of CancelComposition(). | 45 // Call count of CancelComposition(). |
45 int cancel_composition_call_count() const { | 46 int cancel_composition_call_count() const { |
46 return cancel_composition_call_count_; | 47 return cancel_composition_call_count_; |
47 } | 48 } |
48 | 49 |
| 50 // Call count of OnTextLayoutChanged(). |
| 51 int on_text_layout_changed() const { |
| 52 return on_text_layout_changed_; |
| 53 } |
| 54 |
49 // Call count of AssociateFocus(). | 55 // Call count of AssociateFocus(). |
50 int associate_focus_call_count() const { return associate_focus_call_count_; } | 56 int associate_focus_call_count() const { return associate_focus_call_count_; } |
51 | 57 |
52 // Call count of SetFocusClient(). | 58 // Call count of SetFocusClient(). |
53 int set_focused_client_call_count() const { | 59 int set_focused_client_call_count() const { |
54 return set_focused_client_call_count_; | 60 return set_focused_client_call_count_; |
55 } | 61 } |
56 | 62 |
57 // Call count of Shutdown(). | 63 // Call count of Shutdown(). |
58 int remove_focused_client_call_count() const { | 64 int remove_focused_client_call_count() const { |
59 return remove_focused_client_call_count_; | 65 return remove_focused_client_call_count_; |
60 } | 66 } |
61 | 67 |
62 // Returns current TextInputClient. | 68 // Returns current TextInputClient. |
63 TextInputClient* text_input_clinet() const { return text_input_client_; } | 69 TextInputClient* text_input_clinet() const { return text_input_client_; } |
64 | 70 |
65 // Returns currently focused window handle. | 71 // Returns currently focused window handle. |
66 HWND focused_window() const { return focused_window_; } | 72 HWND focused_window() const { return focused_window_; } |
67 | 73 |
68 // Returns latest text input type. | 74 // Returns latest text input type. |
69 TextInputType latest_text_iput_type() const { | 75 TextInputType latest_text_iput_type() const { |
70 return latest_text_input_type_; | 76 return latest_text_input_type_; |
71 } | 77 } |
72 | 78 |
73 private: | 79 private: |
74 int shutdown_call_count_; | 80 int shutdown_call_count_; |
75 int enable_ime_call_count_; | 81 int enable_ime_call_count_; |
76 int disalbe_ime_call_count_; | 82 int disalbe_ime_call_count_; |
77 int cancel_composition_call_count_; | 83 int cancel_composition_call_count_; |
| 84 int on_text_layout_changed_; |
78 int associate_focus_call_count_; | 85 int associate_focus_call_count_; |
79 int set_focused_client_call_count_; | 86 int set_focused_client_call_count_; |
80 int remove_focused_client_call_count_; | 87 int remove_focused_client_call_count_; |
81 TextInputClient* text_input_client_; | 88 TextInputClient* text_input_client_; |
82 HWND focused_window_; | 89 HWND focused_window_; |
83 TextInputType latest_text_input_type_; | 90 TextInputType latest_text_input_type_; |
84 base::win::ScopedComPtr<ITfThreadMgr> thread_manager_; | 91 base::win::ScopedComPtr<ITfThreadMgr> thread_manager_; |
85 | 92 |
86 DISALLOW_COPY_AND_ASSIGN(MockTSFBridge); | 93 DISALLOW_COPY_AND_ASSIGN(MockTSFBridge); |
87 }; | 94 }; |
88 | 95 |
89 } // namespace ui | 96 } // namespace ui |
90 | 97 |
91 #endif // UI_BASE_IME_WIN_MOCK_TSF_BRIDGE_H_ | 98 #endif // UI_BASE_IME_WIN_MOCK_TSF_BRIDGE_H_ |
OLD | NEW |