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