| OLD | NEW |
| (Empty) |
| 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 #include <utility> | |
| 8 | |
| 9 namespace chromeos { | |
| 10 namespace input_method { | |
| 11 | |
| 12 MockInputMethodManager::State::State(MockInputMethodManager* manager) | |
| 13 : manager_(manager) { | |
| 14 active_input_method_ids.push_back("xkb:us::eng"); | |
| 15 } | |
| 16 | |
| 17 MockInputMethodManager::State::~State() { | |
| 18 } | |
| 19 | |
| 20 MockInputMethodManager::MockInputMethodManager() | |
| 21 : add_observer_count_(0), | |
| 22 remove_observer_count_(0), | |
| 23 state_(new State(this)), | |
| 24 util_(&delegate_), | |
| 25 mod3_used_(false) { | |
| 26 } | |
| 27 | |
| 28 MockInputMethodManager::~MockInputMethodManager() { | |
| 29 } | |
| 30 | |
| 31 InputMethodManager::UISessionState MockInputMethodManager::GetUISessionState() { | |
| 32 return InputMethodManager::STATE_BROWSER_SCREEN; | |
| 33 } | |
| 34 | |
| 35 void MockInputMethodManager::AddObserver( | |
| 36 InputMethodManager::Observer* observer) { | |
| 37 ++add_observer_count_; | |
| 38 } | |
| 39 | |
| 40 void MockInputMethodManager::AddCandidateWindowObserver( | |
| 41 InputMethodManager::CandidateWindowObserver* observer) { | |
| 42 } | |
| 43 | |
| 44 void MockInputMethodManager::AddImeMenuObserver( | |
| 45 InputMethodManager::ImeMenuObserver* observer) {} | |
| 46 | |
| 47 void MockInputMethodManager::RemoveObserver( | |
| 48 InputMethodManager::Observer* observer) { | |
| 49 ++remove_observer_count_; | |
| 50 } | |
| 51 | |
| 52 void MockInputMethodManager::RemoveCandidateWindowObserver( | |
| 53 InputMethodManager::CandidateWindowObserver* observer) { | |
| 54 } | |
| 55 | |
| 56 void MockInputMethodManager::RemoveImeMenuObserver( | |
| 57 InputMethodManager::ImeMenuObserver* observer) {} | |
| 58 | |
| 59 std::unique_ptr<InputMethodDescriptors> | |
| 60 MockInputMethodManager::GetSupportedInputMethods() const { | |
| 61 std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | |
| 62 result->push_back( | |
| 63 InputMethodUtil::GetFallbackInputMethodDescriptor()); | |
| 64 return result; | |
| 65 } | |
| 66 | |
| 67 std::unique_ptr<InputMethodDescriptors> | |
| 68 MockInputMethodManager::State::GetActiveInputMethods() const { | |
| 69 std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | |
| 70 result->push_back( | |
| 71 InputMethodUtil::GetFallbackInputMethodDescriptor()); | |
| 72 return result; | |
| 73 } | |
| 74 | |
| 75 const std::vector<std::string>& | |
| 76 MockInputMethodManager::State::GetActiveInputMethodIds() const { | |
| 77 return active_input_method_ids; | |
| 78 } | |
| 79 | |
| 80 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const { | |
| 81 return 1; | |
| 82 } | |
| 83 | |
| 84 const InputMethodDescriptor* | |
| 85 MockInputMethodManager::State::GetInputMethodFromId( | |
| 86 const std::string& input_method_id) const { | |
| 87 static const InputMethodDescriptor defaultInputMethod = | |
| 88 InputMethodUtil::GetFallbackInputMethodDescriptor(); | |
| 89 for (size_t i = 0; i < active_input_method_ids.size(); i++) { | |
| 90 if (input_method_id == active_input_method_ids[i]) { | |
| 91 return &defaultInputMethod; | |
| 92 } | |
| 93 } | |
| 94 return NULL; | |
| 95 } | |
| 96 | |
| 97 void MockInputMethodManager::State::EnableLoginLayouts( | |
| 98 const std::string& language_code, | |
| 99 const std::vector<std::string>& initial_layout) { | |
| 100 } | |
| 101 | |
| 102 void MockInputMethodManager::State::EnableLockScreenLayouts() { | |
| 103 } | |
| 104 | |
| 105 bool MockInputMethodManager::State::ReplaceEnabledInputMethods( | |
| 106 const std::vector<std::string>& new_active_input_method_ids) { | |
| 107 return true; | |
| 108 } | |
| 109 | |
| 110 bool MockInputMethodManager::State::EnableInputMethod( | |
| 111 const std::string& new_active_input_method_id) { | |
| 112 return true; | |
| 113 } | |
| 114 | |
| 115 void MockInputMethodManager::State::ChangeInputMethod( | |
| 116 const std::string& input_method_id, | |
| 117 bool show_message) { | |
| 118 } | |
| 119 | |
| 120 void MockInputMethodManager::ActivateInputMethodMenuItem( | |
| 121 const std::string& key) { | |
| 122 } | |
| 123 | |
| 124 void MockInputMethodManager::State::AddInputMethodExtension( | |
| 125 const std::string& extension_id, | |
| 126 const InputMethodDescriptors& descriptors, | |
| 127 ui::IMEEngineHandlerInterface* instance) {} | |
| 128 | |
| 129 void MockInputMethodManager::State::RemoveInputMethodExtension( | |
| 130 const std::string& extension_id) { | |
| 131 } | |
| 132 | |
| 133 void MockInputMethodManager::State::GetInputMethodExtensions( | |
| 134 InputMethodDescriptors* result) { | |
| 135 } | |
| 136 | |
| 137 void MockInputMethodManager::State::SetEnabledExtensionImes( | |
| 138 std::vector<std::string>* ids) { | |
| 139 } | |
| 140 | |
| 141 void MockInputMethodManager::State::SetInputMethodLoginDefault() { | |
| 142 } | |
| 143 | |
| 144 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD( | |
| 145 const std::string& locale, | |
| 146 const std::string& layout) { | |
| 147 } | |
| 148 | |
| 149 bool MockInputMethodManager::State::CanCycleInputMethod() { | |
| 150 return true; | |
| 151 } | |
| 152 | |
| 153 void MockInputMethodManager::State::SwitchToNextInputMethod() { | |
| 154 } | |
| 155 | |
| 156 void MockInputMethodManager::State::SwitchToPreviousInputMethod() { | |
| 157 } | |
| 158 | |
| 159 bool MockInputMethodManager::State::CanSwitchInputMethod( | |
| 160 const ui::Accelerator& accelerator) { | |
| 161 return true; | |
| 162 } | |
| 163 | |
| 164 void MockInputMethodManager::State::SwitchInputMethod( | |
| 165 const ui::Accelerator& accelerator) { | |
| 166 } | |
| 167 | |
| 168 InputMethodDescriptor MockInputMethodManager::State::GetCurrentInputMethod() | |
| 169 const { | |
| 170 InputMethodDescriptor descriptor = | |
| 171 InputMethodUtil::GetFallbackInputMethodDescriptor(); | |
| 172 if (!current_input_method_id.empty()) { | |
| 173 return InputMethodDescriptor(current_input_method_id, | |
| 174 descriptor.name(), | |
| 175 descriptor.indicator(), | |
| 176 descriptor.keyboard_layouts(), | |
| 177 descriptor.language_codes(), | |
| 178 true, | |
| 179 GURL(), // options page url. | |
| 180 GURL()); // input view page url. | |
| 181 } | |
| 182 return descriptor; | |
| 183 } | |
| 184 | |
| 185 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const { | |
| 186 return mod3_used_; | |
| 187 } | |
| 188 | |
| 189 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const { | |
| 190 return false; | |
| 191 } | |
| 192 | |
| 193 ImeKeyboard* MockInputMethodManager::GetImeKeyboard() { return &keyboard_; } | |
| 194 | |
| 195 InputMethodUtil* MockInputMethodManager::GetInputMethodUtil() { | |
| 196 return &util_; | |
| 197 } | |
| 198 | |
| 199 ComponentExtensionIMEManager* | |
| 200 MockInputMethodManager::GetComponentExtensionIMEManager() { | |
| 201 return comp_ime_manager_.get(); | |
| 202 } | |
| 203 | |
| 204 void MockInputMethodManager::SetComponentExtensionIMEManager( | |
| 205 std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager) { | |
| 206 comp_ime_manager_ = std::move(comp_ime_manager); | |
| 207 } | |
| 208 | |
| 209 void MockInputMethodManager::set_application_locale(const std::string& value) { | |
| 210 delegate_.set_active_locale(value); | |
| 211 } | |
| 212 | |
| 213 bool MockInputMethodManager::IsLoginKeyboard( | |
| 214 const std::string& layout) const { | |
| 215 return true; | |
| 216 } | |
| 217 | |
| 218 bool MockInputMethodManager::MigrateInputMethods( | |
| 219 std::vector<std::string>* input_method_ids) { | |
| 220 return false; | |
| 221 } | |
| 222 scoped_refptr<InputMethodManager::State> MockInputMethodManager::CreateNewState( | |
| 223 Profile* profile) { | |
| 224 NOTIMPLEMENTED(); | |
| 225 return state_; | |
| 226 } | |
| 227 | |
| 228 scoped_refptr<InputMethodManager::State> | |
| 229 MockInputMethodManager::GetActiveIMEState() { | |
| 230 return scoped_refptr<InputMethodManager::State>(state_.get()); | |
| 231 } | |
| 232 | |
| 233 scoped_refptr<InputMethodManager::State> MockInputMethodManager::State::Clone() | |
| 234 const { | |
| 235 NOTIMPLEMENTED(); | |
| 236 return manager_->GetActiveIMEState(); | |
| 237 } | |
| 238 | |
| 239 void MockInputMethodManager::SetState( | |
| 240 scoped_refptr<InputMethodManager::State> state) { | |
| 241 state_ = scoped_refptr<MockInputMethodManager::State>( | |
| 242 static_cast<MockInputMethodManager::State*>(state.get())); | |
| 243 } | |
| 244 | |
| 245 void MockInputMethodManager::SetCurrentInputMethodId( | |
| 246 const std::string& input_method_id) { | |
| 247 state_->current_input_method_id = input_method_id; | |
| 248 } | |
| 249 | |
| 250 void MockInputMethodManager::ImeMenuActivationChanged(bool is_active) {} | |
| 251 | |
| 252 void MockInputMethodManager::NotifyImeMenuItemsChanged( | |
| 253 const std::string& engine_id, | |
| 254 const std::vector<InputMethodManager::MenuItem>& items) {} | |
| 255 | |
| 256 void MockInputMethodManager::MaybeNotifyImeMenuActivationChanged() {} | |
| 257 | |
| 258 void MockInputMethodManager::OverrideKeyboardUrlRef(const std::string& keyset) { | |
| 259 } | |
| 260 | |
| 261 bool MockInputMethodManager::IsEmojiHandwritingVoiceOnImeMenuEnabled() { | |
| 262 return false; | |
| 263 } | |
| 264 | |
| 265 } // namespace input_method | |
| 266 } // namespace chromeos | |
| OLD | NEW |