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::State::State(MockInputMethodManager
* manager
)
12 active_input_method_ids
.push_back("xkb:us::eng");
15 MockInputMethodManager::State::~State() {
18 MockInputMethodManager::MockInputMethodManager()
19 : add_observer_count_(0),
20 remove_observer_count_(0),
21 state_(new State(this)),
26 MockInputMethodManager::~MockInputMethodManager() {
29 InputMethodManager::UISessionState
MockInputMethodManager::GetUISessionState() {
30 return InputMethodManager::STATE_BROWSER_SCREEN
;
33 void MockInputMethodManager::AddObserver(
34 InputMethodManager::Observer
* observer
) {
35 ++add_observer_count_
;
38 void MockInputMethodManager::AddCandidateWindowObserver(
39 InputMethodManager::CandidateWindowObserver
* observer
) {
42 void MockInputMethodManager::RemoveObserver(
43 InputMethodManager::Observer
* observer
) {
44 ++remove_observer_count_
;
47 void MockInputMethodManager::RemoveCandidateWindowObserver(
48 InputMethodManager::CandidateWindowObserver
* observer
) {
51 scoped_ptr
<InputMethodDescriptors
>
52 MockInputMethodManager::GetSupportedInputMethods() const {
53 scoped_ptr
<InputMethodDescriptors
> result(new InputMethodDescriptors
);
55 InputMethodUtil::GetFallbackInputMethodDescriptor());
59 scoped_ptr
<InputMethodDescriptors
>
60 MockInputMethodManager::State::GetActiveInputMethods() const {
61 scoped_ptr
<InputMethodDescriptors
> result(new InputMethodDescriptors
);
63 InputMethodUtil::GetFallbackInputMethodDescriptor());
67 const std::vector
<std::string
>&
68 MockInputMethodManager::State::GetActiveInputMethodIds() const {
69 return active_input_method_ids
;
72 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const {
76 const InputMethodDescriptor
*
77 MockInputMethodManager::State::GetInputMethodFromId(
78 const std::string
& input_method_id
) const {
79 static const InputMethodDescriptor defaultInputMethod
=
80 InputMethodUtil::GetFallbackInputMethodDescriptor();
81 for (size_t i
= 0; i
< active_input_method_ids
.size(); i
++) {
82 if (input_method_id
== active_input_method_ids
[i
]) {
83 return &defaultInputMethod
;
89 void MockInputMethodManager::State::EnableLoginLayouts(
90 const std::string
& language_code
,
91 const std::vector
<std::string
>& initial_layout
) {
94 void MockInputMethodManager::State::EnableLockScreenLayouts() {
97 bool MockInputMethodManager::State::ReplaceEnabledInputMethods(
98 const std::vector
<std::string
>& new_active_input_method_ids
) {
102 bool MockInputMethodManager::State::EnableInputMethod(
103 const std::string
& new_active_input_method_id
) {
107 void MockInputMethodManager::State::ChangeInputMethod(
108 const std::string
& input_method_id
,
112 void MockInputMethodManager::ActivateInputMethodMenuItem(
113 const std::string
& key
) {
116 void MockInputMethodManager::State::AddInputMethodExtension(
117 const std::string
& extension_id
,
118 const InputMethodDescriptors
& descriptors
,
119 InputMethodEngineInterface
* instance
) {
122 void MockInputMethodManager::State::RemoveInputMethodExtension(
123 const std::string
& extension_id
) {
126 void MockInputMethodManager::State::GetInputMethodExtensions(
127 InputMethodDescriptors
* result
) {
130 void MockInputMethodManager::State::SetEnabledExtensionImes(
131 std::vector
<std::string
>* ids
) {
134 void MockInputMethodManager::State::SetInputMethodLoginDefault() {
137 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD(
138 const std::string
& locale
,
139 const std::string
& layout
) {
142 bool MockInputMethodManager::State::CanCycleInputMethod() {
146 void MockInputMethodManager::State::SwitchToNextInputMethod() {
149 void MockInputMethodManager::State::SwitchToPreviousInputMethod() {
152 bool MockInputMethodManager::State::CanSwitchInputMethod(
153 const ui::Accelerator
& accelerator
) {
157 void MockInputMethodManager::State::SwitchInputMethod(
158 const ui::Accelerator
& accelerator
) {
161 InputMethodDescriptor
MockInputMethodManager::State::GetCurrentInputMethod()
163 InputMethodDescriptor descriptor
=
164 InputMethodUtil::GetFallbackInputMethodDescriptor();
165 if (!current_input_method_id
.empty()) {
166 return InputMethodDescriptor(current_input_method_id
,
168 descriptor
.indicator(),
169 descriptor
.keyboard_layouts(),
170 descriptor
.language_codes(),
172 GURL(), // options page url.
173 GURL()); // input view page url.
178 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
182 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
186 ImeKeyboard
* MockInputMethodManager::GetImeKeyboard() { return &keyboard_
; }
188 InputMethodUtil
* MockInputMethodManager::GetInputMethodUtil() {
192 ComponentExtensionIMEManager
*
193 MockInputMethodManager::GetComponentExtensionIMEManager() {
194 return comp_ime_manager_
.get();
197 void MockInputMethodManager::SetComponentExtensionIMEManager(
198 scoped_ptr
<ComponentExtensionIMEManager
> comp_ime_manager
) {
199 comp_ime_manager_
= comp_ime_manager
.Pass();
202 void MockInputMethodManager::set_application_locale(const std::string
& value
) {
203 delegate_
.set_active_locale(value
);
206 bool MockInputMethodManager::IsLoginKeyboard(
207 const std::string
& layout
) const {
211 bool MockInputMethodManager::MigrateInputMethods(
212 std::vector
<std::string
>* input_method_ids
) {
215 scoped_refptr
<InputMethodManager::State
> MockInputMethodManager::CreateNewState(
221 scoped_refptr
<InputMethodManager::State
>
222 MockInputMethodManager::GetActiveIMEState() {
223 return scoped_refptr
<InputMethodManager::State
>(state_
.get());
226 scoped_refptr
<InputMethodManager::State
> MockInputMethodManager::State::Clone()
229 return manager_
->GetActiveIMEState();
232 void MockInputMethodManager::SetState(
233 scoped_refptr
<InputMethodManager::State
> state
) {
234 state_
= scoped_refptr
<MockInputMethodManager::State
>(
235 static_cast<MockInputMethodManager::State
*>(state
.get()));
238 void MockInputMethodManager::SetCurrentInputMethodId(
239 const std::string
& input_method_id
) {
240 state_
->current_input_method_id
= input_method_id
;
243 } // namespace input_method
244 } // namespace chromeos