| 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 8 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 9 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" | 9 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" |
| 10 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" | 10 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" |
| 11 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" | 11 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" |
| 12 #include "ui/base/ime/chromeos/input_method_manager.h" | 12 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 13 #include "ui/base/ime/chromeos/input_method_whitelist.h" | 13 #include "ui/base/ime/chromeos/input_method_whitelist.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 namespace input_method { | 16 namespace input_method { |
| 17 | 17 |
| 18 // The mock implementation of InputMethodManager for testing. | 18 // The mock implementation of InputMethodManager for testing. |
| 19 class MockInputMethodManager : public InputMethodManager { | 19 class MockInputMethodManager : public InputMethodManager { |
| 20 public: | 20 public: |
| 21 class State : public InputMethodManager::State { | 21 class State : public InputMethodManager::State { |
| 22 public: | 22 public: |
| 23 explicit State(MockInputMethodManager* manager); | 23 explicit State(MockInputMethodManager* manager); |
| 24 | 24 |
| 25 virtual scoped_refptr<InputMethodManager::State> Clone() const override; | 25 scoped_refptr<InputMethodManager::State> Clone() const override; |
| 26 virtual void AddInputMethodExtension( | 26 void AddInputMethodExtension(const std::string& extension_id, |
| 27 const std::string& extension_id, | 27 const InputMethodDescriptors& descriptors, |
| 28 const InputMethodDescriptors& descriptors, | 28 InputMethodEngineInterface* instance) override; |
| 29 InputMethodEngineInterface* instance) override; | 29 void RemoveInputMethodExtension(const std::string& extension_id) override; |
| 30 virtual void RemoveInputMethodExtension( | 30 void ChangeInputMethod(const std::string& input_method_id, |
| 31 const std::string& extension_id) override; | 31 bool show_message) override; |
| 32 virtual void ChangeInputMethod(const std::string& input_method_id, | 32 bool EnableInputMethod( |
| 33 bool show_message) override; | |
| 34 virtual bool EnableInputMethod( | |
| 35 const std::string& new_active_input_method_id) override; | 33 const std::string& new_active_input_method_id) override; |
| 36 virtual void EnableLoginLayouts( | 34 void EnableLoginLayouts( |
| 37 const std::string& language_code, | 35 const std::string& language_code, |
| 38 const std::vector<std::string>& initial_layouts) override; | 36 const std::vector<std::string>& initial_layouts) override; |
| 39 virtual void EnableLockScreenLayouts() override; | 37 void EnableLockScreenLayouts() override; |
| 40 virtual void GetInputMethodExtensions( | 38 void GetInputMethodExtensions(InputMethodDescriptors* result) override; |
| 41 InputMethodDescriptors* result) override; | 39 scoped_ptr<InputMethodDescriptors> GetActiveInputMethods() const override; |
| 42 virtual scoped_ptr<InputMethodDescriptors> GetActiveInputMethods() | 40 const std::vector<std::string>& GetActiveInputMethodIds() const override; |
| 43 const override; | 41 const InputMethodDescriptor* GetInputMethodFromId( |
| 44 virtual const std::vector<std::string>& GetActiveInputMethodIds() | |
| 45 const override; | |
| 46 virtual const InputMethodDescriptor* GetInputMethodFromId( | |
| 47 const std::string& input_method_id) const override; | 42 const std::string& input_method_id) const override; |
| 48 virtual size_t GetNumActiveInputMethods() const override; | 43 size_t GetNumActiveInputMethods() const override; |
| 49 virtual void SetEnabledExtensionImes( | 44 void SetEnabledExtensionImes(std::vector<std::string>* ids) override; |
| 50 std::vector<std::string>* ids) override; | 45 void SetInputMethodLoginDefault() override; |
| 51 virtual void SetInputMethodLoginDefault() override; | 46 void SetInputMethodLoginDefaultFromVPD(const std::string& locale, |
| 52 virtual void SetInputMethodLoginDefaultFromVPD( | 47 const std::string& layout) override; |
| 53 const std::string& locale, | 48 bool CanCycleInputMethod() override; |
| 54 const std::string& layout) override; | 49 void SwitchToNextInputMethod() override; |
| 55 virtual bool CanCycleInputMethod() override; | 50 void SwitchToPreviousInputMethod() override; |
| 56 virtual void SwitchToNextInputMethod() override; | 51 bool CanSwitchInputMethod(const ui::Accelerator& accelerator) override; |
| 57 virtual void SwitchToPreviousInputMethod() override; | 52 void SwitchInputMethod(const ui::Accelerator& accelerator) override; |
| 58 virtual bool CanSwitchInputMethod( | 53 InputMethodDescriptor GetCurrentInputMethod() const override; |
| 59 const ui::Accelerator& accelerator) override; | 54 bool ReplaceEnabledInputMethods( |
| 60 virtual void SwitchInputMethod(const ui::Accelerator& accelerator) override; | |
| 61 virtual InputMethodDescriptor GetCurrentInputMethod() const override; | |
| 62 virtual bool ReplaceEnabledInputMethods( | |
| 63 const std::vector<std::string>& new_active_input_method_ids) override; | 55 const std::vector<std::string>& new_active_input_method_ids) override; |
| 64 | 56 |
| 65 // The value GetCurrentInputMethod().id() will return. | 57 // The value GetCurrentInputMethod().id() will return. |
| 66 std::string current_input_method_id; | 58 std::string current_input_method_id; |
| 67 | 59 |
| 68 // The active input method ids cache (actually default only) | 60 // The active input method ids cache (actually default only) |
| 69 std::vector<std::string> active_input_method_ids; | 61 std::vector<std::string> active_input_method_ids; |
| 70 | 62 |
| 71 protected: | 63 protected: |
| 72 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; | 64 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; |
| 73 virtual ~State(); | 65 ~State() override; |
| 74 | 66 |
| 75 MockInputMethodManager* const manager_; | 67 MockInputMethodManager* const manager_; |
| 76 }; | 68 }; |
| 77 | 69 |
| 78 MockInputMethodManager(); | 70 MockInputMethodManager(); |
| 79 virtual ~MockInputMethodManager(); | 71 ~MockInputMethodManager() override; |
| 80 | 72 |
| 81 // InputMethodManager override: | 73 // InputMethodManager override: |
| 82 virtual UISessionState GetUISessionState() override; | 74 UISessionState GetUISessionState() override; |
| 83 virtual void AddObserver(InputMethodManager::Observer* observer) override; | 75 void AddObserver(InputMethodManager::Observer* observer) override; |
| 84 virtual void AddCandidateWindowObserver( | 76 void AddCandidateWindowObserver( |
| 85 InputMethodManager::CandidateWindowObserver* observer) override; | 77 InputMethodManager::CandidateWindowObserver* observer) override; |
| 86 virtual void RemoveObserver(InputMethodManager::Observer* observer) override; | 78 void RemoveObserver(InputMethodManager::Observer* observer) override; |
| 87 virtual void RemoveCandidateWindowObserver( | 79 void RemoveCandidateWindowObserver( |
| 88 InputMethodManager::CandidateWindowObserver* observer) override; | 80 InputMethodManager::CandidateWindowObserver* observer) override; |
| 89 virtual scoped_ptr<InputMethodDescriptors> | 81 scoped_ptr<InputMethodDescriptors> GetSupportedInputMethods() const override; |
| 90 GetSupportedInputMethods() const override; | 82 void ActivateInputMethodMenuItem(const std::string& key) override; |
| 91 virtual void ActivateInputMethodMenuItem(const std::string& key) override; | 83 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; |
| 92 virtual bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; | 84 bool IsAltGrUsedByCurrentInputMethod() const override; |
| 93 virtual bool IsAltGrUsedByCurrentInputMethod() const override; | 85 ImeKeyboard* GetImeKeyboard() override; |
| 94 virtual ImeKeyboard* GetImeKeyboard() override; | 86 InputMethodUtil* GetInputMethodUtil() override; |
| 95 virtual InputMethodUtil* GetInputMethodUtil() override; | 87 ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override; |
| 96 virtual ComponentExtensionIMEManager* | 88 bool IsLoginKeyboard(const std::string& layout) const override; |
| 97 GetComponentExtensionIMEManager() override; | 89 bool MigrateInputMethods(std::vector<std::string>* input_method_ids) override; |
| 98 virtual bool IsLoginKeyboard(const std::string& layout) const override; | 90 scoped_refptr<InputMethodManager::State> CreateNewState( |
| 99 virtual bool MigrateInputMethods( | |
| 100 std::vector<std::string>* input_method_ids) override; | |
| 101 virtual scoped_refptr<InputMethodManager::State> CreateNewState( | |
| 102 Profile* profile) override; | 91 Profile* profile) override; |
| 103 virtual scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; | 92 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; |
| 104 virtual void SetState( | 93 void SetState(scoped_refptr<InputMethodManager::State> state) override; |
| 105 scoped_refptr<InputMethodManager::State> state) override; | |
| 106 | 94 |
| 107 // Sets an input method ID which will be returned by GetCurrentInputMethod(). | 95 // Sets an input method ID which will be returned by GetCurrentInputMethod(). |
| 108 void SetCurrentInputMethodId(const std::string& input_method_id); | 96 void SetCurrentInputMethodId(const std::string& input_method_id); |
| 109 | 97 |
| 110 void SetComponentExtensionIMEManager( | 98 void SetComponentExtensionIMEManager( |
| 111 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager); | 99 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager); |
| 112 | 100 |
| 113 // Set values that will be provided to the InputMethodUtil. | 101 // Set values that will be provided to the InputMethodUtil. |
| 114 void set_application_locale(const std::string& value); | 102 void set_application_locale(const std::string& value); |
| 115 | 103 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 130 bool mod3_used_; | 118 bool mod3_used_; |
| 131 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_; | 119 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager_; |
| 132 | 120 |
| 133 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); | 121 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); |
| 134 }; | 122 }; |
| 135 | 123 |
| 136 } // namespace input_method | 124 } // namespace input_method |
| 137 } // namespace chromeos | 125 } // namespace chromeos |
| 138 | 126 |
| 139 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ | 127 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ |
| OLD | NEW |