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 set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE; |
| 27 virtual void set_text_input_client(TextInputClient* client) OVERRIDE; |
| 28 virtual TextInputClient* text_input_client() const OVERRIDE; |
| 29 virtual void Init() OVERRIDE; |
| 30 virtual void DispatchKeyEvent(gfx::NativeEvent native_event) OVERRIDE; |
| 31 virtual void OnTextInputTypeChanged(gfx::NativeWindow window) OVERRIDE; |
| 32 virtual void OnCaretBoundsChanged(gfx::NativeWindow window) OVERRIDE; |
| 33 virtual void CancelComposition(gfx::NativeWindow window) OVERRIDE; |
| 34 virtual std::string GetInputLocale() OVERRIDE; |
| 35 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; |
| 36 virtual bool IsActive() OVERRIDE; |
| 37 virtual ui::TextInputType GetTextInputType() const OVERRIDE; |
| 38 |
| 39 // If called, the next key press will not generate a Char event. Instead, it |
| 40 // will generate the VKEY_PROCESSKEY RawKeyDown event. |
| 41 void ConsumeNextKey(); |
| 42 |
| 43 // Sends VKEY_PROCESSKEY. |
| 44 void SendFakeProcessKeyEvent(bool pressed, int flags) const; |
| 45 |
| 46 private: |
| 47 internal::InputMethodDelegate* delegate_; |
| 48 TextInputClient* text_input_client_; |
| 49 bool consume_next_key_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(MockInputMethod); |
| 52 }; |
| 53 |
| 54 } // namespace ui |
| 55 |
| 56 #endif // UI_BASE_IME_MOCK_INPUT_METHOD_H_ |
OLD | NEW |