| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #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" | |
| 16 #include "ui/base/ime/chromeos/input_method_whitelist.h" | |
| 17 | |
| 18 namespace chromeos { | |
| 19 namespace input_method { | |
| 20 | |
| 21 // The mock implementation of InputMethodManager for testing. | |
| 22 class MockInputMethodManager : public InputMethodManager { | |
| 23 public: | |
| 24 class State : public InputMethodManager::State { | |
| 25 public: | |
| 26 explicit State(MockInputMethodManager* manager); | |
| 27 | |
| 28 scoped_refptr<InputMethodManager::State> Clone() const override; | |
| 29 void AddInputMethodExtension( | |
| 30 const std::string& extension_id, | |
| 31 const InputMethodDescriptors& descriptors, | |
| 32 ui::IMEEngineHandlerInterface* instance) override; | |
| 33 void RemoveInputMethodExtension(const std::string& extension_id) override; | |
| 34 void ChangeInputMethod(const std::string& input_method_id, | |
| 35 bool show_message) override; | |
| 36 bool EnableInputMethod( | |
| 37 const std::string& new_active_input_method_id) override; | |
| 38 void EnableLoginLayouts( | |
| 39 const std::string& language_code, | |
| 40 const std::vector<std::string>& initial_layouts) override; | |
| 41 void EnableLockScreenLayouts() override; | |
| 42 void GetInputMethodExtensions(InputMethodDescriptors* result) override; | |
| 43 std::unique_ptr<InputMethodDescriptors> GetActiveInputMethods() | |
| 44 const override; | |
| 45 const std::vector<std::string>& GetActiveInputMethodIds() const override; | |
| 46 const InputMethodDescriptor* GetInputMethodFromId( | |
| 47 const std::string& input_method_id) const override; | |
| 48 size_t GetNumActiveInputMethods() const override; | |
| 49 void SetEnabledExtensionImes(std::vector<std::string>* ids) override; | |
| 50 void SetInputMethodLoginDefault() override; | |
| 51 void SetInputMethodLoginDefaultFromVPD(const std::string& locale, | |
| 52 const std::string& layout) override; | |
| 53 bool CanCycleInputMethod() override; | |
| 54 void SwitchToNextInputMethod() override; | |
| 55 void SwitchToPreviousInputMethod() override; | |
| 56 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override; | |
| 57 void SwitchInputMethod(const ui::Accelerator& accelerator) override; | |
| 58 InputMethodDescriptor GetCurrentInputMethod() const override; | |
| 59 bool ReplaceEnabledInputMethods( | |
| 60 const std::vector<std::string>& new_active_input_method_ids) override; | |
| 61 | |
| 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) | |
| 66 std::vector<std::string> active_input_method_ids; | |
| 67 | |
| 68 protected: | |
| 69 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; | |
| 70 ~State() override; | |
| 71 | |
| 72 MockInputMethodManager* const manager_; | |
| 73 }; | |
| 74 | |
| 75 MockInputMethodManager(); | |
| 76 ~MockInputMethodManager() override; | |
| 77 | |
| 78 // InputMethodManager override: | |
| 79 UISessionState GetUISessionState() override; | |
| 80 void AddObserver(InputMethodManager::Observer* observer) override; | |
| 81 void AddCandidateWindowObserver( | |
| 82 InputMethodManager::CandidateWindowObserver* observer) override; | |
| 83 void AddImeMenuObserver( | |
| 84 InputMethodManager::ImeMenuObserver* observer) override; | |
| 85 void RemoveObserver(InputMethodManager::Observer* observer) override; | |
| 86 void RemoveCandidateWindowObserver( | |
| 87 InputMethodManager::CandidateWindowObserver* observer) override; | |
| 88 void RemoveImeMenuObserver( | |
| 89 InputMethodManager::ImeMenuObserver* observer) override; | |
| 90 std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods() | |
| 91 const override; | |
| 92 void ActivateInputMethodMenuItem(const std::string& key) override; | |
| 93 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; | |
| 94 bool IsAltGrUsedByCurrentInputMethod() const override; | |
| 95 ImeKeyboard* GetImeKeyboard() override; | |
| 96 InputMethodUtil* GetInputMethodUtil() override; | |
| 97 ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override; | |
| 98 bool IsLoginKeyboard(const std::string& layout) const override; | |
| 99 bool MigrateInputMethods(std::vector<std::string>* input_method_ids) override; | |
| 100 scoped_refptr<InputMethodManager::State> CreateNewState( | |
| 101 Profile* profile) override; | |
| 102 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; | |
| 103 void SetState(scoped_refptr<InputMethodManager::State> state) override; | |
| 104 void ImeMenuActivationChanged(bool is_active) override; | |
| 105 void NotifyImeMenuItemsChanged( | |
| 106 const std::string& engine_id, | |
| 107 const std::vector<InputMethodManager::MenuItem>& items) override; | |
| 108 void MaybeNotifyImeMenuActivationChanged() override; | |
| 109 void OverrideKeyboardUrlRef(const std::string& keyset) override; | |
| 110 bool IsEmojiHandwritingVoiceOnImeMenuEnabled() override; | |
| 111 | |
| 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: | |
| 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); | |
| 139 }; | |
| 140 | |
| 141 } // namespace input_method | |
| 142 } // namespace chromeos | |
| 143 | |
| 144 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | |
| OLD | NEW |