OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIEWS_IME_MOCK_INPUT_METHOD_H_ | 5 #ifndef UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ |
6 #define UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ | 6 #define UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "ui/base/ime/composition_text.h" | 12 #include "ui/base/ime/composition_text.h" |
13 #include "ui/views/ime/input_method_base.h" | 13 #include "ui/views/ime/input_method_base.h" |
14 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 | 17 |
18 // A mock InputMethod implementation for testing purpose. | 18 // A mock InputMethod implementation for testing purpose. |
19 class VIEWS_EXPORT MockInputMethod : public InputMethodBase { | 19 class VIEWS_EXPORT MockInputMethod : public InputMethodBase { |
20 public: | 20 public: |
21 MockInputMethod(); | 21 MockInputMethod(); |
22 explicit MockInputMethod(internal::InputMethodDelegate* delegate); | 22 explicit MockInputMethod(internal::InputMethodDelegate* delegate); |
23 virtual ~MockInputMethod(); | 23 virtual ~MockInputMethod(); |
24 | 24 |
25 // Overridden from InputMethod: | 25 // Overridden from InputMethod: |
26 virtual void Init(Widget* widget) OVERRIDE; | 26 virtual void Init(Widget* widget) override; |
27 virtual void OnFocus() OVERRIDE; | 27 virtual void OnFocus() override; |
28 virtual void OnBlur() OVERRIDE; | 28 virtual void OnBlur() override; |
29 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, | 29 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event, |
30 NativeEventResult* result) OVERRIDE; | 30 NativeEventResult* result) override; |
31 virtual void DispatchKeyEvent(const ui::KeyEvent& key) OVERRIDE; | 31 virtual void DispatchKeyEvent(const ui::KeyEvent& key) override; |
32 virtual void OnTextInputTypeChanged(View* view) OVERRIDE; | 32 virtual void OnTextInputTypeChanged(View* view) override; |
33 virtual void OnCaretBoundsChanged(View* view) OVERRIDE; | 33 virtual void OnCaretBoundsChanged(View* view) override; |
34 virtual void CancelComposition(View* view) OVERRIDE; | 34 virtual void CancelComposition(View* view) override; |
35 virtual void OnInputLocaleChanged() OVERRIDE; | 35 virtual void OnInputLocaleChanged() override; |
36 virtual std::string GetInputLocale() OVERRIDE; | 36 virtual std::string GetInputLocale() override; |
37 virtual bool IsActive() OVERRIDE; | 37 virtual bool IsActive() override; |
38 virtual bool IsCandidatePopupOpen() const OVERRIDE; | 38 virtual bool IsCandidatePopupOpen() const override; |
39 virtual void ShowImeIfNeeded() OVERRIDE; | 39 virtual void ShowImeIfNeeded() override; |
40 virtual bool IsMock() const OVERRIDE; | 40 virtual bool IsMock() const override; |
41 | 41 |
42 bool focus_changed() const { return focus_changed_; } | 42 bool focus_changed() const { return focus_changed_; } |
43 bool untranslated_ime_message_called() const { | 43 bool untranslated_ime_message_called() const { |
44 return untranslated_ime_message_called_; | 44 return untranslated_ime_message_called_; |
45 } | 45 } |
46 bool text_input_type_changed() const { return text_input_type_changed_; } | 46 bool text_input_type_changed() const { return text_input_type_changed_; } |
47 bool caret_bounds_changed() const { return caret_bounds_changed_; } | 47 bool caret_bounds_changed() const { return caret_bounds_changed_; } |
48 bool cancel_composition_called() const { return cancel_composition_called_; } | 48 bool cancel_composition_called() const { return cancel_composition_called_; } |
49 bool input_locale_changed() const { return input_locale_changed_; } | 49 bool input_locale_changed() const { return input_locale_changed_; } |
50 | 50 |
51 // Clears all internal states and result. | 51 // Clears all internal states and result. |
52 void Clear(); | 52 void Clear(); |
53 | 53 |
54 void SetCompositionTextForNextKey(const ui::CompositionText& composition); | 54 void SetCompositionTextForNextKey(const ui::CompositionText& composition); |
55 void SetResultTextForNextKey(const base::string16& result); | 55 void SetResultTextForNextKey(const base::string16& result); |
56 | 56 |
57 void SetInputLocale(const std::string& locale); | 57 void SetInputLocale(const std::string& locale); |
58 void SetActive(bool active); | 58 void SetActive(bool active); |
59 | 59 |
60 private: | 60 private: |
61 // Overridden from InputMethodBase. | 61 // Overridden from InputMethodBase. |
62 virtual void OnWillChangeFocus(View* focused_before, View* focused) OVERRIDE; | 62 virtual void OnWillChangeFocus(View* focused_before, View* focused) override; |
63 | 63 |
64 // Clears boolean states defined below. | 64 // Clears boolean states defined below. |
65 void ClearStates(); | 65 void ClearStates(); |
66 | 66 |
67 // Clears only composition information and result text. | 67 // Clears only composition information and result text. |
68 void ClearResult(); | 68 void ClearResult(); |
69 | 69 |
70 // Composition information for the next key event. It'll be cleared | 70 // Composition information for the next key event. It'll be cleared |
71 // automatically after dispatching the next key event. | 71 // automatically after dispatching the next key event. |
72 ui::CompositionText composition_; | 72 ui::CompositionText composition_; |
(...skipping 15 matching lines...) Expand all Loading... |
88 // To mock corresponding input method prooperties. | 88 // To mock corresponding input method prooperties. |
89 std::string locale_; | 89 std::string locale_; |
90 bool active_; | 90 bool active_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(MockInputMethod); | 92 DISALLOW_COPY_AND_ASSIGN(MockInputMethod); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace views | 95 } // namespace views |
96 | 96 |
97 #endif // UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ | 97 #endif // UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ |
OLD | NEW |