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(
101 const std::string& id,
102 InputMethodEngineInterface* instance) {
105 void MockInputMethodManager::RemoveInputMethodExtension(Profile* profile,
106 const std::string& id) {
109 void MockInputMethodManager::GetInputMethodExtensions(
110 InputMethodDescriptors* result) {
113 void MockInputMethodManager::SetEnabledExtensionImes(
114 std::vector<std::string>* ids) {
117 void MockInputMethodManager::SetInputMethodLoginDefault() {
120 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD(
121 const std::string& locale, const std::string& layout) {
124 bool MockInputMethodManager::SwitchToNextInputMethod() {
128 bool MockInputMethodManager::SwitchToPreviousInputMethod(
129 const ui::Accelerator& accelerator) {
133 bool MockInputMethodManager::SwitchInputMethod(
134 const ui::Accelerator& accelerator) {
138 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
139 InputMethodDescriptor descriptor =
140 InputMethodUtil::GetFallbackInputMethodDescriptor();
141 if (!current_input_method_id_.empty()) {
142 return InputMethodDescriptor(current_input_method_id_,
144 descriptor.indicator(),
145 descriptor.keyboard_layouts(),
146 descriptor.language_codes(),
148 GURL(), // options page url.
149 GURL()); // input view page url.
154 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
158 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
162 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; }
164 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
168 ComponentExtensionIMEManager*
169 MockInputMethodManager::GetComponentExtensionIMEManager() {
170 return comp_ime_manager_.get();
173 void MockInputMethodManager::SetComponentExtensionIMEManager(
174 scoped_ptr<ComponentExtensionIMEManager> comp_ime_manager) {
175 comp_ime_manager_ = comp_ime_manager.Pass();
178 void MockInputMethodManager::set_application_locale(const std::string& value) {
179 delegate_.set_active_locale(value);
182 bool MockInputMethodManager::IsLoginKeyboard(
183 const std::string& layout) const {
187 bool MockInputMethodManager::MigrateInputMethods(
188 std::vector<std::string>* input_method_ids) {
192 } // namespace input_method
193 } // namespace chromeos