aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktestevent.cpp
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@theqtcompany.com>2015-02-27 12:11:58 +0100
committerCaroline Chao <caroline.chao@theqtcompany.com>2015-03-02 11:45:35 +0000
commit726eaaeeeede086ed341899b8ee0c1570e6bf6f5 (patch)
treeb3880ee109108fb11299a70ac701e6bf1915b3be /src/qmltest/quicktestevent.cpp
parent09e903e0743b3d3d58c31621b368ea317140b0f2 (diff)
testlib: Introduce MouseDoubleClickSequence() method
The existing method MouseDoubleClick() emulates the mouse double click event only. The added method MouseDoubleClickSequence() emulates the full sequence of mouse events a physical double-click would generate: Press-Release-Press-DoubleClick-Release Introducing a new method in order to provide convenience when a test requires to simulate a complete double-click action without changing the behavior of MouseDoubleClick() and risking to break existing tests. Add autotest. Task-number: QTBUG-42185 Change-Id: I1cdddd9e21d3b1d8a818f6d4e3717b06b7d70e08 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/qmltest/quicktestevent.cpp')
-rw-r--r--src/qmltest/quicktestevent.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index 2101d6e7aa..df8de14c14 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -111,7 +111,7 @@ namespace QTest {
namespace QtQuickTest
{
- enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove };
+ enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove, MouseDoubleClickSequence };
static void mouseEvent(MouseAction action, QWindow *window,
QObject *item, Qt::MouseButton button,
@@ -131,6 +131,15 @@ namespace QtQuickTest
return;
}
+ if (action == MouseDoubleClickSequence) {
+ mouseEvent(MousePress, window, item, button, stateKey, _pos);
+ mouseEvent(MouseRelease, window, item, button, stateKey, _pos);
+ mouseEvent(MousePress, window, item, button, stateKey, _pos);
+ mouseEvent(MouseDoubleClick, window, item, button, stateKey, _pos);
+ mouseEvent(MouseRelease, window, item, button, stateKey, _pos);
+ return;
+ }
+
QPoint pos;
QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
if (sgitem)
@@ -162,7 +171,7 @@ namespace QtQuickTest
QSpontaneKeyEvent::setSpontaneous(&me);
if (!qApp->notify(window, &me)) {
static const char *mouseActionNames[] =
- { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" };
+ { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove", "MouseDoubleClickSequence" };
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
}
@@ -269,6 +278,20 @@ bool QuickTestEvent::mouseDoubleClick
return true;
}
+bool QuickTestEvent::mouseDoubleClickSequence
+ (QObject *item, qreal x, qreal y, int button,
+ int modifiers, int delay)
+{
+ QWindow *view = eventWindow();
+ if (!view)
+ return false;
+ QtQuickTest::mouseEvent(QtQuickTest::MouseDoubleClickSequence, view, item,
+ Qt::MouseButton(button),
+ Qt::KeyboardModifiers(modifiers),
+ QPointF(x, y), delay);
+ return true;
+}
+
bool QuickTestEvent::mouseMove
(QObject *item, qreal x, qreal y, int delay, int buttons)
{