47 #pragma qt_no_master_include 50 #include <QtTest/qtest_global.h> 52 #include <QtTest/qtestkeyboard.h> 53 #include <QtTest/qtestmouse.h> 55 #include <QtTest/qtestsystem.h> 57 #include <QtCore/qlist.h> 70 virtual void simulate(
QWidget *w) = 0;
71 virtual QTestEvent *
clone()
const = 0;
81 : _action(action), _delay(delay), _modifiers(modifiers), _ascii(0), _key(key) {}
82 inline QTestKeyEvent(
QTest::KeyAction action,
char ascii, Qt::KeyboardModifiers modifiers,
int delay)
83 : _action(action), _delay(delay), _modifiers(modifiers),
98 Qt::KeyboardModifiers _modifiers;
106 inline QTestKeyClicksEvent(
const QString &
keys, Qt::KeyboardModifiers modifiers,
int delay)
107 : _keys(keys), _modifiers(modifiers), _delay(delay) {}
108 inline QTestEvent *
clone()
const {
return new QTestKeyClicksEvent(*
this); }
110 inline void simulate(
QWidget *w)
117 Qt::KeyboardModifiers _modifiers;
126 : _action(action), _button(button), _modifiers(modifiers), _pos(position), _delay(delay) {}
127 inline QTestEvent *
clone()
const {
return new QTestMouseEvent(*
this); }
129 inline void simulate(
QWidget *w)
137 Qt::KeyboardModifiers _modifiers;
161 {
for (
int i = 0; i < other.
count(); ++i) append(other.
at(i)->
clone()); }
170 inline void addKeyPress(
Qt::Key qtKey, Qt::KeyboardModifiers modifiers =
Qt::NoModifier,
int msecs = -1)
172 inline void addKeyRelease(
Qt::Key qtKey, Qt::KeyboardModifiers modifiers =
Qt::NoModifier,
int msecs = -1)
176 { append(
new QTestKeyEvent(action, qtKey, modifiers, msecs)); }
178 inline void addKeyClick(
char ascii, Qt::KeyboardModifiers modifiers =
Qt::NoModifier,
int msecs = -1)
180 inline void addKeyPress(
char ascii, Qt::KeyboardModifiers modifiers =
Qt::NoModifier,
int msecs = -1)
182 inline void addKeyRelease(
char ascii, Qt::KeyboardModifiers modifiers =
Qt::NoModifier,
int msecs = -1)
185 { append(
new QTestKeyClicksEvent(keys, modifiers, msecs)); }
187 { append(
new QTestKeyEvent(action, ascii, modifiers, msecs)); }
189 inline void addMousePress(
Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
191 { append(
new QTestMouseEvent(
QTest::MousePress, button, stateKey, pos, delay)); }
192 inline void addMouseRelease(
Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
195 inline void addMouseClick(
Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
197 { append(
new QTestMouseEvent(
QTest::MouseClick, button, stateKey, pos, delay)); }
198 inline void addMouseDClick(
Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
201 inline void addMouseMove(
QPoint pos =
QPoint(),
int delay=-1)
210 for (
int i = 0; i < count(); ++i)
void simulate(QWidget *w)
MouseAction
This enum describes possible actions for mouse handling.
#define QT_END_NAMESPACE
This macro expands to.
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyClicks(QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
Simulates clicking a sequence of keys on a widget.
#define at(className, varName)
QTestEvent * clone() const
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static void clear(QVariant::Private *d)
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QString class provides a Unicode character string.
QTestDelayEvent(int msecs)
virtual void simulate(QWidget *w)=0
#define QT_BEGIN_NAMESPACE
This macro expands to.
const T & at(int i) const
Returns the item at index position i in the list.
QTestEventList(const QTestEventList &other)
void clear()
Removes all items from the list.
static void qWait(int ms)
Waits for ms milliseconds.
The QPoint class defines a point in the plane using integer precision.
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
KeyAction
This enum describes possible actions for key handling.
static QString qtKey(CFStringRef cfkey)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
The QList class is a template class that provides lists.
virtual QTestEvent * clone() const =0