mock_input_method_manager.cc revision 3551c9c881056c480085172ff9840cab31610854
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
116bool MockInputMethodManager::SwitchToNextInputMethod() {
117  return true;
118}
119
120bool MockInputMethodManager::SwitchToPreviousInputMethod(
121    const ui::Accelerator& accelerator) {
122  return true;
123}
124
125bool MockInputMethodManager::SwitchInputMethod(
126    const ui::Accelerator& accelerator) {
127  return true;
128}
129
130InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const {
131  InputMethodDescriptor descriptor =
132      InputMethodUtil::GetFallbackInputMethodDescriptor();
133  if (!current_input_method_id_.empty()) {
134    return InputMethodDescriptor(current_input_method_id_,
135                                 descriptor.name(),
136                                 descriptor.keyboard_layouts(),
137                                 descriptor.language_codes(),
138                                 GURL());  // options page url.
139  }
140  return descriptor;
141}
142
143InputMethodPropertyList
144MockInputMethodManager::GetCurrentInputMethodProperties() const {
145  return InputMethodPropertyList();
146}
147
148XKeyboard* MockInputMethodManager::GetXKeyboard() {
149  return &xkeyboard_;
150}
151
152InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() {
153  return &util_;
154}
155
156ComponentExtensionIMEManager*
157    MockInputMethodManager::GetComponentExtensionIMEManager() {
158  return NULL;
159}
160
161void MockInputMethodManager::set_application_locale(const std::string& value) {
162  delegate_.set_active_locale(value);
163}
164
165void MockInputMethodManager::set_hardware_keyboard_layout(
166    const std::string& value) {
167  delegate_.set_hardware_keyboard_layout(value);
168}
169
170bool MockInputMethodManager::IsFullLatinKeyboard(
171    const std::string& layout) const {
172  return true;
173}
174}  // namespace input_method
175}  // namespace chromeos
176