summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordac <qt-info@nokia.com>2010-08-23 13:32:13 +1000
committerdac <qt-info@nokia.com>2010-08-23 13:32:13 +1000
commit2e2540b47eba282a2b79ee24793419c393192099 (patch)
treef597a9f74d79727f17c3cbf5986b41102664f8bc
parent1c3f563c54f4806342af8a6d89bff2432a0d541d (diff)
Add support for mouseMove events.
-rw-r--r--libqsystemtest/qsystemtest.cpp51
-rw-r--r--libqsystemtest/qsystemtest.h3
-rw-r--r--libqtslave/qtestslave.cpp12
-rw-r--r--libqtuitest/qinputgenerator_mac.cpp5
-rw-r--r--libqtuitest/qinputgenerator_p.h1
-rw-r--r--libqtuitest/qinputgenerator_qws.cpp3
-rw-r--r--libqtuitest/qinputgenerator_symbian.cpp6
-rw-r--r--libqtuitest/qinputgenerator_win.cpp5
-rw-r--r--libqtuitest/qinputgenerator_x11.cpp5
-rw-r--r--libqtuitest/qtuitestnamespace.cpp7
-rw-r--r--libqtuitest/qtuitestnamespace.h1
-rw-r--r--libqtuitest/qtuitestwidgets.cpp24
-rw-r--r--libqtuitest/qtuitestwidgets_p.h1
13 files changed, 123 insertions, 1 deletions
diff --git a/libqsystemtest/qsystemtest.cpp b/libqsystemtest/qsystemtest.cpp
index 7f5c70e..1ed26b9 100644
--- a/libqsystemtest/qsystemtest.cpp
+++ b/libqsystemtest/qsystemtest.cpp
@@ -1707,6 +1707,17 @@ void QSystemTest::mouseClick( int x, int y, QFlags<Qt::MouseButton> buttons )
}
/*!
+ Simulates moving mouse pointer to co-ordinates ( \a x, \a y ). The mouse
+ button state is not changed.
+
+ \sa {Query Paths}, {Mouse / Touchscreen Simulation}
+*/
+void QSystemTest::mouseMove( int x, int y )
+{
+ mouseMove(QPoint(x, y));
+}
+
+/*!
Simulates a mouse click / touchscreen tap at \a point.
Example:
@@ -1733,6 +1744,26 @@ void QSystemTest::mouseClick( const QPoint &point, QFlags<Qt::MouseButton> butto
}
/*!
+ Simulates moving the mouse pointer to \a point. The mouse button
+ state is unchanged.
+
+ \sa {Query Paths}, {Mouse / Touchscreen Simulation}
+*/
+void QSystemTest::mouseMove( const QPoint &point )
+{
+ if (QSystemTest::runAsManualTest()) {
+ manualTestData( QString("position (x,y) %1,%2").arg(point.x()).arg(point.y()), true);
+ manualTest( QString("Move the mouse to MAGIC_DATA") );
+ return;
+ }
+
+ if (m_strict_mode) QFAIL( "ERROR: mouseMove is not allowed in strict mode" );
+ QTestMessage message("mouseMove");
+ message["pos"] = point;
+ queryPassed( "OK", "", BT(message) );
+}
+
+/*!
Simulates a mouse click / touchscreen tap at the center of the widget
specified by \a queryPath.
@@ -1760,6 +1791,26 @@ void QSystemTest::mouseClick( const QString &queryPath, QFlags<Qt::MouseButton>
}
/*!
+ Simulates moving the mouse pointer to the center of the widget
+ specified by \a queryPath. The mouse button state is unchanged.
+
+ \sa {Query Paths}, {Mouse / Touchscreen Simulation}
+*/
+void QSystemTest::mouseMove( const QString &queryPath )
+{
+ if (QSystemTest::runAsManualTest()) {
+ manualTest( QString("Move the mouse to %2")
+ .arg(quote(queryPath)));
+ return;
+ }
+
+ if (m_strict_mode) QFAIL( "ERROR: mouseMove is not allowed in strict mode" );
+ QTestMessage message("mouseMove");
+ queryPassed( "OK", "", BT(message), queryPath );
+ wait(200);
+}
+
+/*!
Simulates a mouse click / touchscreen tap at co-ordinates ( \a x, \a y ),
with a custom \a duration in milliseconds between press and release.
diff --git a/libqsystemtest/qsystemtest.h b/libqsystemtest/qsystemtest.h
index b33156f..fd23430 100644
--- a/libqsystemtest/qsystemtest.h
+++ b/libqsystemtest/qsystemtest.h
@@ -296,6 +296,9 @@ public slots:
void mouseRelease(int,int,QFlags<Qt::MouseButton> = Qt::LeftButton);
void mouseRelease(const QPoint&,QFlags<Qt::MouseButton> = Qt::LeftButton);
void mouseRelease(const QString&,QFlags<Qt::MouseButton> = Qt::LeftButton);
+ void mouseMove(int,int);
+ void mouseMove(const QPoint&);
+ void mouseMove(const QString&);
bool mousePreferred();
void setMousePreferred(bool);
diff --git a/libqtslave/qtestslave.cpp b/libqtslave/qtestslave.cpp
index 9a4a666..b2b7b35 100644
--- a/libqtslave/qtestslave.cpp
+++ b/libqtslave/qtestslave.cpp
@@ -209,6 +209,7 @@ public slots:
QTestMessage mousePress (QTestMessage const&);
QTestMessage mouseRelease (QTestMessage const&);
QTestMessage mouseClick (QTestMessage const&);
+ QTestMessage mouseMove (QTestMessage const&);
QTestMessage translate (QTestMessage const&);
QTestMessage getLocale (QTestMessage const&);
@@ -1638,6 +1639,17 @@ QTestMessage QTestSlavePrivate::mouseClick(QTestMessage const &message)
return RET(reply, "OK");
}
+QTestMessage QTestSlavePrivate::mouseMove(QTestMessage const &message)
+{
+ QTestMessage reply;
+ bool ok;
+
+ QPoint pos(mousePointForMessage(message, reply, ok));
+ if (ok) QtUiTest::mouseMove(pos);
+ else return reply;
+ return RET(reply, "OK" );
+}
+
QPoint QTestSlavePrivate::mousePointForMessage(QTestMessage const &message, QTestMessage &reply, bool &ok)
{
ok = true;
diff --git a/libqtuitest/qinputgenerator_mac.cpp b/libqtuitest/qinputgenerator_mac.cpp
index a4adaab..b22f95a 100644
--- a/libqtuitest/qinputgenerator_mac.cpp
+++ b/libqtuitest/qinputgenerator_mac.cpp
@@ -478,3 +478,8 @@ void QInputGenerator::mouseClick(QPoint const& pos, Qt::MouseButtons state)
QtUiTest::wait(1);
}
+void QInputGenerator::mouseMove(QPoint const& pos)
+{
+ QINPUTGENERATOR_DEBUG() << "Mouse move" << pos;
+ d->mouseEvent(pos, d->currentButtons);
+}
diff --git a/libqtuitest/qinputgenerator_p.h b/libqtuitest/qinputgenerator_p.h
index c18bde6..c390f70 100644
--- a/libqtuitest/qinputgenerator_p.h
+++ b/libqtuitest/qinputgenerator_p.h
@@ -74,6 +74,7 @@ public:
void mousePress (QPoint const&, Qt::MouseButtons);
void mouseRelease(QPoint const&, Qt::MouseButtons);
void mouseClick (QPoint const&, Qt::MouseButtons);
+ void mouseMove (QPoint const&);
QPoint mapFromActiveWindow(QPoint const&) const;
diff --git a/libqtuitest/qinputgenerator_qws.cpp b/libqtuitest/qinputgenerator_qws.cpp
index 657f34e..134564f 100644
--- a/libqtuitest/qinputgenerator_qws.cpp
+++ b/libqtuitest/qinputgenerator_qws.cpp
@@ -296,6 +296,9 @@ void QInputGenerator::mouseRelease(QPoint const& pos, Qt::MouseButtons state)
void QInputGenerator::mouseClick(QPoint const& pos, Qt::MouseButtons state)
{ d->mouseEvent(pos, state, d->MouseClick); }
+void QInputGenerator::mouseMove(QPoint const& pos)
+{ d->mouseEvent(pos, 0, d->MouseRelease); }
+
void QInputGeneratorPrivate::ensureModifiers(Qt::KeyboardModifiers desiredMod)
{
if (currentModifiers == desiredMod) return;
diff --git a/libqtuitest/qinputgenerator_symbian.cpp b/libqtuitest/qinputgenerator_symbian.cpp
index 2adce33..92fc095 100644
--- a/libqtuitest/qinputgenerator_symbian.cpp
+++ b/libqtuitest/qinputgenerator_symbian.cpp
@@ -423,3 +423,9 @@ void QInputGenerator::mouseClick(QPoint const& pos, Qt::MouseButtons state)
QtUiTest::wait(20);
mouseRelease(pos,state);
}
+
+void QInputGenerator::mouseMove(QPoint const& pos)
+{
+ QINPUTGENERATOR_DEBUG() << "Mouse move" << pos;
+ d->mouseEvent(pos, d->currentButtons);
+}
diff --git a/libqtuitest/qinputgenerator_win.cpp b/libqtuitest/qinputgenerator_win.cpp
index 991755b..eab05f0 100644
--- a/libqtuitest/qinputgenerator_win.cpp
+++ b/libqtuitest/qinputgenerator_win.cpp
@@ -494,3 +494,8 @@ void QInputGenerator::mouseClick(QPoint const& pos, Qt::MouseButtons state)
mouseRelease(pos,state);
}
+void QInputGenerator::mouseMove(QPoint const& pos)
+{
+ QINPUTGENERATOR_DEBUG() << "Mouse move" << pos;
+ d->mouseEvent(pos, d->currentButtons);
+}
diff --git a/libqtuitest/qinputgenerator_x11.cpp b/libqtuitest/qinputgenerator_x11.cpp
index 11bb7e1..f4369b2 100644
--- a/libqtuitest/qinputgenerator_x11.cpp
+++ b/libqtuitest/qinputgenerator_x11.cpp
@@ -512,3 +512,8 @@ void QInputGenerator::mouseClick(QPoint const& pos, Qt::MouseButtons state)
mouseRelease(pos,state);
}
+void QInputGenerator::mouseMove(QPoint const& pos)
+{
+ QINPUTGENERATOR_DEBUG() << "Mouse move" << pos;
+ d->mouseEvent(pos, d->currentButtons);
+}
diff --git a/libqtuitest/qtuitestnamespace.cpp b/libqtuitest/qtuitestnamespace.cpp
index 09d838f..f824422 100644
--- a/libqtuitest/qtuitestnamespace.cpp
+++ b/libqtuitest/qtuitestnamespace.cpp
@@ -455,6 +455,13 @@ bool QtUiTest::mouseClick(QObject* object, QPoint const& pos, Qt::MouseButtons b
}
/*!
+ Simulate moving the mouse pointer to the global co-ordinates given by \a pos.
+ \a options are applied to the simulated event.
+*/
+void QtUiTest::mouseMove(QPoint const& pos, QtUiTest::InputOption options)
+{ QtUiTestWidgets::instance()->mouseMove(pos, options); }
+
+/*!
\internal
*/
bool QtUiTest::mouseClick(QObject* object, QList<QEvent::Type> const& types, QPoint const& pos,
diff --git a/libqtuitest/qtuitestnamespace.h b/libqtuitest/qtuitestnamespace.h
index 41d88c6..6582795 100644
--- a/libqtuitest/qtuitestnamespace.h
+++ b/libqtuitest/qtuitestnamespace.h
@@ -106,6 +106,7 @@ namespace QtUiTest
InputOption = NoOptions);
QTUITEST_EXPORT bool mouseClick (QObject*,QByteArray const&,QPoint const&,
Qt::MouseButtons = Qt::LeftButton, InputOption = NoOptions);
+ QTUITEST_EXPORT void mouseMove (QPoint const&, InputOption = NoOptions);
QTUITEST_EXPORT void keyPress (int,Qt::KeyboardModifiers = 0,
InputOption = NoOptions);
diff --git a/libqtuitest/qtuitestwidgets.cpp b/libqtuitest/qtuitestwidgets.cpp
index 9d163ef..156b6d6 100644
--- a/libqtuitest/qtuitestwidgets.cpp
+++ b/libqtuitest/qtuitestwidgets.cpp
@@ -76,7 +76,7 @@
*/
#ifdef QTUITEST_RACE_TEST
-enum QtUiTestInputType { QtUiTestPress, QtUiTestRelease, QtUiTestClick };
+enum QtUiTestInputType { QtUiTestPress, QtUiTestRelease, QtUiTestClick, QtUiTestMove };
struct QtUiTestKeyEvent
{
QtUiTestInputType type;
@@ -517,6 +517,26 @@ void QtUiTestWidgets::mouseClick(QPoint const &pos, Qt::MouseButtons state,
d->input.mouseClick(pos, state);
}
+
+/*!
+ Simulate moving the mouse pointer to global co-ordinates given by \a pos,
+ \a opt is applied to the simulated event.
+*/
+void QtUiTestWidgets::mouseMove(QPoint const &pos, QtUiTest::InputOption opt)
+{
+#ifdef QTUITEST_RACE_TEST
+ int delay;
+ if ((delay = qtUiTestInputDelay()) != -1) {
+ QtUiTestMouseEvent event = {QtUiTestMove, pos, 0, opt};
+ d->pendingMouseEvents << event;
+ QTimer::singleShot(delay, this, SLOT(_q_postNextMouseEvent()));
+ return;
+ }
+#endif
+ QTWOptStack st(d, opt);
+ d->input.mouseMove(pos);
+}
+
/*!
Simulate a key press event, using the given \a key and \a mod.
\a opt is applied to the simulated event.
@@ -588,6 +608,8 @@ void QtUiTestWidgetsPrivate::_q_postNextMouseEvent()
input.mouseRelease(event.pos, event.state);
else if (event.type == QtUiTestClick)
input.mouseClick(event.pos, event.state);
+ else if (event.type == QtUiTestMove)
+ input.mouseMove(event.pos);
}
void QtUiTestWidgetsPrivate::_q_postNextKeyEvent()
diff --git a/libqtuitest/qtuitestwidgets_p.h b/libqtuitest/qtuitestwidgets_p.h
index 784b760..2d5bb7b 100644
--- a/libqtuitest/qtuitestwidgets_p.h
+++ b/libqtuitest/qtuitestwidgets_p.h
@@ -91,6 +91,7 @@ public:
QtUiTest::InputOption = QtUiTest::NoOptions);
void mouseClick (QPoint const&,Qt::MouseButtons = Qt::LeftButton,
QtUiTest::InputOption = QtUiTest::NoOptions);
+ void mouseMove (QPoint const&, QtUiTest::InputOption = QtUiTest::NoOptions);
void keyPress (Qt::Key,Qt::KeyboardModifiers = 0,QtUiTest::InputOption = QtUiTest::NoOptions);
void keyRelease(Qt::Key,Qt::KeyboardModifiers = 0,QtUiTest::InputOption = QtUiTest::NoOptions);