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

Side by Side Diff: views/ime/mock_input_method.h

Issue 6688049: New InputMethod api for Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add InputMethodWin. Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
(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 VIEWS_IME_MOCK_INPUT_METHOD_H_
6 #define VIEWS_IME_MOCK_INPUT_METHOD_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "views/focus/focus_manager.h"
12 #include "views/ime/input_method.h"
13 #include "views/ime/input_method_delegate.h"
14 #include "views/ime/text_input_client.h"
15 #include "views/view.h"
16
17 namespace views {
18
19 // A mock InputMethod implementation for testing purpose.
20 class MockInputMethod : public InputMethod,
21 public FocusChangeListener {
22 public:
23 MockInputMethod();
24 virtual ~MockInputMethod();
25
26 // Overridden from InputMethod:
27 virtual void set_delegate(internal::InputMethodDelegate* delegate) OVERRIDE;
28 virtual void Init(Widget* widget) OVERRIDE;
29 virtual void DispatchKeyEvent(const KeyEvent& key) OVERRIDE;
30 virtual void OnTextInputTypeChanged(View* view) OVERRIDE;
31 virtual void OnCaretBoundsChanged(View* view) OVERRIDE;
32 virtual void CancelComposition(View* view) OVERRIDE;
33 virtual std::string GetInputLocale() OVERRIDE;
34 virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE;
35 virtual bool IsActive() OVERRIDE;
36
37 // Overridden from FocusChangeListener:
38 virtual void FocusWillChange(View* focused_before, View* focused) OVERRIDE;
39
40 bool focus_changed() const { return focus_changed_; }
41 bool text_input_type_changed() const { return text_input_type_changed_; }
42 bool caret_bounds_changed() const { return caret_bounds_changed_; }
43 bool cancel_composition_called() const { return cancel_composition_called_; }
44
45 ui::TextInputType GetTextInputType() const;
46
47 // Clears all internal states and result.
48 void Clear();
49
50 void SetCompositionForNextKey(const ui::Composition& composition);
51 void SetResultForNextKey(const string16& result);
52
53 void SetInputLocale(const std::string& locale);
54 void SetInputTextDirection(base::i18n::TextDirection direction);
55 void SetActive(bool active);
56
57 private:
58 // Clears boolean states defined below.
59 void ClearStates();
60
61 // Clears only composition information and result text.
62 void ClearResult();
63
64 TextInputClient* GetTextInputClient() const;
65
66 // Convenience method to call TextInputClient::OnInputMethodChanged().
67 void OnInputMethodChanged() const;
68
69 internal::InputMethodDelegate* delegate_;
70 Widget* widget_;
71 View* focused_view_;
72
73 // Composition information for the next key event. It'll be cleared
74 // automatically after dispatching the next key event.
75 ui::Composition composition_;
76 bool composition_changed_;
77
78 // Result text for the next key event. It'll be cleared automatically after
79 // dispatching the next key event.
80 string16 result_text_;
81
82 // Record call state of corresponding methods. They will be set to false
83 // automatically before dispatching a key event.
84 bool focus_changed_;
85 bool text_input_type_changed_;
86 bool caret_bounds_changed_;
87 bool cancel_composition_called_;
88
89 // To mock corresponding input method prooperties.
90 std::string locale_;
91 base::i18n::TextDirection direction_;
92 bool active_;
93 };
94
95 } // namespace views
96
97 #endif // VIEWS_IME_MOCK_INPUT_METHOD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698