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.
5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
8 namespace input_method {
10 MockInputMethodManager::State::State(MockInputMethodManager* manager)
12 active_input_method_ids.push_back("xkb:us::eng");
15 MockInputMethodManager::State::~State() {
18 MockInputMethodManager::MockInputMethodManager()
19 : add_observer_count_(0),
20 remove_observer_count_(0),
21 state_(new State(this)),
26 MockInputMethodManager::~MockInputMethodManager() {
29 InputMethodManager::UISessionState MockInputMethodManager::GetUISessionState() {
30 return InputMethodManager::STATE_BROWSER_SCREEN;
33 void MockInputMethodManager::AddObserver(
34 InputMethodManager::Observer* observer) {
35 ++add_observer_count_;
38 void MockInputMethodManager::AddCandidateWindowObserver(
39 InputMethodManager::CandidateWindowObserver* observer) {
42 void MockInputMethodManager::RemoveObserver(
43 InputMethodManager::Observer* observer) {
44 ++remove_observer_count_;
47 void MockInputMethodManager::RemoveCandidateWindowObserver(
48 InputMethodManager::CandidateWindowObserver* observer) {
51 scoped_ptr<InputMethodDescriptors>
52 MockInputMethodManager::GetSupportedInputMethods() const {
53 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
55 InputMethodUtil::GetFallbackInputMethodDescriptor());
59 scoped_ptr<InputMethodDescriptors>
60 MockInputMethodManager::State::GetActiveInputMethods() const {
61 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
63 InputMethodUtil::GetFallbackInputMethodDescriptor());
67 const std::vector<std::string>&
68 MockInputMethodManager::State::GetActiveInputMethodIds() const {
69 return active_input_method_ids;
72 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const {
76 const InputMethodDescriptor*
77 MockInputMethodManager::State::GetInputMethodFromId(
78 const std::string& input_method_id) const {
79 static const InputMethodDescriptor defaultInputMethod =
80 InputMethodUtil::GetFallbackInputMethodDescriptor();
81 for (size_t i = 0; i < active_input_method_ids.size(); i++) {
82 if (input_method_id == active_input_method_ids[i]) {
83 return &defaultInputMethod;
89 void MockInputMethodManager::State::EnableLoginLayouts(
90 const std::string& language_code,
91 const std::vector<std::string>& initial_layout) {
94 void MockInputMethodManager::State::EnableLockScreenLayouts() {
97 bool MockInputMethodManager::State::ReplaceEnabledInputMethods(
98 const std::vector<std::string>& new_active_input_method_ids) {
102 bool MockInputMethodManager::State::EnableInputMethod(
103 const std::string& new_active_input_method_id) {
107 void MockInputMethodManager::State::ChangeInputMethod(
108 const std::string& input_method_id,
112 void MockInputMethodManager::ActivateInputMethodMenuItem(
113 const std::string& key) {
116 void MockInputMethodManager::State::AddInputMethodExtension(
117 const std::string& extension_id,
118 const InputMethodDescriptors& descriptors,
119 InputMethodEngineInterface* instance) {
122 void MockInputMethodManager::State::RemoveInputMethodExtension(
123 const std::string& extension_id) {
126 void MockInputMethodManager::State::GetInputMethodExtensions(
127 InputMethodDescriptors* result) {
130 void MockInputMethodManager::State::SetEnabledExtensionImes(
131 std::vector<std::string>* ids) {
134 void MockInputMethodManager::State::SetInputMethodLoginDefault() {
137 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD(
138 const std::string& locale,
139 const std::string& layout) {
142 bool MockInputMethodManager::State::SwitchToNextInputMethod() {
146 bool MockInputMethodManager::State::SwitchToPreviousInputMethod(
147 const ui::Accelerator& accelerator) {
151 bool MockInputMethodManager::State::SwitchInputMethod(
152 const ui::Accelerator& accelerator) {
156 InputMethodDescriptor MockInputMethodManager::State::GetCurrentInputMethod()
158 InputMethodDescriptor descriptor =
159 InputMethodUtil::GetFallbackInputMethodDescriptor();
160 if (!current_input_method_id.empty()) {
161 return InputMethodDescriptor(current_input_method_id,
163 descriptor.indicator(),
164 descriptor.keyboard_layouts(),
165 descriptor.language_codes(),
167 GURL(), // options page url.
168 GURL()); // input view page url.
173 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
177 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
181 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
183 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
187 ComponentExtensionIMEManager*
188 MockInputMethodManager::GetComponentExtensionIMEManager() {
189 return comp_ime_manager_.get();
192 void MockInputMethodManager::SetComponentExtensionIMEManager(
193 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
194 comp_ime_manager_ = comp_ime_manager.Pass();
197 void MockInputMethodManager::set_application_locale(const std::string& value) {
198 delegate_.set_active_locale(value);
201 bool MockInputMethodManager::IsLoginKeyboard(
202 const std::string& layout) const {
206 bool MockInputMethodManager::MigrateInputMethods(
207 std::vector<std::string>* input_method_ids) {
210 scoped_refptr<InputMethodManager::State> MockInputMethodManager::CreateNewState(
216 scoped_refptr<InputMethodManager::State>
217 MockInputMethodManager::GetActiveIMEState() {
218 return scoped_refptr<InputMethodManager::State>(state_.get());
221 scoped_refptr<InputMethodManager::State> MockInputMethodManager::State::Clone()
224 return manager_->GetActiveIMEState();
227 void MockInputMethodManager::SetState(
228 scoped_refptr<InputMethodManager::State> state) {
229 state_ = scoped_refptr<MockInputMethodManager::State>(
230 static_cast<MockInputMethodManager::State*>(state.get()));
233 void MockInputMethodManager::SetCurrentInputMethodId(
234 const std::string& input_method_id) {
235 state_->current_input_method_id = input_method_id;
238 } // namespace input_method
239 } // namespace chromeos