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