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 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
6
7 namespace chromeos {
8 namespace input_method {
9
MockInputMethodManager()10 MockInputMethodManager::MockInputMethodManager()
11 : add_observer_count_(0),
12 remove_observer_count_(0),
13 util_(&delegate_, whitelist_.GetSupportedInputMethods()),
14 mod3_used_(false) {
15 active_input_method_ids_.push_back("xkb:us::eng");
16 }
17
~MockInputMethodManager()18 MockInputMethodManager::~MockInputMethodManager() {
19 }
20
AddObserver(InputMethodManager::Observer * observer)21 void MockInputMethodManager::AddObserver(
22 InputMethodManager::Observer* observer) {
23 ++add_observer_count_;
24 }
25
AddCandidateWindowObserver(InputMethodManager::CandidateWindowObserver * observer)26 void MockInputMethodManager::AddCandidateWindowObserver(
27 InputMethodManager::CandidateWindowObserver* observer) {
28 }
29
RemoveObserver(InputMethodManager::Observer * observer)30 void MockInputMethodManager::RemoveObserver(
31 InputMethodManager::Observer* observer) {
32 ++remove_observer_count_;
33 }
34
RemoveCandidateWindowObserver(InputMethodManager::CandidateWindowObserver * observer)35 void MockInputMethodManager::RemoveCandidateWindowObserver(
36 InputMethodManager::CandidateWindowObserver* observer) {
37 }
38
39 scoped_ptr<InputMethodDescriptors>
GetSupportedInputMethods() const40 MockInputMethodManager::GetSupportedInputMethods() const {
41 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
42 result->push_back(
43 InputMethodUtil::GetFallbackInputMethodDescriptor());
44 return result.Pass();
45 }
46
47 scoped_ptr<InputMethodDescriptors>
GetActiveInputMethods() const48 MockInputMethodManager::GetActiveInputMethods() const {
49 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
50 result->push_back(
51 InputMethodUtil::GetFallbackInputMethodDescriptor());
52 return result.Pass();
53 }
54
55 const std::vector<std::string>&
GetActiveInputMethodIds() const56 MockInputMethodManager::GetActiveInputMethodIds() const {
57 return active_input_method_ids_;
58 }
59
GetNumActiveInputMethods() const60 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
61 return 1;
62 }
63
GetInputMethodFromId(const std::string & input_method_id) const64 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
65 const std::string& input_method_id) const {
66 static const InputMethodDescriptor defaultInputMethod =
67 InputMethodUtil::GetFallbackInputMethodDescriptor();
68 for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
69 if (input_method_id == active_input_method_ids_[i]) {
70 return &defaultInputMethod;
71 }
72 }
73 return NULL;
74 }
75
EnableLoginLayouts(const std::string & language_code,const std::vector<std::string> & initial_layout)76 void MockInputMethodManager::EnableLoginLayouts(
77 const std::string& language_code,
78 const std::vector<std::string>& initial_layout) {
79 }
80
ReplaceEnabledInputMethods(const std::vector<std::string> & new_active_input_method_ids)81 bool MockInputMethodManager::ReplaceEnabledInputMethods(
82 const std::vector<std::string>& new_active_input_method_ids) {
83 return true;
84 }
85
EnableInputMethod(const std::string & new_active_input_method_id)86 bool MockInputMethodManager::EnableInputMethod(
87 const std::string& new_active_input_method_id) {
88 return true;
89 }
90
ChangeInputMethod(const std::string & input_method_id)91 void MockInputMethodManager::ChangeInputMethod(
92 const std::string& input_method_id) {
93 }
94
ActivateInputMethodMenuItem(const std::string & key)95 void MockInputMethodManager::ActivateInputMethodMenuItem(
96 const std::string& key) {
97 }
98
AddInputMethodExtension(Profile * profile,const std::string & id,InputMethodEngineInterface * instance)99 void MockInputMethodManager::AddInputMethodExtension(
100 Profile* profile,
101 const std::string& id,
102 InputMethodEngineInterface* instance) {
103 }
104
RemoveInputMethodExtension(Profile * profile,const std::string & id)105 void MockInputMethodManager::RemoveInputMethodExtension(Profile* profile,
106 const std::string& id) {
107 }
108
GetInputMethodExtensions(InputMethodDescriptors * result)109 void MockInputMethodManager::GetInputMethodExtensions(
110 InputMethodDescriptors* result) {
111 }
112
SetEnabledExtensionImes(std::vector<std::string> * ids)113 void MockInputMethodManager::SetEnabledExtensionImes(
114 std::vector<std::string>* ids) {
115 }
116
SetInputMethodLoginDefault()117 void MockInputMethodManager::SetInputMethodLoginDefault() {
118 }
119
SetInputMethodLoginDefaultFromVPD(const std::string & locale,const std::string & layout)120 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD(
121 const std::string& locale, const std::string& layout) {
122 }
123
SwitchToNextInputMethod()124 bool MockInputMethodManager::SwitchToNextInputMethod() {
125 return true;
126 }
127
SwitchToPreviousInputMethod(const ui::Accelerator & accelerator)128 bool MockInputMethodManager::SwitchToPreviousInputMethod(
129 const ui::Accelerator& accelerator) {
130 return true;
131 }
132
SwitchInputMethod(const ui::Accelerator & accelerator)133 bool MockInputMethodManager::SwitchInputMethod(
134 const ui::Accelerator& accelerator) {
135 return true;
136 }
137
GetCurrentInputMethod() const138 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
139 InputMethodDescriptor descriptor =
140 InputMethodUtil::GetFallbackInputMethodDescriptor();
141 if (!current_input_method_id_.empty()) {
142 return InputMethodDescriptor(current_input_method_id_,
143 descriptor.name(),
144 descriptor.indicator(),
145 descriptor.keyboard_layouts(),
146 descriptor.language_codes(),
147 true,
148 GURL(), // options page url.
149 GURL()); // input view page url.
150 }
151 return descriptor;
152 }
153
IsISOLevel5ShiftUsedByCurrentInputMethod() const154 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
155 return mod3_used_;
156 }
157
IsAltGrUsedByCurrentInputMethod() const158 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
159 return false;
160 }
161
GetImeKeyboard()162 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
163
GetInputMethodUtil()164 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
165 return &util_;
166 }
167
168 ComponentExtensionIMEManager*
GetComponentExtensionIMEManager()169 MockInputMethodManager::GetComponentExtensionIMEManager() {
170 return comp_ime_manager_.get();
171 }
172
SetComponentExtensionIMEManager(scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager)173 void MockInputMethodManager::SetComponentExtensionIMEManager(
174 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
175 comp_ime_manager_ = comp_ime_manager.Pass();
176 }
177
set_application_locale(const std::string & value)178 void MockInputMethodManager::set_application_locale(const std::string& value) {
179 delegate_.set_active_locale(value);
180 }
181
IsLoginKeyboard(const std::string & layout) const182 bool MockInputMethodManager::IsLoginKeyboard(
183 const std::string& layout) const {
184 return true;
185 }
186
MigrateInputMethods(std::vector<std::string> * input_method_ids)187 bool MockInputMethodManager::MigrateInputMethods(
188 std::vector<std::string>* input_method_ids) {
189 return false;
190 }
191
192 } // namespace input_method
193 } // namespace chromeos
194