1
#ifndef UT_MINPUTCONTEXT_H
2
#define UT_MINPUTCONTEXT_H
6
#include <QtTest/QtTest>
9
#include <minputcontext.h>
10
#include <mimserverconnection.h>
12
class InputMethodServerTestConnection: public MImServerConnection
17
struct RedirectedKeyParamsStruct {
24
InputMethodServerTestConnection(QObject *parent = 0);
25
virtual ~InputMethodServerTestConnection();
27
// method calls are counted, this resets counters
28
void resetCallCounts();
31
// returns counter for specific methods
32
int showInputMethodCount();
33
int hideInputMethodCount();
34
int mouseClickedOnPreeditCount();
35
int setPreeditCount();
38
int activateContextCount();
40
int orientationChangedCount();
42
const QString &lastPreedit();
44
int setCopyPasteStateCount();
45
QList<bool> &setCopyPasteStateParams();
47
int redirectKeyCount();
48
RedirectedKeyParamsStruct &redirectKeyParams();
52
virtual void showInputMethod();
53
virtual void hideInputMethod();
54
virtual void mouseClickedOnPreedit(const QPoint &pos, const QRect &preeditRect);
55
virtual void setPreedit(const QString &text, int cursorPos);
56
virtual void reset(bool);
58
virtual void activateContext();
60
virtual void appOrientationChanged(int angle);
62
virtual void setCopyPasteState(bool copyAvailable, bool pasteAvailable);
64
virtual void processKeyEvent(QEvent::Type keyType, Qt::Key keyCode,
65
Qt::KeyboardModifiers modifiers,
66
const QString &text, bool autoRepeat, int count,
67
quint32 nativeScanCode, quint32 nativeModifiers,
72
int showInputMethodCallCount;
73
int hideInputMethodCallCount;
74
int mouseClickedOnPreeditCallCount;
75
int setPreeditCallCount;
78
int activateContextCallCount;
79
int appOrientationChangedCount;
81
int setCopyPasteStateCallCount;
82
QList<bool> setCopyPasteStateCallParams;
83
int redirectKeyCallCount;
84
RedirectedKeyParamsStruct redirectKeyCallParams;
85
QString lastPreeditString;
86
int lastPreeditCursorPos;
90
class WidgetStub: public QWidget
95
WidgetStub(QObject *, bool enableVisualizationPriority = false);
96
virtual ~WidgetStub();
98
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
99
virtual void inputMethodEvent(QInputMethodEvent *event);
100
virtual bool event(QEvent *event);
102
void resetCounters();
103
int inputMethodQueryCount();
104
int inputMethodEventCount();
106
QInputMethodEvent lastInputMethodEvent();
107
QKeyEvent lastKeyEvent();
109
void sendCopyAvailable(bool yes);
111
QString selectedText;
114
void copyAvailable(bool);
117
mutable int m_inputMethodQueryCount;
118
mutable int m_inputMethodEventCount;
119
mutable QInputMethodEvent m_lastImEvent;
121
QKeyEvent m_lastKeyEvent;
122
bool visualizationPriority;
127
class Ut_MInputContext : public QObject
133
void cleanupTestCase();
138
// input context interface
139
void testAddCoverage();
142
void testMouseHandler();
144
//void testSetFocusWidget();
146
// test outbound input method server communication
147
void testInputMethodHidden();
148
void testCommitString_data();
149
void testCommitString();
150
void testUpdatePreedit();
151
void testAppOrientationChanged();
153
// test inbound input method server communication
154
void testImAreaChangePropagation();
155
void testImInitiatedHideUnfocusesWidget();
156
void testImCommitStringInjection();
157
void testImSelectionInjection();
158
void testImGetSelection();
160
void testNonTextEntryWidget();
162
// FIXME: do separate tests for qgraphics based widget stub?
163
// FIXME: test non-input enabled widgets?
165
//test copy/paste stuff
166
void testCopyPasteState();
168
void testSetRedirectKeys();
170
void testInvalidScene();
172
void testPropertyNameNormalization_data();
173
void testPropertyNameNormalization();
176
void waitAndProcessEvents(int waitTime);
179
QPointer<MInputContext> m_subject;
180
QSharedPointer<InputMethodServerTestConnection> m_connection;