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