mock_input_method_manager.cc revision 424c4d7b64af9d0d8fd9624f381f469654d5e3d2
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
77bool MockInputMethodManager::MigrateOldInputMethods(
78    std::vector<std::string>* input_method_ids) {
79  return false;
80}
81
82bool MockInputMethodManager::MigrateKoreanKeyboard(
83    const std::string& keyboard_id,
84    std::vector<std::string>* input_method_ids) {
85  return false;
86}
87
88void MockInputMethodManager::ChangeInputMethod(
89    const std::string& input_method_id) {
90}
91
92void MockInputMethodManager::ActivateInputMethodProperty(
93    const std::string& key) {
94}
95
96void MockInputMethodManager::AddInputMethodExtension(
97    const std::string& id,
98    const std::string& name,
99    const std::vector<std::string>& layouts,
100    const std::vector<std::string>& languages,
101    const GURL& options_url,
102    InputMethodEngine* instance) {
103}
104
105void MockInputMethodManager::RemoveInputMethodExtension(const std::string& id) {
106}
107
108void MockInputMethodManager::GetInputMethodExtensions(
109    InputMethodDescriptors* result) {
110}
111
112void MockInputMethodManager::SetEnabledExtensionImes(
113    std::vector<std::string>* ids) {
114}
115
116void MockInputMethodManager::SetInputMethodDefault() {
117}
118
119bool MockInputMethodManager::SwitchToNextInputMethod() {
120  return true;
121}
122
123bool MockInputMethodManager::SwitchToPreviousInputMethod(
124    const ui::Accelerator& accelerator) {
125  return true;
126}
127
128bool MockInputMethodManager::SwitchInputMethod(
129    const ui::Accelerator& accelerator) {
130  return true;
131}
132
133InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
134  InputMethodDescriptor descriptor =
135      InputMethodUtil::GetFallbackInputMethodDescriptor();
136  if (!current_input_method_id_.empty()) {
137    return InputMethodDescriptor(current_input_method_id_,
138                                 descriptor.name(),
139                                 descriptor.keyboard_layouts(),
140                                 descriptor.language_codes(),
141                                 true,
142                                 GURL());  // options page url.
143  }
144  return descriptor;
145}
146
147InputMethodPropertyList
148MockInputMethodManager::GetCurrentInputMethodProperties() const {
149  return InputMethodPropertyList();
150}
151
152XKeyboard* MockInputMethodManager::GetXKeyboard() {
153  return &xkeyboard_;
154}
155
156InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
157  return &util_;
158}
159
160ComponentExtensionIMEManager*
161    MockInputMethodManager::GetComponentExtensionIMEManager() {
162  return NULL;
163}
164
165void MockInputMethodManager::set_application_locale(const std::string& value) {
166  delegate_.set_active_locale(value);
167}
168
169void MockInputMethodManager::set_hardware_keyboard_layout(
170    const std::string& value) {
171  delegate_.set_hardware_keyboard_layout(value);
172}
173
174bool MockInputMethodManager::IsLoginKeyboard(
175    const std::string& layout) const {
176  return true;
177}
178}  // namespace input_method
179}  // namespace chromeos
180