mock_input_method_manager.cc revision effb81e5f8246d0db0270817048dc992db66e9fb
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.
4
5#include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
6
7namespace chromeos {
8namespace input_method {
9
10MockInputMethodManager::MockInputMethodManager()
11    : add_observer_count_(0),
12      remove_observer_count_(0),
13      util_(&delegate_, whitelist_.GetSupportedInputMethods()),
14      mod3_used_(false) {
15  active_input_method_ids_.push_back("xkb:us::eng");
16}
17
18MockInputMethodManager::~MockInputMethodManager() {
19}
20
21void MockInputMethodManager::AddObserver(
22    InputMethodManager::Observer* observer) {
23  ++add_observer_count_;
24}
25
26void MockInputMethodManager::AddCandidateWindowObserver(
27    InputMethodManager::CandidateWindowObserver* observer) {
28}
29
30void MockInputMethodManager::RemoveObserver(
31    InputMethodManager::Observer* observer) {
32  ++remove_observer_count_;
33}
34
35void MockInputMethodManager::RemoveCandidateWindowObserver(
36    InputMethodManager::CandidateWindowObserver* observer) {
37}
38
39scoped_ptr<InputMethodDescriptors>
40MockInputMethodManager::GetSupportedInputMethods() const {
41  scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
42  result->push_back(
43      InputMethodUtil::GetFallbackInputMethodDescriptor());
44  return result.Pass();
45}
46
47scoped_ptr<InputMethodDescriptors>
48MockInputMethodManager::GetActiveInputMethods() const {
49  scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
50  result->push_back(
51      InputMethodUtil::GetFallbackInputMethodDescriptor());
52  return result.Pass();
53}
54
55const std::vector<std::string>&
56MockInputMethodManager::GetActiveInputMethodIds() const {
57  return active_input_method_ids_;
58}
59
60size_t MockInputMethodManager::GetNumActiveInputMethods() const {
61  return 1;
62}
63
64const 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;
71    }
72  }
73  return NULL;
74}
75
76void MockInputMethodManager::EnableLoginLayouts(
77    const std::string& language_code,
78    const std::vector<std::string>& initial_layout) {
79}
80
81bool MockInputMethodManager::ReplaceEnabledInputMethods(
82    const std::vector<std::string>& new_active_input_method_ids) {
83  return true;
84}
85
86bool MockInputMethodManager::EnableInputMethod(
87    const std::string& new_active_input_method_id) {
88  return true;
89}
90
91void MockInputMethodManager::ChangeInputMethod(
92    const std::string& input_method_id) {
93}
94
95void MockInputMethodManager::ActivateInputMethodMenuItem(
96    const std::string& key) {
97}
98
99void MockInputMethodManager::AddInputMethodExtension(
100    const std::string& id,
101    InputMethodEngineInterface* instance) {
102}
103
104void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
105}
106
107void MockInputMethodManager::GetInputMethodExtensions(
108    InputMethodDescriptors* result) {
109}
110
111void MockInputMethodManager::SetEnabledExtensionImes(
112    std::vector<std::string>* ids) {
113}
114
115void MockInputMethodManager::SetInputMethodLoginDefault() {
116}
117
118bool MockInputMethodManager::SwitchToNextInputMethod() {
119  return true;
120}
121
122bool MockInputMethodManager::SwitchToPreviousInputMethod(
123    const ui::Accelerator& accelerator) {
124  return true;
125}
126
127bool MockInputMethodManager::SwitchInputMethod(
128    const ui::Accelerator& accelerator) {
129  return true;
130}
131
132InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
133  InputMethodDescriptor descriptor =
134      InputMethodUtil::GetFallbackInputMethodDescriptor();
135  if (!current_input_method_id_.empty()) {
136    return InputMethodDescriptor(current_input_method_id_,
137                                 descriptor.name(),
138                                 descriptor.indicator(),
139                                 descriptor.keyboard_layouts(),
140                                 descriptor.language_codes(),
141                                 true,
142                                 GURL(),  // options page url.
143                                 GURL());  // input view page url.
144  }
145  return descriptor;
146}
147
148bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const {
149  return mod3_used_;
150}
151
152bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const {
153  return false;
154}
155
156XKeyboard* MockInputMethodManager::GetXKeyboard() {
157  return &xkeyboard_;
158}
159
160InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
161  return &util_;
162}
163
164ComponentExtensionIMEManager*
165    MockInputMethodManager::GetComponentExtensionIMEManager() {
166  return NULL;
167}
168
169void MockInputMethodManager::set_application_locale(const std::string& value) {
170  delegate_.set_active_locale(value);
171}
172
173bool MockInputMethodManager::IsLoginKeyboard(
174    const std::string& layout) const {
175  return true;
176}
177
178bool MockInputMethodManager::MigrateXkbInputMethods(
179    std::vector<std::string>* input_method_ids) {
180  return false;
181}
182
183}  // namespace input_method
184}  // namespace chromeos
185