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

Side by Side Diff: chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h

Issue 2605843002: Add MockInputMethodManager under ui/base/ime/chromeos/ (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "chrome/browser/chromeos/input_method/input_method_util.h" 11 #include "chrome/browser/chromeos/input_method/input_method_util.h"
stevenjb 2016/12/28 18:28:13 FWIW, this appears to be the only Chrome dependenc
Azure Wei 2017/01/03 09:56:22 Done. Used unique_ptr and forward declared for Inp
12 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" 12 #include "ui/base/ime/chromeos/component_extension_ime_manager.h"
13 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" 13 #include "ui/base/ime/chromeos/fake_ime_keyboard.h"
14 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" 14 #include "ui/base/ime/chromeos/fake_input_method_delegate.h"
15 #include "ui/base/ime/chromeos/input_method_manager.h" 15 #include "ui/base/ime/chromeos/input_method_manager.h"
16 #include "ui/base/ime/chromeos/input_method_whitelist.h" 16 #include "ui/base/ime/chromeos/input_method_whitelist.h"
17 #include "ui/base/ime/chromeos/mock_input_method_manager.h"
17 18
18 namespace chromeos { 19 namespace chromeos {
19 namespace input_method { 20 namespace input_method {
20 21
21 // The mock implementation of InputMethodManager for testing. 22 // The mock implementation of InputMethodManager for testing.
22 class MockInputMethodManager : public InputMethodManager { 23 class MockInputMethodManagerImpl : public MockInputMethodManager {
23 public: 24 public:
24 class State : public InputMethodManager::State { 25 class State : public InputMethodManager::State {
25 public: 26 public:
26 explicit State(MockInputMethodManager* manager); 27 explicit State(MockInputMethodManagerImpl* manager);
27 28
28 scoped_refptr<InputMethodManager::State> Clone() const override; 29 scoped_refptr<InputMethodManager::State> Clone() const override;
29 void AddInputMethodExtension( 30 void AddInputMethodExtension(
30 const std::string& extension_id, 31 const std::string& extension_id,
31 const InputMethodDescriptors& descriptors, 32 const InputMethodDescriptors& descriptors,
32 ui::IMEEngineHandlerInterface* instance) override; 33 ui::IMEEngineHandlerInterface* instance) override;
33 void RemoveInputMethodExtension(const std::string& extension_id) override; 34 void RemoveInputMethodExtension(const std::string& extension_id) override;
34 void ChangeInputMethod(const std::string& input_method_id, 35 void ChangeInputMethod(const std::string& input_method_id,
35 bool show_message) override; 36 bool show_message) override;
36 bool EnableInputMethod( 37 bool EnableInputMethod(
(...skipping 28 matching lines...) Expand all
65 // The active input method ids cache (actually default only) 66 // The active input method ids cache (actually default only)
66 std::vector<std::string> active_input_method_ids; 67 std::vector<std::string> active_input_method_ids;
67 68
68 protected: 69 protected:
69 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>; 70 friend base::RefCounted<chromeos::input_method::InputMethodManager::State>;
70 ~State() override; 71 ~State() override;
71 72
72 MockInputMethodManager* const manager_; 73 MockInputMethodManager* const manager_;
73 }; 74 };
74 75
75 MockInputMethodManager(); 76 MockInputMethodManagerImpl();
76 ~MockInputMethodManager() override; 77 ~MockInputMethodManagerImpl() override;
77 78
78 // InputMethodManager override: 79 // MockInputMethodManager:
79 UISessionState GetUISessionState() override;
80 void AddObserver(InputMethodManager::Observer* observer) 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; 81 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() 82 std::unique_ptr<InputMethodDescriptors> GetSupportedInputMethods()
91 const override; 83 const override;
92 void ActivateInputMethodMenuItem(const std::string& key) override;
93 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override; 84 bool IsISOLevel5ShiftUsedByCurrentInputMethod() const override;
94 bool IsAltGrUsedByCurrentInputMethod() const override;
95 ImeKeyboard* GetImeKeyboard() override; 85 ImeKeyboard* GetImeKeyboard() override;
96 InputMethodUtil* GetInputMethodUtil() override; 86 InputMethodUtil* GetInputMethodUtil() override;
97 ComponentExtensionIMEManager* GetComponentExtensionIMEManager() override; 87 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( 88 scoped_refptr<InputMethodManager::State> CreateNewState(
101 Profile* profile) override; 89 Profile* profile) override;
102 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override; 90 scoped_refptr<InputMethodManager::State> GetActiveIMEState() override;
103 void SetState(scoped_refptr<InputMethodManager::State> state) override; 91 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 92
112 // Sets an input method ID which will be returned by GetCurrentInputMethod(). 93 // Sets an input method ID which will be returned by GetCurrentInputMethod().
113 void SetCurrentInputMethodId(const std::string& input_method_id); 94 void SetCurrentInputMethodId(const std::string& input_method_id);
114 95
115 void SetComponentExtensionIMEManager( 96 void SetComponentExtensionIMEManager(
116 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager); 97 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager);
117 98
118 // Set values that will be provided to the InputMethodUtil. 99 // Set values that will be provided to the InputMethodUtil.
119 void set_application_locale(const std::string& value); 100 void set_application_locale(const std::string& value);
120 101
121 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod 102 // Set the value returned by IsISOLevel5ShiftUsedByCurrentInputMethod
122 void set_mod3_used(bool value) { mod3_used_ = value; } 103 void set_mod3_used(bool value) { mod3_used_ = value; }
123 104
124 // TODO(yusukes): Add more variables for counting the numbers of the API calls 105 // TODO(yusukes): Add more variables for counting the numbers of the API calls
125 int add_observer_count_; 106 int add_observer_count_;
126 int remove_observer_count_; 107 int remove_observer_count_;
127 108
128 protected: 109 protected:
129 scoped_refptr<State> state_; 110 scoped_refptr<State> state_;
130 111
131 private: 112 private:
132 FakeInputMethodDelegate delegate_; // used by util_ 113 FakeInputMethodDelegate delegate_; // used by util_
133 InputMethodUtil util_; 114 InputMethodUtil util_;
134 FakeImeKeyboard keyboard_; 115 FakeImeKeyboard keyboard_;
135 bool mod3_used_; 116 bool mod3_used_;
136 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager_; 117 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager_;
137 118
138 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManager); 119 DISALLOW_COPY_AND_ASSIGN(MockInputMethodManagerImpl);
139 }; 120 };
140 121
141 } // namespace input_method 122 } // namespace input_method
142 } // namespace chromeos 123 } // namespace chromeos
143 124
144 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_H_ 125 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_IMPL_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698