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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | 5 #ifndef UI_BASE_IME_CHROMEOS_MOCK_INPUT_METHOD_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | 6 #define UI_BASE_IME_CHROMEOS_MOCK_INPUT_METHOD_MANAGER_H_ |
7 | |
8 #include <stddef.h> | |
9 | 7 |
10 #include "base/macros.h" | 8 #include "base/macros.h" |
11 #include "chrome/browser/chromeos/input_method/input_method_util.h" | |
12 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" | |
13 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" | |
14 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" | |
15 #include "ui/base/ime/chromeos/input_method_manager.h" | 9 #include "ui/base/ime/chromeos/input_method_manager.h" |
16 #include "ui/base/ime/chromeos/input_method_whitelist.h" | |
17 | 10 |
18 namespace chromeos { | 11 namespace chromeos { |
19 namespace input_method { | 12 namespace input_method { |
| 13 class InputMethodUtil; |
| 14 class ImeKeyboard; |
20 | 15 |
21 // The mock implementation of InputMethodManager for testing. | 16 // The mock InputMethodManager for testing. |
22 class MockInputMethodManager : public InputMethodManager { | 17 class UI_BASE_IME_EXPORT MockInputMethodManager : public InputMethodManager { |
| 18 public: |
23 public: | 19 public: |
24 class State : public InputMethodManager::State { | 20 class State : public InputMethodManager::State { |
25 public: | 21 public: |
26 explicit State(MockInputMethodManager* manager); | 22 State(); |
27 | 23 |
28 scoped_refptr<InputMethodManager::State> Clone() const override; | |
29 void AddInputMethodExtension( | 24 void AddInputMethodExtension( |
30 const std::string& extension_id, | 25 const std::string& extension_id, |
31 const InputMethodDescriptors& descriptors, | 26 const InputMethodDescriptors& descriptors, |
32 ui::IMEEngineHandlerInterface* instance) override; | 27 ui::IMEEngineHandlerInterface* instance) override; |
33 void RemoveInputMethodExtension(const std::string& extension_id) override; | 28 void RemoveInputMethodExtension(const std::string& extension_id) override; |
34 void ChangeInputMethod(const std::string& input_method_id, | 29 void ChangeInputMethod(const std::string& input_method_id, |
35 bool show_message) override; | 30 bool show_message) override; |
36 bool EnableInputMethod( | 31 bool EnableInputMethod( |
37 const std::string& new_active_input_method_id) override; | 32 const std::string& new_active_input_method_id) override; |
38 void EnableLoginLayouts( | 33 void EnableLoginLayouts( |
(...skipping 13 matching lines...) Expand all Loading... |
52 const std::string& layout) override; | 47 const std::string& layout) override; |
53 bool CanCycleInputMethod() override; | 48 bool CanCycleInputMethod() override; |
54 void SwitchToNextInputMethod() override; | 49 void SwitchToNextInputMethod() override; |
55 void SwitchToPreviousInputMethod() override; | 50 void SwitchToPreviousInputMethod() override; |
56 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override; | 51 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override; |
57 void SwitchInputMethod(const ui::Accelerator& accelerator) override; | 52 void SwitchInputMethod(const ui::Accelerator& accelerator) override; |
58 InputMethodDescriptor GetCurrentInputMethod() const override; | 53 InputMethodDescriptor GetCurrentInputMethod() const override; |
59 bool ReplaceEnabledInputMethods( | 54 bool ReplaceEnabledInputMethods( |
60 const std::vector<std::string>& new_active_input_method_ids) override; | 55 const std::vector<std::string>& new_active_input_method_ids) override; |
61 | 56 |
62 // The value GetCurrentInputMethod().id() will return. | |
63 std::string current_input_method_id; | |
64 | |
65 // The active input method ids cache (actually default only) | 57 // The active input method ids cache (actually default only) |
66 std::vector<std::string> active_input_method_ids; | 58 std::vector<std::string> active_input_method_ids; |
67 | 59 |
68 protected: | 60 protected: |
69 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; | 61 friend base::RefCounted<InputMethodManager::State>; |
70 ~State() override; | 62 ~State() override; |
71 | 63 |
72 MockInputMethodManager* const manager_; | 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(State); |
73 }; | 66 }; |
74 | 67 |
75 MockInputMethodManager(); | 68 MockInputMethodManager(); |
76 ~MockInputMethodManager() override; | 69 ~MockInputMethodManager() override; |
77 | 70 |
78 // InputMethodManager override: | 71 // InputMethodManager override: |
79 UISessionState GetUISessionState() override; | 72 UISessionState GetUISessionState() override; |
80 void AddObserver(InputMethodManager::Observer* observer) override; | 73 void AddObserver(InputMethodManager::Observer* observer) override; |
81 void AddCandidateWindowObserver( | 74 void AddCandidateWindowObserver( |
82 InputMethodManager::CandidateWindowObserver* observer) override; | 75 InputMethodManager::CandidateWindowObserver* observer) override; |
(...skipping 19 matching lines...) Expand all Loading... |
102 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; | 95 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; |
103 void SetState(scoped_refptr<InputMethodManager::State> state) override; | 96 void SetState(scoped_refptr<InputMethodManager::State> state) override; |
104 void ImeMenuActivationChanged(bool is_active) override; | 97 void ImeMenuActivationChanged(bool is_active) override; |
105 void NotifyImeMenuItemsChanged( | 98 void NotifyImeMenuItemsChanged( |
106 const std::string& engine_id, | 99 const std::string& engine_id, |
107 const std::vector<InputMethodManager::MenuItem>& items) override; | 100 const std::vector<InputMethodManager::MenuItem>& items) override; |
108 void MaybeNotifyImeMenuActivationChanged() override; | 101 void MaybeNotifyImeMenuActivationChanged() override; |
109 void OverrideKeyboardUrlRef(const std::string& keyset) override; | 102 void OverrideKeyboardUrlRef(const std::string& keyset) override; |
110 bool IsEmojiHandwritingVoiceOnImeMenuEnabled() override; | 103 bool IsEmojiHandwritingVoiceOnImeMenuEnabled() override; |
111 | 104 |
112 // Sets an input method ID which will be returned by GetCurrentInputMethod(). | |
113 void SetCurrentInputMethodId(const std::string& input_method_id); | |
114 | |
115 void SetComponentExtensionIMEManager( | |
116 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager); | |
117 | |
118 // Set values that will be provided to the InputMethodUtil. | |
119 void set_application_locale(const std::string& value); | |
120 | |
121 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod | |
122 void set_mod3_used(bool value) { mod3_used_ = value; } | |
123 | |
124 // TODO(yusukes): Add more variables for counting the numbers of the API calls | |
125 int add_observer_count_; | |
126 int remove_observer_count_; | |
127 | |
128 protected: | |
129 scoped_refptr<State> state_; | |
130 | |
131 private: | 105 private: |
132 FakeInputMethodDelegate delegate_; // used by util_ | |
133 InputMethodUtil util_; | |
134 FakeImeKeyboard keyboard_; | |
135 bool mod3_used_; | |
136 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager_; | |
137 | |
138 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); | 106 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); |
139 }; | 107 }; |
140 | 108 |
141 } // namespace input_method | 109 } // namespace input_method |
142 } // namespace chromeos | 110 } // namespace chromeos |
143 | 111 |
144 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | 112 #endif // UI_BASE_IME_CHROMEOS_MOCK_INPUT_METHOD_MANAGER_H_ |
OLD | NEW |