diff options
author | Charles Yin <charles.yin@nokia.com> | 2012-03-08 11:27:04 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-13 15:17:18 +0100 |
commit | ada9dd41c83aad3890b8f01a98fdbeae04528eba (patch) | |
tree | f976a4849bccfbb2bccef23f6ec0797a95a29e57 /src | |
parent | b262e81d52e8c269063e1de829aea311dff7c632 (diff) |
Implement mouseDrag
Simulates the drag behavior by press-move-move-release mouse events,
we need 2 move events here to trigger the drag threshold.
Task-number: QTBUG-22753
Change-Id: Ic3470c061834b7410c524029d82375cba62afa36
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/testlib/TestCase.qml | 16 | ||||
-rw-r--r-- | src/imports/testlib/main.cpp | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 0433483cfd..1f9de5e998 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -407,6 +407,22 @@ Item { qtest_fail("window not shown", 2) } + function mouseDrag(item, x, y, dx, dy, button, modifiers, delay) { + if (item.x === undefined || item.y === undefined) + return + if (button === undefined) + button = Qt.LeftButton + if (modifiers === undefined) + modifiers = Qt.NoModifier + if (delay == undefined) + delay = -1 + + mousePress(item, x, y, button, modifiers, delay) + //trigger draging + mouseMove(item, x + util.dragThreshold + 1, y + util.dragThreshold + 1, delay, button) + mouseMove(item, x + dx, y + dy, delay, button) + } + function mouseClick(item, x, y, button, modifiers, delay) { if (button === undefined) button = Qt.LeftButton diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 6473d216c7..18039e7a3f 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -48,6 +48,8 @@ #include "private/qtestoptions_p.h" #include "QtQuick/qquickitem.h" #include <QtQml/private/qqmlengine_p.h> +#include <QtGui/QGuiApplication> +#include <QtGui/qstylehints.h> QML_DECLARE_TYPE(QuickTestResult) QML_DECLARE_TYPE(QuickTestEvent) @@ -61,6 +63,7 @@ class QuickTestUtil : public QObject Q_OBJECT Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged) Q_PROPERTY(bool wrapper READ wrapper NOTIFY wrapperChanged) + Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged) public: QuickTestUtil(QObject *parent = 0) :QObject(parent) @@ -76,9 +79,13 @@ public: { return true; } + int dragThreshold() const { return qApp->styleHints()->startDragDistance(); } + Q_SIGNALS: void printAvailableFunctionsChanged(); void wrapperChanged(); + void dragThresholdChanged(); + public Q_SLOTS: QQmlV8Handle typeName(const QVariant& v) const |