OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_BASE_IME_MOCK_INPUT_METHOD_H_ |
| 6 #define UI_BASE_IME_MOCK_INPUT_METHOD_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "ui/base/ime/input_method.h" |
| 12 #include "ui/base/ui_export.h" |
| 13 |
| 14 namespace ui { |
| 15 |
| 16 class TextInputClient; |
| 17 |
| 18 // A mock InputMethod implementation for testing classes that use the |
| 19 // ui::InputMethod interface such as aura::DesktopHost. |
| 20 class UI_EXPORT MockInputMethod : public InputMethod { |
| 21 public: |
| 22 explicit MockInputMethod(internal::InputMethodDelegate* delegate); |
| 23 virtual ~MockInputMethod(); |
| 24 |
| 25 // Overriden from InputMethod. |
| 26 virtual void SetDelegate(internal::InputMethodDelegate* delegate) OVERRIDE; |
| 27 virtual void Init(bool focused) OVERRIDE; |
| 28 virtual void OnFocus() OVERRIDE; |
| 29 virtual void OnBlur() OVERRIDE; |
| 30 virtual void SetFocusedTextInputClient(TextInputClient* client) OVERRIDE; |
| 31 virtual TextInputClient* GetTextInputClient() const OVERRIDE; |
| 32 virtual void DispatchKeyEvent(const base::NativeEvent& native_event) OVERRIDE; |
| 33 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; |
| 34 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE; |
| 35 virtual void CancelComposition(const TextInputClient* client) OVERRIDE; |
| 36 virtual std::string GetInputLocale() OVERRIDE; |
| 37 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 38 virtual bool IsActive() OVERRIDE; |
| 39 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
| 40 |
| 41 // If called, the next key press will not generate a Char event. Instead, it |
| 42 // will generate the VKEY_PROCESSKEY RawKeyDown event. |
| 43 void ConsumeNextKey(); |
| 44 |
| 45 // Sends VKEY_PROCESSKEY. |
| 46 void SendFakeProcessKeyEvent(bool pressed, int flags) const; |
| 47 |
| 48 private: |
| 49 internal::InputMethodDelegate* delegate_; |
| 50 TextInputClient* text_input_client_; |
| 51 bool consume_next_key_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(MockInputMethod); |
| 54 }; |
| 55 |
| 56 } // namespace ui |
| 57 |
| 58 #endif // UI_BASE_IME_MOCK_INPUT_METHOD_H_ |
OLD | NEW |