Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ui/base/ime/input_method_base_unittest.cc

Issue 667923002: Standardize usage of virtual/override/final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_base.h ('k') | ui/base/ime/input_method_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/ime/input_method_base.h" 5 #include "ui/base/ime/input_method_base.h"
6 6
7 #include "base/gtest_prod_util.h" 7 #include "base/gtest_prod_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 private: 140 private:
141 scoped_ptr<base::MessageLoop> message_loop_; 141 scoped_ptr<base::MessageLoop> message_loop_;
142 DISALLOW_COPY_AND_ASSIGN(InputMethodBaseTest); 142 DISALLOW_COPY_AND_ASSIGN(InputMethodBaseTest);
143 }; 143 };
144 144
145 class MockInputMethodBase : public InputMethodBase { 145 class MockInputMethodBase : public InputMethodBase {
146 public: 146 public:
147 // Note: this class does not take the ownership of |verifier|. 147 // Note: this class does not take the ownership of |verifier|.
148 MockInputMethodBase(ClientChangeVerifier* verifier) : verifier_(verifier) { 148 MockInputMethodBase(ClientChangeVerifier* verifier) : verifier_(verifier) {
149 } 149 }
150 virtual ~MockInputMethodBase() { 150 ~MockInputMethodBase() override {}
151 }
152 151
153 private: 152 private:
154 // Overriden from InputMethod. 153 // Overriden from InputMethod.
155 virtual bool OnUntranslatedIMEMessage( 154 bool OnUntranslatedIMEMessage(
156 const base::NativeEvent& event, 155 const base::NativeEvent& event,
157 InputMethod::NativeEventResult* result) override { 156 InputMethod::NativeEventResult* result) override {
158 return false; 157 return false;
159 } 158 }
160 virtual bool DispatchKeyEvent(const ui::KeyEvent&) override { 159 bool DispatchKeyEvent(const ui::KeyEvent&) override { return false; }
161 return false; 160 void OnCaretBoundsChanged(const TextInputClient* client) override {}
162 } 161 void CancelComposition(const TextInputClient* client) override {}
163 virtual void OnCaretBoundsChanged(const TextInputClient* client) override { 162 void OnInputLocaleChanged() override {}
164 } 163 std::string GetInputLocale() override { return ""; }
165 virtual void CancelComposition(const TextInputClient* client) override { 164 bool IsActive() override { return false; }
166 } 165 bool IsCandidatePopupOpen() const override { return false; }
167 virtual void OnInputLocaleChanged() override {
168 }
169 virtual std::string GetInputLocale() override{
170 return "";
171 }
172 virtual bool IsActive() override {
173 return false;
174 }
175 virtual bool IsCandidatePopupOpen() const override {
176 return false;
177 }
178 // Overriden from InputMethodBase. 166 // Overriden from InputMethodBase.
179 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, 167 void OnWillChangeFocusedClient(TextInputClient* focused_before,
180 TextInputClient* focused) override { 168 TextInputClient* focused) override {
181 verifier_->OnWillChangeFocusedClient(focused_before, focused); 169 verifier_->OnWillChangeFocusedClient(focused_before, focused);
182 } 170 }
183 171
184 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, 172 void OnDidChangeFocusedClient(TextInputClient* focused_before,
185 TextInputClient* focused) override { 173 TextInputClient* focused) override {
186 verifier_->OnDidChangeFocusedClient(focused_before, focused); 174 verifier_->OnDidChangeFocusedClient(focused_before, focused);
187 } 175 }
188 176
189 ClientChangeVerifier* verifier_; 177 ClientChangeVerifier* verifier_;
190 178
191 FRIEND_TEST_ALL_PREFIXES(InputMethodBaseTest, CandidateWindowEvents); 179 FRIEND_TEST_ALL_PREFIXES(InputMethodBaseTest, CandidateWindowEvents);
192 DISALLOW_COPY_AND_ASSIGN(MockInputMethodBase); 180 DISALLOW_COPY_AND_ASSIGN(MockInputMethodBase);
193 }; 181 };
194 182
195 class MockInputMethodObserver : public InputMethodObserver { 183 class MockInputMethodObserver : public InputMethodObserver {
196 public: 184 public:
197 // Note: this class does not take the ownership of |verifier|. 185 // Note: this class does not take the ownership of |verifier|.
198 explicit MockInputMethodObserver(ClientChangeVerifier* verifier) 186 explicit MockInputMethodObserver(ClientChangeVerifier* verifier)
199 : verifier_(verifier) { 187 : verifier_(verifier) {
200 } 188 }
201 virtual ~MockInputMethodObserver() { 189 ~MockInputMethodObserver() override {}
202 }
203 190
204 private: 191 private:
205 virtual void OnTextInputTypeChanged(const TextInputClient* client) override { 192 void OnTextInputTypeChanged(const TextInputClient* client) override {}
206 } 193 void OnFocus() override {}
207 virtual void OnFocus() override { 194 void OnBlur() override {}
208 } 195 void OnCaretBoundsChanged(const TextInputClient* client) override {}
209 virtual void OnBlur() override { 196 void OnTextInputStateChanged(const TextInputClient* client) override {
210 }
211 virtual void OnCaretBoundsChanged(const TextInputClient* client) override {
212 }
213 virtual void OnTextInputStateChanged(const TextInputClient* client) override {
214 verifier_->OnTextInputStateChanged(client); 197 verifier_->OnTextInputStateChanged(client);
215 } 198 }
216 virtual void OnShowImeIfNeeded() override { 199 void OnShowImeIfNeeded() override {}
217 } 200 void OnInputMethodDestroyed(const InputMethod* client) override {}
218 virtual void OnInputMethodDestroyed(const InputMethod* client) override {
219 }
220 201
221 ClientChangeVerifier* verifier_; 202 ClientChangeVerifier* verifier_;
222 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); 203 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver);
223 }; 204 };
224 205
225 class MockTextInputClient : public DummyTextInputClient { 206 class MockTextInputClient : public DummyTextInputClient {
226 public: 207 public:
227 MockTextInputClient() 208 MockTextInputClient()
228 : shown_event_count_(0), updated_event_count_(0), hidden_event_count_(0) { 209 : shown_event_count_(0), updated_event_count_(0), hidden_event_count_(0) {
229 } 210 }
230 virtual ~MockTextInputClient() { 211 ~MockTextInputClient() override {}
231 }
232 212
233 virtual void OnCandidateWindowShown() override { 213 void OnCandidateWindowShown() override { ++shown_event_count_; }
234 ++shown_event_count_; 214 void OnCandidateWindowUpdated() override { ++updated_event_count_; }
235 } 215 void OnCandidateWindowHidden() override { ++hidden_event_count_; }
236 virtual void OnCandidateWindowUpdated() override {
237 ++updated_event_count_;
238 }
239 virtual void OnCandidateWindowHidden() override {
240 ++hidden_event_count_;
241 }
242 216
243 int shown_event_count() const { return shown_event_count_; } 217 int shown_event_count() const { return shown_event_count_; }
244 int updated_event_count() const { return updated_event_count_; } 218 int updated_event_count() const { return updated_event_count_; }
245 int hidden_event_count() const { return hidden_event_count_; } 219 int hidden_event_count() const { return hidden_event_count_; }
246 220
247 private: 221 private:
248 int shown_event_count_; 222 int shown_event_count_;
249 int updated_event_count_; 223 int updated_event_count_;
250 int hidden_event_count_; 224 int hidden_event_count_;
251 }; 225 };
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // If InputMethod is deleted immediately after an event happens, but before 385 // If InputMethod is deleted immediately after an event happens, but before
412 // its callback is invoked, the callback will be cancelled. 386 // its callback is invoked, the callback will be cancelled.
413 base::RunLoop().RunUntilIdle(); 387 base::RunLoop().RunUntilIdle();
414 EXPECT_EQ(1, text_input_client.shown_event_count()); 388 EXPECT_EQ(1, text_input_client.shown_event_count());
415 EXPECT_EQ(1, text_input_client.updated_event_count()); 389 EXPECT_EQ(1, text_input_client.updated_event_count());
416 EXPECT_EQ(1, text_input_client.hidden_event_count()); 390 EXPECT_EQ(1, text_input_client.hidden_event_count());
417 } 391 }
418 392
419 } // namespace 393 } // namespace
420 } // namespace ui 394 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_base.h ('k') | ui/base/ime/input_method_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698