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::MockInputMethodManager()
11 : add_observer_count_(0),
12 remove_observer_count_(0),
15 active_input_method_ids_.push_back("xkb:us::eng");
18 MockInputMethodManager::~MockInputMethodManager() {
21 InputMethodManager::State MockInputMethodManager::GetState() {
22 return InputMethodManager::STATE_BROWSER_SCREEN;
25 void MockInputMethodManager::AddObserver(
26 InputMethodManager::Observer* observer) {
27 ++add_observer_count_;
30 void MockInputMethodManager::AddCandidateWindowObserver(
31 InputMethodManager::CandidateWindowObserver* observer) {
34 void MockInputMethodManager::RemoveObserver(
35 InputMethodManager::Observer* observer) {
36 ++remove_observer_count_;
39 void MockInputMethodManager::RemoveCandidateWindowObserver(
40 InputMethodManager::CandidateWindowObserver* observer) {
43 scoped_ptr<InputMethodDescriptors>
44 MockInputMethodManager::GetSupportedInputMethods() const {
45 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
47 InputMethodUtil::GetFallbackInputMethodDescriptor());
51 scoped_ptr<InputMethodDescriptors>
52 MockInputMethodManager::GetActiveInputMethods() const {
53 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
55 InputMethodUtil::GetFallbackInputMethodDescriptor());
59 const std::vector<std::string>&
60 MockInputMethodManager::GetActiveInputMethodIds() const {
61 return active_input_method_ids_;
64 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
68 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
69 const std::string& input_method_id) const {
70 static const InputMethodDescriptor defaultInputMethod =
71 InputMethodUtil::GetFallbackInputMethodDescriptor();
72 for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
73 if (input_method_id == active_input_method_ids_[i]) {
74 return &defaultInputMethod;
80 void MockInputMethodManager::EnableLoginLayouts(
81 const std::string& language_code,
82 const std::vector<std::string>& initial_layout) {
85 bool MockInputMethodManager::ReplaceEnabledInputMethods(
86 const std::vector<std::string>& new_active_input_method_ids) {
90 bool MockInputMethodManager::EnableInputMethod(
91 const std::string& new_active_input_method_id) {
95 void MockInputMethodManager::ChangeInputMethod(
96 const std::string& input_method_id) {
99 void MockInputMethodManager::ActivateInputMethodMenuItem(
100 const std::string& key) {
103 void MockInputMethodManager::AddInputMethodExtension(
104 const std::string& extension_id,
105 const InputMethodDescriptors& descriptors,
106 InputMethodEngineInterface* instance) {
109 void MockInputMethodManager::RemoveInputMethodExtension(
110 const std::string& extension_id) {
113 void MockInputMethodManager::GetInputMethodExtensions(
114 InputMethodDescriptors* result) {
117 void MockInputMethodManager::SetEnabledExtensionImes(
118 std::vector<std::string>* ids) {
121 void MockInputMethodManager::SetInputMethodLoginDefault() {
124 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD(
125 const std::string& locale, const std::string& layout) {
128 bool MockInputMethodManager::SwitchToNextInputMethod() {
132 bool MockInputMethodManager::SwitchToPreviousInputMethod(
133 const ui::Accelerator& accelerator) {
137 bool MockInputMethodManager::SwitchInputMethod(
138 const ui::Accelerator& accelerator) {
142 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
143 InputMethodDescriptor descriptor =
144 InputMethodUtil::GetFallbackInputMethodDescriptor();
145 if (!current_input_method_id_.empty()) {
146 return InputMethodDescriptor(current_input_method_id_,
148 descriptor.indicator(),
149 descriptor.keyboard_layouts(),
150 descriptor.language_codes(),
152 GURL(), // options page url.
153 GURL()); // input view page url.
158 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
162 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
166 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
168 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
172 ComponentExtensionIMEManager*
173 MockInputMethodManager::GetComponentExtensionIMEManager() {
174 return comp_ime_manager_.get();
177 void MockInputMethodManager::SetComponentExtensionIMEManager(
178 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
179 comp_ime_manager_ = comp_ime_manager.Pass();
182 void MockInputMethodManager::set_application_locale(const std::string& value) {
183 delegate_.set_active_locale(value);
186 bool MockInputMethodManager::IsLoginKeyboard(
187 const std::string& layout) const {
191 bool MockInputMethodManager::MigrateInputMethods(
192 std::vector<std::string>* input_method_ids) {
196 } // namespace input_method
197 } // namespace chromeos