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()),
15 active_input_method_ids_.push_back("xkb:us::eng");
18 MockInputMethodManager::~MockInputMethodManager() {
21 void MockInputMethodManager::AddObserver(
22 InputMethodManager::Observer* observer) {
23 ++add_observer_count_;
26 void MockInputMethodManager::AddCandidateWindowObserver(
27 InputMethodManager::CandidateWindowObserver* observer) {
30 void MockInputMethodManager::RemoveObserver(
31 InputMethodManager::Observer* observer) {
32 ++remove_observer_count_;
35 void MockInputMethodManager::RemoveCandidateWindowObserver(
36 InputMethodManager::CandidateWindowObserver* observer) {
39 scoped_ptr<InputMethodDescriptors>
40 MockInputMethodManager::GetSupportedInputMethods() const {
41 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
43 InputMethodUtil::GetFallbackInputMethodDescriptor());
47 scoped_ptr<InputMethodDescriptors>
48 MockInputMethodManager::GetActiveInputMethods() const {
49 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
51 InputMethodUtil::GetFallbackInputMethodDescriptor());
55 const std::vector<std::string>&
56 MockInputMethodManager::GetActiveInputMethodIds() const {
57 return active_input_method_ids_;
60 size_t MockInputMethodManager::GetNumActiveInputMethods() const {
64 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;
76 void MockInputMethodManager::EnableLoginLayouts(
77 const std::string& language_code,
78 const std::vector<std::string>& initial_layout) {
81 bool MockInputMethodManager::ReplaceEnabledInputMethods(
82 const std::vector<std::string>& new_active_input_method_ids) {
86 bool MockInputMethodManager::EnableInputMethod(
87 const std::string& new_active_input_method_id) {
91 void MockInputMethodManager::ChangeInputMethod(
92 const std::string& input_method_id) {
95 void MockInputMethodManager::ActivateInputMethodMenuItem(
96 const std::string& key) {
99 void MockInputMethodManager::AddInputMethodExtension(
100 const std::string& id,
101 InputMethodEngineInterface* instance) {
104 void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
107 void MockInputMethodManager::GetInputMethodExtensions(
108 InputMethodDescriptors* result) {
111 void MockInputMethodManager::SetEnabledExtensionImes(
112 std::vector<std::string>* ids) {
115 void MockInputMethodManager::SetInputMethodLoginDefault() {
118 bool MockInputMethodManager::SwitchToNextInputMethod() {
122 bool MockInputMethodManager::SwitchToPreviousInputMethod(
123 const ui::Accelerator& accelerator) {
127 bool MockInputMethodManager::SwitchInputMethod(
128 const ui::Accelerator& accelerator) {
132 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
133 InputMethodDescriptor descriptor =
134 InputMethodUtil::GetFallbackInputMethodDescriptor();
135 if (!current_input_method_id_.empty()) {
136 return InputMethodDescriptor(current_input_method_id_,
138 descriptor.indicator(),
139 descriptor.keyboard_layouts(),
140 descriptor.language_codes(),
142 GURL(), // options page url.
143 GURL()); // input view page url.
148 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
152 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
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 {
178 bool MockInputMethodManager::MigrateXkbInputMethods(
179 std::vector<std::string>* input_method_ids) {
183 } // namespace input_method
184 } // namespace chromeos