Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ui/views/ime/mock_input_method.h

Issue 782673002: MacViews: tryjobs for toolkit_views=1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: latest crrev/901823002 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/ime/input_method_bridge.cc ('k') | ui/views/ime/mock_input_method.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ~MockInputMethod() override; 23 ~MockInputMethod() override;
24 24
25 // Overridden from InputMethod: 25 // Overridden from InputMethod:
26 void Init(Widget* widget) override;
27 void OnFocus() override; 26 void OnFocus() override;
28 void OnBlur() override; 27 void OnBlur() override;
29 bool OnUntranslatedIMEMessage(const base::NativeEvent& event, 28 bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
30 NativeEventResult* result) override; 29 NativeEventResult* result) override;
31 void DispatchKeyEvent(const ui::KeyEvent& key) override; 30 void DispatchKeyEvent(const ui::KeyEvent& key) override;
32 void OnTextInputTypeChanged(View* view) override; 31 void OnTextInputTypeChanged(View* view) override;
33 void OnCaretBoundsChanged(View* view) override; 32 void OnCaretBoundsChanged(View* view) override;
34 void CancelComposition(View* view) override; 33 void CancelComposition(View* view) override;
35 void OnInputLocaleChanged() override; 34 void OnInputLocaleChanged() override;
36 std::string GetInputLocale() override; 35 std::string GetInputLocale() override;
37 bool IsActive() override; 36 bool IsActive() override;
38 bool IsCandidatePopupOpen() const override; 37 bool IsCandidatePopupOpen() const override;
39 void ShowImeIfNeeded() override; 38 void ShowImeIfNeeded() override;
40 bool IsMock() const override; 39 bool IsMock() const override;
41 40
42 bool focus_changed() const { return focus_changed_; }
43 bool untranslated_ime_message_called() const { 41 bool untranslated_ime_message_called() const {
44 return untranslated_ime_message_called_; 42 return untranslated_ime_message_called_;
45 } 43 }
46 bool text_input_type_changed() const { return text_input_type_changed_; } 44 bool text_input_type_changed() const { return text_input_type_changed_; }
47 bool caret_bounds_changed() const { return caret_bounds_changed_; }
48 bool cancel_composition_called() const { return cancel_composition_called_; } 45 bool cancel_composition_called() const { return cancel_composition_called_; }
49 bool input_locale_changed() const { return input_locale_changed_; }
50 46
51 // Clears all internal states and result. 47 // Clears all internal states and result.
52 void Clear(); 48 void Clear();
53 49
54 void SetCompositionTextForNextKey(const ui::CompositionText& composition); 50 void SetCompositionTextForNextKey(const ui::CompositionText& composition);
55 void SetResultTextForNextKey(const base::string16& result); 51 void SetResultTextForNextKey(const base::string16& result);
56 52
57 void SetInputLocale(const std::string& locale); 53 // Insert a mock composition directly into the TextInputClient.
58 void SetActive(bool active); 54 void InsertMockComposition();
55 // Whether InsertMockComposition() would add a mock composition to the client.
56 bool HasMockComposition();
57 // Clear any mock composition.
58 void ClearMockComposition();
59 59
60 private: 60 private:
61 // Overridden from InputMethodBase. 61 // Overridden from InputMethodBase.
62 void OnWillChangeFocus(View* focused_before, View* focused) override; 62 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.
68 void ClearResult();
69
70 // Composition information for the next key event. It'll be cleared 67 // Composition information for the next key event. It'll be cleared
71 // automatically after dispatching the next key event. 68 // automatically after dispatching the next key event.
72 ui::CompositionText composition_; 69 ui::CompositionText composition_;
73 bool composition_changed_;
74 70
75 // Result text for the next key event. It'll be cleared automatically after 71 // Result text for the next key event. It'll be cleared automatically after
76 // dispatching the next key event. 72 // dispatching the next key event.
77 base::string16 result_text_; 73 base::string16 result_text_;
78 74
79 // Record call state of corresponding methods. They will be set to false 75 // Record call state of corresponding methods. They will be set to false
80 // automatically before dispatching a key event. 76 // automatically before dispatching a key event.
81 bool focus_changed_;
82 bool untranslated_ime_message_called_; 77 bool untranslated_ime_message_called_;
83 bool text_input_type_changed_; 78 bool text_input_type_changed_;
84 bool caret_bounds_changed_;
85 bool cancel_composition_called_; 79 bool cancel_composition_called_;
86 bool input_locale_changed_;
87
88 // To mock corresponding input method prooperties.
89 std::string locale_;
90 bool active_;
91 80
92 DISALLOW_COPY_AND_ASSIGN(MockInputMethod); 81 DISALLOW_COPY_AND_ASSIGN(MockInputMethod);
93 }; 82 };
94 83
95 } // namespace views 84 } // namespace views
96 85
97 #endif // UI_VIEWS_IME_MOCK_INPUT_METHOD_H_ 86 #endif // UI_VIEWS_IME_MOCK_INPUT_METHOD_H_
OLDNEW
« no previous file with comments | « ui/views/ime/input_method_bridge.cc ('k') | ui/views/ime/mock_input_method.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698