Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/mock_input_method_manager_impl.cc |
| diff --git a/chrome/browser/chromeos/input_method/mock_input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/mock_input_method_manager_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e2e0b0c93ddfcc18aebadcb2f5559dddc8bc75ef |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/input_method/mock_input_method_manager_impl.cc |
| @@ -0,0 +1,201 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/input_method/mock_input_method_manager_impl.h" |
| + |
| +#include <utility> |
| + |
| +namespace chromeos { |
| +namespace input_method { |
| + |
| +MockInputMethodManagerImpl::State::State(MockInputMethodManagerImpl* manager) |
| + : manager_(manager) { |
| + active_input_method_ids.push_back("xkb:us::eng"); |
| +} |
| + |
| +MockInputMethodManagerImpl::State::~State() {} |
| + |
| +MockInputMethodManagerImpl::MockInputMethodManagerImpl() |
| + : add_observer_count_(0), |
| + remove_observer_count_(0), |
| + state_(new State(this)), |
| + util_(&delegate_), |
| + mod3_used_(false) {} |
| + |
| +MockInputMethodManagerImpl::~MockInputMethodManagerImpl() {} |
| + |
| +void MockInputMethodManagerImpl::AddObserver( |
| + InputMethodManager::Observer* observer) { |
| + ++add_observer_count_; |
| +} |
| + |
| +void MockInputMethodManagerImpl::RemoveObserver( |
| + InputMethodManager::Observer* observer) { |
| + ++remove_observer_count_; |
| +} |
| + |
| +std::unique_ptr<InputMethodDescriptors> |
| +MockInputMethodManagerImpl::GetSupportedInputMethods() const { |
| + std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
| + result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor()); |
| + return result; |
| +} |
| + |
| +std::unique_ptr<InputMethodDescriptors> |
| +MockInputMethodManagerImpl::State::GetActiveInputMethods() const { |
| + std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
| + result->push_back(InputMethodUtil::GetFallbackInputMethodDescriptor()); |
| + return result; |
| +} |
| + |
| +const std::vector<std::string>& |
| +MockInputMethodManagerImpl::State::GetActiveInputMethodIds() const { |
| + return active_input_method_ids; |
| +} |
| + |
| +size_t MockInputMethodManagerImpl::State::GetNumActiveInputMethods() const { |
| + return 1; |
| +} |
| + |
| +const InputMethodDescriptor* |
| +MockInputMethodManagerImpl::State::GetInputMethodFromId( |
| + const std::string& input_method_id) const { |
| + static const InputMethodDescriptor defaultInputMethod = |
| + InputMethodUtil::GetFallbackInputMethodDescriptor(); |
| + for (size_t i = 0; i < active_input_method_ids.size(); i++) { |
| + if (input_method_id == active_input_method_ids[i]) { |
| + return &defaultInputMethod; |
| + } |
| + } |
| + return NULL; |
| +} |
| + |
| +void MockInputMethodManagerImpl::State::EnableLoginLayouts( |
| + const std::string& language_code, |
| + const std::vector<std::string>& initial_layout) {} |
| + |
| +void MockInputMethodManagerImpl::State::EnableLockScreenLayouts() {} |
| + |
| +bool MockInputMethodManagerImpl::State::ReplaceEnabledInputMethods( |
| + const std::vector<std::string>& new_active_input_method_ids) { |
| + return true; |
| +} |
|
stevenjb
2016/12/28 18:28:13
Any trivial methods like this should just be part
Azure Wei
2017/01/03 09:56:22
Done.
|
| + |
| +bool MockInputMethodManagerImpl::State::EnableInputMethod( |
| + const std::string& new_active_input_method_id) { |
| + return true; |
| +} |
| + |
| +void MockInputMethodManagerImpl::State::ChangeInputMethod( |
| + const std::string& input_method_id, |
| + bool show_message) {} |
| + |
| +void MockInputMethodManagerImpl::State::AddInputMethodExtension( |
| + const std::string& extension_id, |
| + const InputMethodDescriptors& descriptors, |
| + ui::IMEEngineHandlerInterface* instance) {} |
| + |
| +void MockInputMethodManagerImpl::State::RemoveInputMethodExtension( |
| + const std::string& extension_id) {} |
| + |
| +void MockInputMethodManagerImpl::State::GetInputMethodExtensions( |
| + InputMethodDescriptors* result) {} |
| + |
| +void MockInputMethodManagerImpl::State::SetEnabledExtensionImes( |
| + std::vector<std::string>* ids) {} |
| + |
| +void MockInputMethodManagerImpl::State::SetInputMethodLoginDefault() {} |
| + |
| +void MockInputMethodManagerImpl::State::SetInputMethodLoginDefaultFromVPD( |
| + const std::string& locale, |
| + const std::string& layout) {} |
| + |
| +bool MockInputMethodManagerImpl::State::CanCycleInputMethod() { |
| + return true; |
| +} |
| + |
| +void MockInputMethodManagerImpl::State::SwitchToNextInputMethod() {} |
| + |
| +void MockInputMethodManagerImpl::State::SwitchToPreviousInputMethod() {} |
| + |
| +bool MockInputMethodManagerImpl::State::CanSwitchInputMethod( |
| + const ui::Accelerator& accelerator) { |
| + return true; |
| +} |
| + |
| +void MockInputMethodManagerImpl::State::SwitchInputMethod( |
| + const ui::Accelerator& accelerator) {} |
| + |
| +InputMethodDescriptor MockInputMethodManagerImpl::State::GetCurrentInputMethod() |
| + const { |
| + InputMethodDescriptor descriptor = |
| + InputMethodUtil::GetFallbackInputMethodDescriptor(); |
| + if (!current_input_method_id.empty()) { |
| + return InputMethodDescriptor( |
| + current_input_method_id, descriptor.name(), descriptor.indicator(), |
| + descriptor.keyboard_layouts(), descriptor.language_codes(), true, |
| + GURL(), // options page url. |
| + GURL()); // input view page url. |
| + } |
| + return descriptor; |
| +} |
| + |
| +bool MockInputMethodManagerImpl::IsISOLevel5ShiftUsedByCurrentInputMethod() |
| + const { |
| + return mod3_used_; |
| +} |
| + |
| +ImeKeyboard* MockInputMethodManagerImpl::GetImeKeyboard() { |
| + return &keyboard_; |
| +} |
| + |
| +InputMethodUtil* MockInputMethodManagerImpl::GetInputMethodUtil() { |
| + return &util_; |
| +} |
| + |
| +ComponentExtensionIMEManager* |
| +MockInputMethodManagerImpl::GetComponentExtensionIMEManager() { |
| + return comp_ime_manager_.get(); |
| +} |
| + |
| +void MockInputMethodManagerImpl::SetComponentExtensionIMEManager( |
| + std::unique_ptr<ComponentExtensionIMEManager> comp_ime_manager) { |
| + comp_ime_manager_ = std::move(comp_ime_manager); |
| +} |
| + |
| +void MockInputMethodManagerImpl::set_application_locale( |
| + const std::string& value) { |
| + delegate_.set_active_locale(value); |
| +} |
| + |
| +scoped_refptr<InputMethodManager::State> |
| +MockInputMethodManagerImpl::CreateNewState(Profile* profile) { |
| + NOTIMPLEMENTED(); |
| + return state_; |
| +} |
| + |
| +scoped_refptr<InputMethodManager::State> |
| +MockInputMethodManagerImpl::GetActiveIMEState() { |
| + return scoped_refptr<InputMethodManager::State>(state_.get()); |
| +} |
| + |
| +scoped_refptr<InputMethodManager::State> |
| +MockInputMethodManagerImpl::State::Clone() const { |
| + NOTIMPLEMENTED(); |
| + return manager_->GetActiveIMEState(); |
| +} |
| + |
| +void MockInputMethodManagerImpl::SetState( |
| + scoped_refptr<InputMethodManager::State> state) { |
| + state_ = scoped_refptr<MockInputMethodManagerImpl::State>( |
| + static_cast<MockInputMethodManagerImpl::State*>(state.get())); |
| +} |
| + |
| +void MockInputMethodManagerImpl::SetCurrentInputMethodId( |
| + const std::string& input_method_id) { |
| + state_->current_input_method_id = input_method_id; |
| +} |
| + |
| +} // namespace input_method |
| +} // namespace chromeos |