| OLD | NEW |
| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~MockInputMethodBase() { |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 // Overriden from InputMethod. | 154 // Overriden from InputMethod. |
| 155 virtual bool OnUntranslatedIMEMessage( | 155 virtual bool OnUntranslatedIMEMessage( |
| 156 const base::NativeEvent& event, | 156 const base::NativeEvent& event, |
| 157 InputMethod::NativeEventResult* result) OVERRIDE { | 157 InputMethod::NativeEventResult* result) override { |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 virtual bool DispatchKeyEvent(const ui::KeyEvent&) OVERRIDE { | 160 virtual bool DispatchKeyEvent(const ui::KeyEvent&) override { |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE { | 163 virtual void OnCaretBoundsChanged(const TextInputClient* client) override { |
| 164 } | 164 } |
| 165 virtual void CancelComposition(const TextInputClient* client) OVERRIDE { | 165 virtual void CancelComposition(const TextInputClient* client) override { |
| 166 } | 166 } |
| 167 virtual void OnInputLocaleChanged() OVERRIDE { | 167 virtual void OnInputLocaleChanged() override { |
| 168 } | 168 } |
| 169 virtual std::string GetInputLocale() OVERRIDE{ | 169 virtual std::string GetInputLocale() override{ |
| 170 return ""; | 170 return ""; |
| 171 } | 171 } |
| 172 virtual bool IsActive() OVERRIDE { | 172 virtual bool IsActive() override { |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 virtual bool IsCandidatePopupOpen() const OVERRIDE { | 175 virtual bool IsCandidatePopupOpen() const override { |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 // Overriden from InputMethodBase. | 178 // Overriden from InputMethodBase. |
| 179 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, | 179 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before, |
| 180 TextInputClient* focused) OVERRIDE { | 180 TextInputClient* focused) override { |
| 181 verifier_->OnWillChangeFocusedClient(focused_before, focused); | 181 verifier_->OnWillChangeFocusedClient(focused_before, focused); |
| 182 } | 182 } |
| 183 | 183 |
| 184 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, | 184 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, |
| 185 TextInputClient* focused) OVERRIDE { | 185 TextInputClient* focused) override { |
| 186 verifier_->OnDidChangeFocusedClient(focused_before, focused); | 186 verifier_->OnDidChangeFocusedClient(focused_before, focused); |
| 187 } | 187 } |
| 188 | 188 |
| 189 ClientChangeVerifier* verifier_; | 189 ClientChangeVerifier* verifier_; |
| 190 | 190 |
| 191 FRIEND_TEST_ALL_PREFIXES(InputMethodBaseTest, CandidateWindowEvents); | 191 FRIEND_TEST_ALL_PREFIXES(InputMethodBaseTest, CandidateWindowEvents); |
| 192 DISALLOW_COPY_AND_ASSIGN(MockInputMethodBase); | 192 DISALLOW_COPY_AND_ASSIGN(MockInputMethodBase); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class MockInputMethodObserver : public InputMethodObserver { | 195 class MockInputMethodObserver : public InputMethodObserver { |
| 196 public: | 196 public: |
| 197 // Note: this class does not take the ownership of |verifier|. | 197 // Note: this class does not take the ownership of |verifier|. |
| 198 explicit MockInputMethodObserver(ClientChangeVerifier* verifier) | 198 explicit MockInputMethodObserver(ClientChangeVerifier* verifier) |
| 199 : verifier_(verifier) { | 199 : verifier_(verifier) { |
| 200 } | 200 } |
| 201 virtual ~MockInputMethodObserver() { | 201 virtual ~MockInputMethodObserver() { |
| 202 } | 202 } |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE { | 205 virtual void OnTextInputTypeChanged(const TextInputClient* client) override { |
| 206 } | 206 } |
| 207 virtual void OnFocus() OVERRIDE { | 207 virtual void OnFocus() override { |
| 208 } | 208 } |
| 209 virtual void OnBlur() OVERRIDE { | 209 virtual void OnBlur() override { |
| 210 } | 210 } |
| 211 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE { | 211 virtual void OnCaretBoundsChanged(const TextInputClient* client) override { |
| 212 } | 212 } |
| 213 virtual void OnTextInputStateChanged(const TextInputClient* client) OVERRIDE { | 213 virtual void OnTextInputStateChanged(const TextInputClient* client) override { |
| 214 verifier_->OnTextInputStateChanged(client); | 214 verifier_->OnTextInputStateChanged(client); |
| 215 } | 215 } |
| 216 virtual void OnShowImeIfNeeded() OVERRIDE { | 216 virtual void OnShowImeIfNeeded() override { |
| 217 } | 217 } |
| 218 virtual void OnInputMethodDestroyed(const InputMethod* client) OVERRIDE { | 218 virtual void OnInputMethodDestroyed(const InputMethod* client) override { |
| 219 } | 219 } |
| 220 | 220 |
| 221 ClientChangeVerifier* verifier_; | 221 ClientChangeVerifier* verifier_; |
| 222 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); | 222 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 class MockTextInputClient : public DummyTextInputClient { | 225 class MockTextInputClient : public DummyTextInputClient { |
| 226 public: | 226 public: |
| 227 MockTextInputClient() | 227 MockTextInputClient() |
| 228 : shown_event_count_(0), updated_event_count_(0), hidden_event_count_(0) { | 228 : shown_event_count_(0), updated_event_count_(0), hidden_event_count_(0) { |
| 229 } | 229 } |
| 230 virtual ~MockTextInputClient() { | 230 virtual ~MockTextInputClient() { |
| 231 } | 231 } |
| 232 | 232 |
| 233 virtual void OnCandidateWindowShown() OVERRIDE { | 233 virtual void OnCandidateWindowShown() override { |
| 234 ++shown_event_count_; | 234 ++shown_event_count_; |
| 235 } | 235 } |
| 236 virtual void OnCandidateWindowUpdated() OVERRIDE { | 236 virtual void OnCandidateWindowUpdated() override { |
| 237 ++updated_event_count_; | 237 ++updated_event_count_; |
| 238 } | 238 } |
| 239 virtual void OnCandidateWindowHidden() OVERRIDE { | 239 virtual void OnCandidateWindowHidden() override { |
| 240 ++hidden_event_count_; | 240 ++hidden_event_count_; |
| 241 } | 241 } |
| 242 | 242 |
| 243 int shown_event_count() const { return shown_event_count_; } | 243 int shown_event_count() const { return shown_event_count_; } |
| 244 int updated_event_count() const { return updated_event_count_; } | 244 int updated_event_count() const { return updated_event_count_; } |
| 245 int hidden_event_count() const { return hidden_event_count_; } | 245 int hidden_event_count() const { return hidden_event_count_; } |
| 246 | 246 |
| 247 private: | 247 private: |
| 248 int shown_event_count_; | 248 int shown_event_count_; |
| 249 int updated_event_count_; | 249 int updated_event_count_; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // If InputMethod is deleted immediately after an event happens, but before | 411 // If InputMethod is deleted immediately after an event happens, but before |
| 412 // its callback is invoked, the callback will be cancelled. | 412 // its callback is invoked, the callback will be cancelled. |
| 413 base::RunLoop().RunUntilIdle(); | 413 base::RunLoop().RunUntilIdle(); |
| 414 EXPECT_EQ(1, text_input_client.shown_event_count()); | 414 EXPECT_EQ(1, text_input_client.shown_event_count()); |
| 415 EXPECT_EQ(1, text_input_client.updated_event_count()); | 415 EXPECT_EQ(1, text_input_client.updated_event_count()); |
| 416 EXPECT_EQ(1, text_input_client.hidden_event_count()); | 416 EXPECT_EQ(1, text_input_client.hidden_event_count()); |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace | 419 } // namespace |
| 420 } // namespace ui | 420 } // namespace ui |
| OLD | NEW |