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),
13 util_(&delegate_, whitelist_.GetSupportedInputMethods()) {
14 active_input_method_ids_.push_back("xkb:us::eng");
17 MockInputMethodManager::~MockInputMethodManager() {
20 void MockInputMethodManager::AddObserver(
21 InputMethodManager::Observer* observer) {
22 ++add_observer_count_;
25 void MockInputMethodManager::AddCandidateWindowObserver(
26 InputMethodManager::CandidateWindowObserver* observer) {
29 void MockInputMethodManager::RemoveObserver(
30 InputMethodManager::Observer* observer) {
31 ++remove_observer_count_;
34 void MockInputMethodManager::RemoveCandidateWindowObserver(
35 InputMethodManager::CandidateWindowObserver* observer) {
38 scoped_ptr<InputMethodDescriptors>
39 MockInputMethodManager::GetSupportedInputMethods() const {
40 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
42 InputMethodUtil::GetFallbackInputMethodDescriptor());
46 scoped_ptr<InputMethodDescriptors>
47 MockInputMethodManager::GetActiveInputMethods() const {
48 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
50 InputMethodUtil::GetFallbackInputMethodDescriptor());
54 const std::vector<std::string>&
55 MockInputMethodManager::GetActiveInputMethodIds() const {
56 return active_input_method_ids_;
59 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
63 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId(
64 const std::string& input_method_id) const {
65 static const InputMethodDescriptor defaultInputMethod =
66 InputMethodUtil::GetFallbackInputMethodDescriptor();
67 for (size_t i = 0; i < active_input_method_ids_.size(); i++) {
68 if (input_method_id == active_input_method_ids_[i]) {
69 return &defaultInputMethod;
75 void MockInputMethodManager::EnableLoginLayouts(
76 const std::string& language_code,
77 const std::vector<std::string>& initial_layout) {
80 bool MockInputMethodManager::ReplaceEnabledInputMethods(
81 const std::vector<std::string>& new_active_input_method_ids) {
85 bool MockInputMethodManager::EnableInputMethod(
86 const std::string& new_active_input_method_id) {
90 void MockInputMethodManager::ChangeInputMethod(
91 const std::string& input_method_id) {
94 void MockInputMethodManager::ActivateInputMethodProperty(
95 const std::string& key) {
98 void MockInputMethodManager::AddInputMethodExtension(
99 const std::string& id,
100 InputMethodEngineInterface* instance) {
103 void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
106 void MockInputMethodManager::GetInputMethodExtensions(
107 InputMethodDescriptors* result) {
110 void MockInputMethodManager::SetEnabledExtensionImes(
111 std::vector<std::string>* ids) {
114 void MockInputMethodManager::SetInputMethodLoginDefault() {
117 bool MockInputMethodManager::SwitchToNextInputMethod() {
121 bool MockInputMethodManager::SwitchToPreviousInputMethod(
122 const ui::Accelerator& accelerator) {
126 bool MockInputMethodManager::SwitchInputMethod(
127 const ui::Accelerator& accelerator) {
131 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
132 InputMethodDescriptor descriptor =
133 InputMethodUtil::GetFallbackInputMethodDescriptor();
134 if (!current_input_method_id_.empty()) {
135 return InputMethodDescriptor(current_input_method_id_,
137 descriptor.indicator(),
138 descriptor.keyboard_layouts(),
139 descriptor.language_codes(),
141 GURL(), // options page url.
142 GURL()); // input view page url.
147 InputMethodPropertyList
148 MockInputMethodManager::GetCurrentInputMethodProperties() const {
149 return InputMethodPropertyList();
152 void MockInputMethodManager::SetCurrentInputMethodProperties(
153 const InputMethodPropertyList& property_list) {
156 XKeyboard* MockInputMethodManager::GetXKeyboard() {
160 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
164 ComponentExtensionIMEManager*
165 MockInputMethodManager::GetComponentExtensionIMEManager() {
169 void MockInputMethodManager::set_application_locale(const std::string& value) {
170 delegate_.set_active_locale(value);
173 bool MockInputMethodManager::IsLoginKeyboard(
174 const std::string& layout) const {
177 } // namespace input_method
178 } // namespace chromeos