testlib: Separate the gui- and widgets-specific api
Group the widgets-specific ("legacy") api under as few ifdefs as possible. (The diff can look confusing; rest assured that this change "only" moves entire functions around in the files.) Change-Id: I27bdec7d1c96d0b040dc22a8fed17e4e47766276 Reviewed-on: http://codereview.qt-project.org/5290 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Matthew Cattell <matthew.cattell@nokia.com>
This commit is contained in:
parent
294a3e7b47
commit
bc60b6787c
@ -68,6 +68,88 @@ namespace QTest
|
||||
{
|
||||
enum KeyAction { Press, Release, Click };
|
||||
|
||||
static void simulateEvent(QWindow *window, bool press, int code,
|
||||
Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
|
||||
{
|
||||
QEvent::Type type;
|
||||
type = press ? QEvent::KeyPress : QEvent::KeyRelease;
|
||||
QWindowSystemInterface::handleKeyEvent(window, type, code, modifier, text, repeat, delay);
|
||||
}
|
||||
|
||||
static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
|
||||
QString text, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
{
|
||||
QTEST_ASSERT(qApp);
|
||||
QTEST_ASSERT(window);
|
||||
|
||||
if (action == Click) {
|
||||
sendKeyEvent(Press, window, code, text, modifier, delay);
|
||||
sendKeyEvent(Release, window, code, text, modifier, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
bool repeat = false;
|
||||
|
||||
if (action == Press) {
|
||||
if (modifier & Qt::ShiftModifier)
|
||||
simulateEvent(window, true, Qt::Key_Shift, 0, QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ControlModifier)
|
||||
simulateEvent(window, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::AltModifier)
|
||||
simulateEvent(window, true, Qt::Key_Alt,
|
||||
modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
|
||||
if (modifier & Qt::MetaModifier)
|
||||
simulateEvent(window, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier
|
||||
| Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
|
||||
simulateEvent(window, true, code, modifier, text, repeat, delay);
|
||||
} else if (action == Release) {
|
||||
simulateEvent(window, false, code, modifier, text, repeat, delay);
|
||||
|
||||
if (modifier & Qt::MetaModifier)
|
||||
simulateEvent(window, false, Qt::Key_Meta, modifier, QString(), false, delay);
|
||||
if (modifier & Qt::AltModifier)
|
||||
simulateEvent(window, false, Qt::Key_Alt, modifier &
|
||||
(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ControlModifier)
|
||||
simulateEvent(window, false, Qt::Key_Control,
|
||||
modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ShiftModifier)
|
||||
simulateEvent(window, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
|
||||
}
|
||||
}
|
||||
|
||||
// Convenience function
|
||||
static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
|
||||
char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
{
|
||||
QString text;
|
||||
if (ascii)
|
||||
text = QString(QChar::fromLatin1(ascii));
|
||||
sendKeyEvent(action, window, code, text, modifier, delay);
|
||||
}
|
||||
|
||||
inline static void keyEvent(KeyAction action, QWindow *window, char ascii,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, window, asciiToKey(ascii), ascii, modifier, delay); }
|
||||
inline static void keyEvent(KeyAction action, QWindow *window, Qt::Key key,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, window, key, keyToAscii(key), modifier, delay); }
|
||||
|
||||
inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Click, window, key, modifier, delay); }
|
||||
inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Click, window, key, modifier, delay); }
|
||||
inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Release, window, key, modifier, delay); }
|
||||
inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Press, window, key, modifier, delay); }
|
||||
inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Press, window, key, modifier, delay); }
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
static void simulateEvent(QWidget *widget, bool press, int code,
|
||||
Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
|
||||
@ -85,17 +167,7 @@ namespace QTest
|
||||
if (!qApp->notify(widget, &a))
|
||||
QTest::qWarn("Keyboard event not accepted by receiving widget");
|
||||
}
|
||||
#endif
|
||||
//QWindow overload
|
||||
static void simulateEvent(QWindow *window, bool press, int code,
|
||||
Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
|
||||
{
|
||||
QEvent::Type type;
|
||||
type = press ? QEvent::KeyPress : QEvent::KeyRelease;
|
||||
QWindowSystemInterface::handleKeyEvent(window, type, code, modifier, text, repeat, delay);
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code,
|
||||
QString text, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
{
|
||||
@ -159,55 +231,7 @@ namespace QTest
|
||||
simulateEvent(widget, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//QWindow overload
|
||||
static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
|
||||
QString text, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
{
|
||||
QTEST_ASSERT(qApp);
|
||||
QTEST_ASSERT(window);
|
||||
|
||||
if (action == Click) {
|
||||
sendKeyEvent(Press, window, code, text, modifier, delay);
|
||||
sendKeyEvent(Release, window, code, text, modifier, delay);
|
||||
return;
|
||||
}
|
||||
|
||||
bool repeat = false;
|
||||
|
||||
if (action == Press) {
|
||||
if (modifier & Qt::ShiftModifier)
|
||||
simulateEvent(window, true, Qt::Key_Shift, 0, QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ControlModifier)
|
||||
simulateEvent(window, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::AltModifier)
|
||||
simulateEvent(window, true, Qt::Key_Alt,
|
||||
modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
|
||||
if (modifier & Qt::MetaModifier)
|
||||
simulateEvent(window, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier
|
||||
| Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
|
||||
simulateEvent(window, true, code, modifier, text, repeat, delay);
|
||||
} else if (action == Release) {
|
||||
simulateEvent(window, false, code, modifier, text, repeat, delay);
|
||||
|
||||
if (modifier & Qt::MetaModifier)
|
||||
simulateEvent(window, false, Qt::Key_Meta, modifier, QString(), false, delay);
|
||||
if (modifier & Qt::AltModifier)
|
||||
simulateEvent(window, false, Qt::Key_Alt, modifier &
|
||||
(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ControlModifier)
|
||||
simulateEvent(window, false, Qt::Key_Control,
|
||||
modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
|
||||
|
||||
if (modifier & Qt::ShiftModifier)
|
||||
simulateEvent(window, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
// Convenience function
|
||||
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code,
|
||||
char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
@ -217,35 +241,14 @@ namespace QTest
|
||||
text = QString(QChar::fromLatin1(ascii));
|
||||
sendKeyEvent(action, widget, code, text, modifier, delay);
|
||||
}
|
||||
#endif
|
||||
// QWindow convenience function
|
||||
static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
|
||||
char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
|
||||
{
|
||||
QString text;
|
||||
if (ascii)
|
||||
text = QString(QChar::fromLatin1(ascii));
|
||||
sendKeyEvent(action, window, code, text, modifier, delay);
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
inline static void keyEvent(KeyAction action, QWidget *widget, char ascii,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, widget, asciiToKey(ascii), ascii, modifier, delay); }
|
||||
inline static void keyEvent(KeyAction action, QWidget *widget, Qt::Key key,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, widget, key, keyToAscii(key), modifier, delay); }
|
||||
#endif
|
||||
|
||||
//Support QWindow
|
||||
inline static void keyEvent(KeyAction action, QWindow *window, char ascii,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, window, asciiToKey(ascii), ascii, modifier, delay); }
|
||||
inline static void keyEvent(KeyAction action, QWindow *window, Qt::Key key,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ sendKeyEvent(action, window, key, keyToAscii(key), modifier, delay); }
|
||||
///////////////
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
inline static void keyClicks(QWidget *widget, const QString &sequence,
|
||||
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{
|
||||
@ -265,18 +268,7 @@ namespace QTest
|
||||
{ keyEvent(Release, widget, key, modifier, delay); }
|
||||
inline static void keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Click, widget, key, modifier, delay); }
|
||||
#endif
|
||||
//Support QWindow
|
||||
inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Click, window, key, modifier, delay); }
|
||||
inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Click, window, key, modifier, delay); }
|
||||
inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Release, window, key, modifier, delay); }
|
||||
inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Press, window, key, modifier, delay); }
|
||||
inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
|
||||
{ keyEvent(Press, window, key, modifier, delay); }
|
||||
#endif // QT_WIDGETS_LIB
|
||||
|
||||
}
|
||||
|
||||
|
@ -68,66 +68,6 @@ namespace QTest
|
||||
{
|
||||
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove };
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
|
||||
{
|
||||
QTEST_ASSERT(widget);
|
||||
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
|
||||
|
||||
if (delay == -1 || delay < defaultMouseDelay())
|
||||
delay = defaultMouseDelay();
|
||||
if (delay > 0)
|
||||
QTest::qWait(delay);
|
||||
|
||||
if (pos.isNull())
|
||||
pos = widget->rect().center();
|
||||
|
||||
if (action == MouseClick) {
|
||||
mouseEvent(MousePress, widget, button, stateKey, pos);
|
||||
mouseEvent(MouseRelease, widget, button, stateKey, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
|
||||
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
|
||||
|
||||
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
|
||||
|
||||
QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
|
||||
switch (action)
|
||||
{
|
||||
case MousePress:
|
||||
me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
|
||||
break;
|
||||
case MouseRelease:
|
||||
me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
|
||||
break;
|
||||
case MouseDClick:
|
||||
me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
|
||||
break;
|
||||
case MouseMove:
|
||||
QCursor::setPos(widget->mapToGlobal(pos));
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QTest::qWait(20);
|
||||
#else
|
||||
qApp->processEvents();
|
||||
#endif
|
||||
return;
|
||||
default:
|
||||
QTEST_ASSERT(false);
|
||||
}
|
||||
QSpontaneKeyEvent::setSpontaneous(&me);
|
||||
if (!qApp->notify(widget, &me)) {
|
||||
static const char *mouseActionNames[] =
|
||||
{ "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
|
||||
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
|
||||
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
|
||||
{
|
||||
@ -188,24 +128,6 @@ namespace QTest
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
inline void mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MousePress, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseRelease(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseRelease, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseClick, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseDClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseDClick, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseMove, widget, Qt::NoButton, 0, pos, delay); }
|
||||
#endif
|
||||
|
||||
//Support QWindow
|
||||
inline void mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MousePress, window, button, stateKey, pos, delay); }
|
||||
@ -220,6 +142,81 @@ namespace QTest
|
||||
{ mouseEvent(MouseDClick, window, button, stateKey, pos, delay); }
|
||||
inline void mouseMove(QWindow *window, QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseMove, window, Qt::NoButton, 0, pos, delay); }
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
|
||||
{
|
||||
QTEST_ASSERT(widget);
|
||||
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
|
||||
|
||||
if (delay == -1 || delay < defaultMouseDelay())
|
||||
delay = defaultMouseDelay();
|
||||
if (delay > 0)
|
||||
QTest::qWait(delay);
|
||||
|
||||
if (pos.isNull())
|
||||
pos = widget->rect().center();
|
||||
|
||||
if (action == MouseClick) {
|
||||
mouseEvent(MousePress, widget, button, stateKey, pos);
|
||||
mouseEvent(MouseRelease, widget, button, stateKey, pos);
|
||||
return;
|
||||
}
|
||||
|
||||
QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
|
||||
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
|
||||
|
||||
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
|
||||
|
||||
QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
|
||||
switch (action)
|
||||
{
|
||||
case MousePress:
|
||||
me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
|
||||
break;
|
||||
case MouseRelease:
|
||||
me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
|
||||
break;
|
||||
case MouseDClick:
|
||||
me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
|
||||
break;
|
||||
case MouseMove:
|
||||
QCursor::setPos(widget->mapToGlobal(pos));
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
QTest::qWait(20);
|
||||
#else
|
||||
qApp->processEvents();
|
||||
#endif
|
||||
return;
|
||||
default:
|
||||
QTEST_ASSERT(false);
|
||||
}
|
||||
QSpontaneKeyEvent::setSpontaneous(&me);
|
||||
if (!qApp->notify(widget, &me)) {
|
||||
static const char *mouseActionNames[] =
|
||||
{ "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
|
||||
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
|
||||
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inline void mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MousePress, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseRelease(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseRelease, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseClick, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseDClick(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseDClick, widget, button, stateKey, pos, delay); }
|
||||
inline void mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1)
|
||||
{ mouseEvent(MouseMove, widget, Qt::NoButton, 0, pos, delay); }
|
||||
#endif // QT_WIDGETS_LIB
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -79,15 +79,6 @@ namespace QTest
|
||||
commit();
|
||||
points.clear();
|
||||
}
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointPressed);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
@ -95,16 +86,6 @@ namespace QTest
|
||||
p.setState(Qt::TouchPointPressed);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointMoved);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
@ -112,15 +93,6 @@ namespace QTest
|
||||
p.setState(Qt::TouchPointMoved);
|
||||
return *this;
|
||||
}
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointReleased);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
@ -135,6 +107,30 @@ namespace QTest
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointPressed);
|
||||
return *this;
|
||||
}
|
||||
QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointMoved);
|
||||
return *this;
|
||||
}
|
||||
QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
|
||||
{
|
||||
QTouchEvent::TouchPoint &p = point(touchId);
|
||||
p.setScreenPos(mapToScreen(widget, pt));
|
||||
p.setState(Qt::TouchPointReleased);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
QTouchEventSequence(QWidget *widget, QTouchEvent::DeviceType aDeviceType)
|
||||
|
Loading…
Reference in New Issue
Block a user