OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 5 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
6 | 6 |
7 namespace chromeos { | 7 namespace chromeos { |
8 namespace input_method { | 8 namespace input_method { |
9 | 9 |
| 10 MockInputMethodManager::State::State(MockInputMethodManager* manager) |
| 11 : manager_(manager) { |
| 12 active_input_method_ids.push_back("xkb:us::eng"); |
| 13 } |
| 14 |
| 15 MockInputMethodManager::State::~State() { |
| 16 } |
| 17 |
10 MockInputMethodManager::MockInputMethodManager() | 18 MockInputMethodManager::MockInputMethodManager() |
11 : add_observer_count_(0), | 19 : add_observer_count_(0), |
12 remove_observer_count_(0), | 20 remove_observer_count_(0), |
| 21 state_(new State(this)), |
13 util_(&delegate_), | 22 util_(&delegate_), |
14 mod3_used_(false) { | 23 mod3_used_(false) { |
15 active_input_method_ids_.push_back("xkb:us::eng"); | |
16 } | 24 } |
17 | 25 |
18 MockInputMethodManager::~MockInputMethodManager() { | 26 MockInputMethodManager::~MockInputMethodManager() { |
19 } | 27 } |
20 | 28 |
21 InputMethodManager::State MockInputMethodManager::GetState() { | 29 InputMethodManager::UISessionState MockInputMethodManager::GetUISessionState() { |
22 return InputMethodManager::STATE_BROWSER_SCREEN; | 30 return InputMethodManager::STATE_BROWSER_SCREEN; |
23 } | 31 } |
24 | 32 |
25 void MockInputMethodManager::AddObserver( | 33 void MockInputMethodManager::AddObserver( |
26 InputMethodManager::Observer* observer) { | 34 InputMethodManager::Observer* observer) { |
27 ++add_observer_count_; | 35 ++add_observer_count_; |
28 } | 36 } |
29 | 37 |
30 void MockInputMethodManager::AddCandidateWindowObserver( | 38 void MockInputMethodManager::AddCandidateWindowObserver( |
31 InputMethodManager::CandidateWindowObserver* observer) { | 39 InputMethodManager::CandidateWindowObserver* observer) { |
(...skipping 10 matching lines...) Expand all Loading... |
42 | 50 |
43 scoped_ptr<InputMethodDescriptors> | 51 scoped_ptr<InputMethodDescriptors> |
44 MockInputMethodManager::GetSupportedInputMethods() const { | 52 MockInputMethodManager::GetSupportedInputMethods() const { |
45 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | 53 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
46 result->push_back( | 54 result->push_back( |
47 InputMethodUtil::GetFallbackInputMethodDescriptor()); | 55 InputMethodUtil::GetFallbackInputMethodDescriptor()); |
48 return result.Pass(); | 56 return result.Pass(); |
49 } | 57 } |
50 | 58 |
51 scoped_ptr<InputMethodDescriptors> | 59 scoped_ptr<InputMethodDescriptors> |
52 MockInputMethodManager::GetActiveInputMethods() const { | 60 MockInputMethodManager::State::GetActiveInputMethods() const { |
53 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); | 61 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); |
54 result->push_back( | 62 result->push_back( |
55 InputMethodUtil::GetFallbackInputMethodDescriptor()); | 63 InputMethodUtil::GetFallbackInputMethodDescriptor()); |
56 return result.Pass(); | 64 return result.Pass(); |
57 } | 65 } |
58 | 66 |
59 const std::vector<std::string>& | 67 const std::vector<std::string>& |
60 MockInputMethodManager::GetActiveInputMethodIds() const { | 68 MockInputMethodManager::State::GetActiveInputMethodIds() const { |
61 return active_input_method_ids_; | 69 return active_input_method_ids; |
62 } | 70 } |
63 | 71 |
64 size_t MockInputMethodManager::GetNumActiveInputMethods() const { | 72 size_t MockInputMethodManager::State::GetNumActiveInputMethods() const { |
65 return 1; | 73 return 1; |
66 } | 74 } |
67 | 75 |
68 const InputMethodDescriptor* MockInputMethodManager::GetInputMethodFromId( | 76 const InputMethodDescriptor* |
| 77 MockInputMethodManager::State::GetInputMethodFromId( |
69 const std::string& input_method_id) const { | 78 const std::string& input_method_id) const { |
70 static const InputMethodDescriptor defaultInputMethod = | 79 static const InputMethodDescriptor defaultInputMethod = |
71 InputMethodUtil::GetFallbackInputMethodDescriptor(); | 80 InputMethodUtil::GetFallbackInputMethodDescriptor(); |
72 for (size_t i = 0; i < active_input_method_ids_.size(); i++) { | 81 for (size_t i = 0; i < active_input_method_ids.size(); i++) { |
73 if (input_method_id == active_input_method_ids_[i]) { | 82 if (input_method_id == active_input_method_ids[i]) { |
74 return &defaultInputMethod; | 83 return &defaultInputMethod; |
75 } | 84 } |
76 } | 85 } |
77 return NULL; | 86 return NULL; |
78 } | 87 } |
79 | 88 |
80 void MockInputMethodManager::EnableLoginLayouts( | 89 void MockInputMethodManager::State::EnableLoginLayouts( |
81 const std::string& language_code, | 90 const std::string& language_code, |
82 const std::vector<std::string>& initial_layout) { | 91 const std::vector<std::string>& initial_layout) { |
83 } | 92 } |
84 | 93 |
85 bool MockInputMethodManager::ReplaceEnabledInputMethods( | 94 void MockInputMethodManager::State::EnableLockScreenLayouts() { |
| 95 } |
| 96 |
| 97 bool MockInputMethodManager::State::ReplaceEnabledInputMethods( |
86 const std::vector<std::string>& new_active_input_method_ids) { | 98 const std::vector<std::string>& new_active_input_method_ids) { |
87 return true; | 99 return true; |
88 } | 100 } |
89 | 101 |
90 bool MockInputMethodManager::EnableInputMethod( | 102 bool MockInputMethodManager::State::EnableInputMethod( |
91 const std::string& new_active_input_method_id) { | 103 const std::string& new_active_input_method_id) { |
92 return true; | 104 return true; |
93 } | 105 } |
94 | 106 |
95 void MockInputMethodManager::ChangeInputMethod( | 107 void MockInputMethodManager::State::ChangeInputMethod( |
96 const std::string& input_method_id) { | 108 const std::string& input_method_id, |
| 109 bool show_message) { |
97 } | 110 } |
98 | 111 |
99 void MockInputMethodManager::ActivateInputMethodMenuItem( | 112 void MockInputMethodManager::ActivateInputMethodMenuItem( |
100 const std::string& key) { | 113 const std::string& key) { |
101 } | 114 } |
102 | 115 |
103 void MockInputMethodManager::AddInputMethodExtension( | 116 void MockInputMethodManager::State::AddInputMethodExtension( |
104 const std::string& extension_id, | 117 const std::string& extension_id, |
105 const InputMethodDescriptors& descriptors, | 118 const InputMethodDescriptors& descriptors, |
106 InputMethodEngineInterface* instance) { | 119 InputMethodEngineInterface* instance) { |
107 } | 120 } |
108 | 121 |
109 void MockInputMethodManager::RemoveInputMethodExtension( | 122 void MockInputMethodManager::State::RemoveInputMethodExtension( |
110 const std::string& extension_id) { | 123 const std::string& extension_id) { |
111 } | 124 } |
112 | 125 |
113 void MockInputMethodManager::GetInputMethodExtensions( | 126 void MockInputMethodManager::State::GetInputMethodExtensions( |
114 InputMethodDescriptors* result) { | 127 InputMethodDescriptors* result) { |
115 } | 128 } |
116 | 129 |
117 void MockInputMethodManager::SetEnabledExtensionImes( | 130 void MockInputMethodManager::State::SetEnabledExtensionImes( |
118 std::vector<std::string>* ids) { | 131 std::vector<std::string>* ids) { |
119 } | 132 } |
120 | 133 |
121 void MockInputMethodManager::SetInputMethodLoginDefault() { | 134 void MockInputMethodManager::State::SetInputMethodLoginDefault() { |
122 } | 135 } |
123 | 136 |
124 void MockInputMethodManager::SetInputMethodLoginDefaultFromVPD( | 137 void MockInputMethodManager::State::SetInputMethodLoginDefaultFromVPD( |
125 const std::string& locale, const std::string& layout) { | 138 const std::string& locale, |
| 139 const std::string& layout) { |
126 } | 140 } |
127 | 141 |
128 bool MockInputMethodManager::SwitchToNextInputMethod() { | 142 bool MockInputMethodManager::State::SwitchToNextInputMethod() { |
129 return true; | 143 return true; |
130 } | 144 } |
131 | 145 |
132 bool MockInputMethodManager::SwitchToPreviousInputMethod( | 146 bool MockInputMethodManager::State::SwitchToPreviousInputMethod( |
133 const ui::Accelerator& accelerator) { | 147 const ui::Accelerator& accelerator) { |
134 return true; | 148 return true; |
135 } | 149 } |
136 | 150 |
137 bool MockInputMethodManager::SwitchInputMethod( | 151 bool MockInputMethodManager::State::SwitchInputMethod( |
138 const ui::Accelerator& accelerator) { | 152 const ui::Accelerator& accelerator) { |
139 return true; | 153 return true; |
140 } | 154 } |
141 | 155 |
142 InputMethodDescriptor MockInputMethodManager::GetCurrentInputMethod() const { | 156 InputMethodDescriptor MockInputMethodManager::State::GetCurrentInputMethod() |
| 157 const { |
143 InputMethodDescriptor descriptor = | 158 InputMethodDescriptor descriptor = |
144 InputMethodUtil::GetFallbackInputMethodDescriptor(); | 159 InputMethodUtil::GetFallbackInputMethodDescriptor(); |
145 if (!current_input_method_id_.empty()) { | 160 if (!current_input_method_id.empty()) { |
146 return InputMethodDescriptor(current_input_method_id_, | 161 return InputMethodDescriptor(current_input_method_id, |
147 descriptor.name(), | 162 descriptor.name(), |
148 descriptor.indicator(), | 163 descriptor.indicator(), |
149 descriptor.keyboard_layouts(), | 164 descriptor.keyboard_layouts(), |
150 descriptor.language_codes(), | 165 descriptor.language_codes(), |
151 true, | 166 true, |
152 GURL(), // options page url. | 167 GURL(), // options page url. |
153 GURL()); // input view page url. | 168 GURL()); // input view page url. |
154 } | 169 } |
155 return descriptor; | 170 return descriptor; |
156 } | 171 } |
157 | 172 |
158 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const { | 173 bool MockInputMethodManager::IsISOLevel5ShiftUsedByCurrentInputMethod() const { |
159 return mod3_used_; | 174 return mod3_used_; |
160 } | 175 } |
161 | 176 |
162 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const { | 177 bool MockInputMethodManager::IsAltGrUsedByCurrentInputMethod() const { |
(...skipping 22 matching lines...) Expand all Loading... |
185 | 200 |
186 bool MockInputMethodManager::IsLoginKeyboard( | 201 bool MockInputMethodManager::IsLoginKeyboard( |
187 const std::string& layout) const { | 202 const std::string& layout) const { |
188 return true; | 203 return true; |
189 } | 204 } |
190 | 205 |
191 bool MockInputMethodManager::MigrateInputMethods( | 206 bool MockInputMethodManager::MigrateInputMethods( |
192 std::vector<std::string>* input_method_ids) { | 207 std::vector<std::string>* input_method_ids) { |
193 return false; | 208 return false; |
194 } | 209 } |
| 210 scoped_refptr<InputMethodManager::State> MockInputMethodManager::CreateNewState( |
| 211 Profile* profile) { |
| 212 NOTIMPLEMENTED(); |
| 213 return state_; |
| 214 } |
| 215 |
| 216 scoped_refptr<InputMethodManager::State> |
| 217 MockInputMethodManager::GetActiveIMEState() { |
| 218 return scoped_refptr<InputMethodManager::State>(state_.get()); |
| 219 } |
| 220 |
| 221 scoped_refptr<InputMethodManager::State> MockInputMethodManager::State::Clone() |
| 222 const { |
| 223 NOTIMPLEMENTED(); |
| 224 return manager_->GetActiveIMEState(); |
| 225 } |
| 226 |
| 227 void MockInputMethodManager::SetState( |
| 228 scoped_refptr<InputMethodManager::State> state) { |
| 229 state_ = scoped_refptr<MockInputMethodManager::State>( |
| 230 static_cast<MockInputMethodManager::State*>(state.get())); |
| 231 } |
| 232 |
| 233 void MockInputMethodManager::SetCurrentInputMethodId( |
| 234 const std::string& input_method_id) { |
| 235 state_->current_input_method_id = input_method_id; |
| 236 } |
195 | 237 |
196 } // namespace input_method | 238 } // namespace input_method |
197 } // namespace chromeos | 239 } // namespace chromeos |
OLD | NEW |