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.cc

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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h"
6
7 #include <utility>
8
9 namespace chromeos {
10 namespace input_method {
11
12 MockInputMethodManagerImpl::State::State(MockInputMethodManagerImpl* manager)
13 : manager_(manager) {
14 active_input_method_ids.push_back("xkb:us::eng");
15 }
16
17 MockInputMethodManagerImpl::State::~State() {}
18
19 MockInputMethodManagerImpl::MockInputMethodManagerImpl()
20 : add_observer_count_(0),
21 remove_observer_count_(0),
22 state_(new State(this)),
23 util_(&delegate_),
24 mod3_used_(false) {}
25
26 MockInputMethodManagerImpl::~MockInputMethodManagerImpl() {}
27
28 void MockInputMethodManagerImpl::AddObserver(
29 InputMethodManager::Observer* observer) {
30 ++add_observer_count_;
31 }
32
33 void MockInputMethodManagerImpl::RemoveObserver(
34 InputMethodManager::Observer* observer) {
35 ++remove_observer_count_;
36 }
37
38 std::unique_ptr<InputMethodDescriptors>
39 MockInputMethodManagerImpl::GetSupportedInputMethods() const {
40 std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
41 result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor());
42 return result;
43 }
44
45 std::unique_ptr<InputMethodDescriptors>
46 MockInputMethodManagerImpl::State::GetActiveInputMethods() const {
47 std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
48 result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor());
49 return result;
50 }
51
52 const std::vector<std::string>&
53 MockInputMethodManagerImpl::State::GetActiveInputMethodIds() const {
54 return active_input_method_ids;
55 }
56
57 size_t MockInputMethodManagerImpl::State::GetNumActiveInputMethods() const {
58 return 1;
59 }
60
61 const InputMethodDescriptor*
62 MockInputMethodManagerImpl::State::GetInputMethodFromId(
63 const std::string& input_method_id) const {
64 static const InputMethodDescriptor defaultInputMethod =
65 InputMethodUtil::GetFallbackInputMethodDescriptor();
66 for (size_t i = 0; i < active_input_method_ids.size(); i++) {
67 if (input_method_id == active_input_method_ids[i]) {
68 return &defaultInputMethod;
69 }
70 }
71 return NULL;
72 }
73
74 void MockInputMethodManagerImpl::State::EnableLoginLayouts(
75 const std::string& language_code,
76 const std::vector<std::string>& initial_layout) {}
77
78 void MockInputMethodManagerImpl::State::EnableLockScreenLayouts() {}
79
80 bool MockInputMethodManagerImpl::State::ReplaceEnabledInputMethods(
81 const std::vector<std::string>& new_active_input_method_ids) {
82 return true;
83 }
stevenjb 2016/12/28 18:28:13 Any trivial methods like this should just be part
Azure Wei 2017/01/03 09:56:22 Done.
84
85 bool MockInputMethodManagerImpl::State::EnableInputMethod(
86 const std::string& new_active_input_method_id) {
87 return true;
88 }
89
90 void MockInputMethodManagerImpl::State::ChangeInputMethod(
91 const std::string& input_method_id,
92 bool show_message) {}
93
94 void MockInputMethodManagerImpl::State::AddInputMethodExtension(
95 const std::string& extension_id,
96 const InputMethodDescriptors& descriptors,
97 ui::IMEEngineHandlerInterface* instance) {}
98
99 void MockInputMethodManagerImpl::State::RemoveInputMethodExtension(
100 const std::string& extension_id) {}
101
102 void MockInputMethodManagerImpl::State::GetInputMethodExtensions(
103 InputMethodDescriptors* result) {}
104
105 void MockInputMethodManagerImpl::State::SetEnabledExtensionImes(
106 std::vector<std::string>* ids) {}
107
108 void MockInputMethodManagerImpl::State::SetInputMethodLoginDefault() {}
109
110 void MockInputMethodManagerImpl::State::SetInputMethodLoginDefaultFromVPD(
111 const std::string& locale,
112 const std::string& layout) {}
113
114 bool MockInputMethodManagerImpl::State::CanCycleInputMethod() {
115 return true;
116 }
117
118 void MockInputMethodManagerImpl::State::SwitchToNextInputMethod() {}
119
120 void MockInputMethodManagerImpl::State::SwitchToPreviousInputMethod() {}
121
122 bool MockInputMethodManagerImpl::State::CanSwitchInputMethod(
123 const ui::Accelerator& accelerator) {
124 return true;
125 }
126
127 void MockInputMethodManagerImpl::State::SwitchInputMethod(
128 const ui::Accelerator& accelerator) {}
129
130 InputMethodDescriptor MockInputMethodManagerImpl::State::GetCurrentInputMethod()
131 const {
132 InputMethodDescriptor descriptor =
133 InputMethodUtil::GetFallbackInputMethodDescriptor();
134 if (!current_input_method_id.empty()) {
135 return InputMethodDescriptor(
136 current_input_method_id, descriptor.name(), descriptor.indicator(),
137 descriptor.keyboard_layouts(), descriptor.language_codes(), true,
138 GURL(), // options page url.
139 GURL()); // input view page url.
140 }
141 return descriptor;
142 }
143
144 bool MockInputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod()
145 const {
146 return mod3_used_;
147 }
148
149 ImeKeyboard* MockInputMethodManagerImpl::GetImeKeyboard() {
150 return &keyboard_;
151 }
152
153 InputMethodUtil* MockInputMethodManagerImpl::GetInputMethodUtil() {
154 return &util_;
155 }
156
157 ComponentExtensionIMEManager*
158 MockInputMethodManagerImpl::GetComponentExtensionIMEManager() {
159 return comp_ime_manager_.get();
160 }
161
162 void MockInputMethodManagerImpl::SetComponentExtensionIMEManager(
163 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
164 comp_ime_manager_ = std::move(comp_ime_manager);
165 }
166
167 void MockInputMethodManagerImpl::set_application_locale(
168 const std::string& value) {
169 delegate_.set_active_locale(value);
170 }
171
172 scoped_refptr<InputMethodManager::State>
173 MockInputMethodManagerImpl::CreateNewState(Profile* profile) {
174 NOTIMPLEMENTED();
175 return state_;
176 }
177
178 scoped_refptr<InputMethodManager::State>
179 MockInputMethodManagerImpl::GetActiveIMEState() {
180 return scoped_refptr<InputMethodManager::State>(state_.get());
181 }
182
183 scoped_refptr<InputMethodManager::State>
184 MockInputMethodManagerImpl::State::Clone() const {
185 NOTIMPLEMENTED();
186 return manager_->GetActiveIMEState();
187 }
188
189 void MockInputMethodManagerImpl::SetState(
190 scoped_refptr<InputMethodManager::State> state) {
191 state_ = scoped_refptr<MockInputMethodManagerImpl::State>(
192 static_cast<MockInputMethodManagerImpl::State*>(state.get()));
193 }
194
195 void MockInputMethodManagerImpl::SetCurrentInputMethodId(
196 const std::string& input_method_id) {
197 state_->current_input_method_id = input_method_id;
198 }
199
200 } // namespace input_method
201 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698