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::EnableLayouts(const std::string
& language_code
,
76 const std::string
& initial_layout
) {
79 bool MockInputMethodManager::EnableInputMethods(
80 const std::vector
<std::string
>& new_active_input_method_ids
) {
84 bool MockInputMethodManager::EnableInputMethod(
85 const std::string
& new_active_input_method_id
) {
89 void MockInputMethodManager::ChangeInputMethod(
90 const std::string
& input_method_id
) {
93 void MockInputMethodManager::ActivateInputMethodProperty(
94 const std::string
& key
) {
97 void MockInputMethodManager::AddInputMethodExtension(
98 const std::string
& id
,
99 InputMethodEngineInterface
* instance
) {
102 void MockInputMethodManager::RemoveInputMethodExtension(const std::string
& id
) {
105 void MockInputMethodManager::GetInputMethodExtensions(
106 InputMethodDescriptors
* result
) {
109 void MockInputMethodManager::SetEnabledExtensionImes(
110 std::vector
<std::string
>* ids
) {
113 void MockInputMethodManager::SetInputMethodDefault() {
116 bool MockInputMethodManager::SwitchToNextInputMethod() {
120 bool MockInputMethodManager::SwitchToPreviousInputMethod(
121 const ui::Accelerator
& accelerator
) {
125 bool MockInputMethodManager::SwitchInputMethod(
126 const ui::Accelerator
& accelerator
) {
130 InputMethodDescriptor
MockInputMethodManager::GetCurrentInputMethod() const {
131 InputMethodDescriptor descriptor
=
132 InputMethodUtil::GetFallbackInputMethodDescriptor();
133 if (!current_input_method_id_
.empty()) {
134 return InputMethodDescriptor(current_input_method_id_
,
136 descriptor
.keyboard_layouts(),
137 descriptor
.language_codes(),
139 GURL(), // options page url.
140 GURL()); // input view page url.
145 InputMethodPropertyList
146 MockInputMethodManager::GetCurrentInputMethodProperties() const {
147 return InputMethodPropertyList();
150 void MockInputMethodManager::SetCurrentInputMethodProperties(
151 const InputMethodPropertyList
& property_list
) {
154 XKeyboard
* MockInputMethodManager::GetXKeyboard() {
158 InputMethodUtil
* MockInputMethodManager::GetInputMethodUtil() {
162 ComponentExtensionIMEManager
*
163 MockInputMethodManager::GetComponentExtensionIMEManager() {
167 void MockInputMethodManager::set_application_locale(const std::string
& value
) {
168 delegate_
.set_active_locale(value
);
171 void MockInputMethodManager::set_hardware_keyboard_layout(
172 const std::string
& value
) {
173 delegate_
.set_hardware_keyboard_layout(value
);
176 bool MockInputMethodManager::IsLoginKeyboard(
177 const std::string
& layout
) const {
180 } // namespace input_method
181 } // namespace chromeos