~michael-sheldon/ubuntu/utopic/maliit-framework/fix-orientation-updates

« back to all changes in this revision

Viewing changes to tests/ut_minputcontext/ut_minputcontext.h

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo, Sergio Schvezov, Ricardo Salveti de Araujo
  • Date: 2013-07-23 19:47:04 UTC
  • mfrom: (1.1.2) (1.2.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130723194704-1lsy1kmlda069cea
Tags: 0.99.0+git20130615+97e8335-0ubuntu1
[ Sergio Schvezov ]
* New build from HEAD 97e8335.
* Packaging import from lp:phablet-extras/maliit-framework.

[ Ricardo Salveti de Araujo ]
* debian/control: adding vcs and fixing dependencies
* General package cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef UT_MINPUTCONTEXT_H
2
 
#define UT_MINPUTCONTEXT_H
3
 
 
4
 
#include <memory>
5
 
#include <QPointer>
6
 
#include <QtTest/QtTest>
7
 
#include <QObject>
8
 
 
9
 
#include <minputcontext.h>
10
 
#include <mimserverconnection.h>
11
 
 
12
 
class InputMethodServerTestConnection: public MImServerConnection
13
 
{
14
 
    Q_OBJECT
15
 
 
16
 
public:
17
 
    struct RedirectedKeyParamsStruct {
18
 
        int keyType;
19
 
        int keyCode;
20
 
        QString text;
21
 
        void clear();
22
 
    };
23
 
 
24
 
    InputMethodServerTestConnection(QObject *parent = 0);
25
 
    virtual ~InputMethodServerTestConnection();
26
 
 
27
 
    // method calls are counted, this resets counters
28
 
    void resetCallCounts();
29
 
    void emitConnected();
30
 
 
31
 
    // returns counter for specific methods
32
 
    int showInputMethodCount();
33
 
    int hideInputMethodCount();
34
 
    int mouseClickedOnPreeditCount();
35
 
    int setPreeditCount();
36
 
    int resetCount();
37
 
 
38
 
    int activateContextCount();
39
 
    int keyEventCount();
40
 
    int orientationChangedCount();
41
 
 
42
 
    const QString &lastPreedit();
43
 
 
44
 
    int setCopyPasteStateCount();
45
 
    QList<bool> &setCopyPasteStateParams();
46
 
 
47
 
    int redirectKeyCount();
48
 
    RedirectedKeyParamsStruct &redirectKeyParams();
49
 
 
50
 
public Q_SLOTS:
51
 
    //! reimpl
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);
57
 
 
58
 
    virtual void activateContext();
59
 
 
60
 
    virtual void appOrientationChanged(int angle);
61
 
 
62
 
    virtual void setCopyPasteState(bool copyAvailable, bool pasteAvailable);
63
 
 
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,
68
 
                                 unsigned long time);
69
 
    //! reimpl end
70
 
 
71
 
private:
72
 
    int showInputMethodCallCount;
73
 
    int hideInputMethodCallCount;
74
 
    int mouseClickedOnPreeditCallCount;
75
 
    int setPreeditCallCount;
76
 
    int resetCallCount;
77
 
 
78
 
    int activateContextCallCount;
79
 
    int appOrientationChangedCount;
80
 
 
81
 
    int setCopyPasteStateCallCount;
82
 
    QList<bool> setCopyPasteStateCallParams;
83
 
    int redirectKeyCallCount;
84
 
    RedirectedKeyParamsStruct redirectKeyCallParams;
85
 
    QString lastPreeditString;
86
 
    int lastPreeditCursorPos;
87
 
};
88
 
 
89
 
 
90
 
class WidgetStub: public QWidget
91
 
{
92
 
    Q_OBJECT
93
 
 
94
 
public:
95
 
    WidgetStub(QObject *, bool enableVisualizationPriority = false);
96
 
    virtual ~WidgetStub();
97
 
 
98
 
    virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
99
 
    virtual void inputMethodEvent(QInputMethodEvent *event);
100
 
    virtual bool event(QEvent *event);
101
 
 
102
 
    void resetCounters();
103
 
    int inputMethodQueryCount();
104
 
    int inputMethodEventCount();
105
 
    int eventCount();
106
 
    QInputMethodEvent lastInputMethodEvent();
107
 
    QKeyEvent lastKeyEvent();
108
 
 
109
 
    void sendCopyAvailable(bool yes);
110
 
 
111
 
    QString selectedText;
112
 
 
113
 
Q_SIGNALS:
114
 
    void copyAvailable(bool);
115
 
 
116
 
private:
117
 
    mutable int m_inputMethodQueryCount;
118
 
    mutable int m_inputMethodEventCount;
119
 
    mutable QInputMethodEvent m_lastImEvent;
120
 
    int m_eventCount;
121
 
    QKeyEvent m_lastKeyEvent;
122
 
    bool visualizationPriority;
123
 
};
124
 
 
125
 
 
126
 
 
127
 
class Ut_MInputContext : public QObject
128
 
{
129
 
    Q_OBJECT
130
 
 
131
 
private Q_SLOTS:
132
 
    void initTestCase();
133
 
    void cleanupTestCase();
134
 
 
135
 
    void init();
136
 
    void cleanup();
137
 
 
138
 
    // input context interface
139
 
    void testAddCoverage();
140
 
    void testEvent();
141
 
    void testReset();
142
 
    void testMouseHandler();
143
 
    void testKeyEvent();
144
 
    //void testSetFocusWidget();
145
 
 
146
 
    // test outbound input method server communication
147
 
    void testInputMethodHidden();
148
 
    void testCommitString_data();
149
 
    void testCommitString();
150
 
    void testUpdatePreedit();
151
 
    void testAppOrientationChanged();
152
 
 
153
 
    // test inbound input method server communication
154
 
    void testImAreaChangePropagation();
155
 
    void testImInitiatedHideUnfocusesWidget();
156
 
    void testImCommitStringInjection();
157
 
    void testImSelectionInjection();
158
 
    void testImGetSelection();
159
 
 
160
 
    void testNonTextEntryWidget();
161
 
 
162
 
    // FIXME: do separate tests for qgraphics based widget stub?
163
 
    // FIXME: test non-input enabled widgets?
164
 
 
165
 
    //test copy/paste stuff
166
 
    void testCopyPasteState();
167
 
 
168
 
    void testSetRedirectKeys();
169
 
 
170
 
    void testInvalidScene();
171
 
 
172
 
    void testPropertyNameNormalization_data();
173
 
    void testPropertyNameNormalization();
174
 
 
175
 
private:
176
 
    void waitAndProcessEvents(int waitTime);
177
 
 
178
 
private:
179
 
    QPointer<MInputContext> m_subject;
180
 
    QSharedPointer<InputMethodServerTestConnection> m_connection;
181
 
};
182
 
 
183
 
 
184
 
 
185
 
#endif