aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
index e232341a06..3615f56e5b 100644
--- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -144,6 +144,8 @@ private slots:
void cleanupTestCase();
void active();
+ void setActive_data();
+ void setActive();
void drop();
void move();
void parentChange();
@@ -379,6 +381,50 @@ void tst_QQuickDrag::active()
QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); QCOMPARE(dropTarget.moveEvents, 0);
}
+void tst_QQuickDrag::setActive_data()
+{
+ QTest::addColumn<QString>("dragType");
+
+ QTest::newRow("default") << "";
+ QTest::newRow("internal") << "Drag.dragType: Drag.Internal";
+ QTest::newRow("none") << "Drag.dragType: Drag.None";
+ /* We don't test Drag.Automatic, because that causes QDrag::exec() to be
+ * invoked, and on some platforms tha's implemented by running a main loop
+ * until the drag has finished -- and at that point, the Drag.active will
+ * be false again. */
+}
+
+// QTBUG-52540
+void tst_QQuickDrag::setActive()
+{
+ QFETCH(QString, dragType);
+
+ QQuickWindow window;
+ TestDropTarget dropTarget(window.contentItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n" +
+ dragType.toUtf8() + "\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+}
+
void tst_QQuickDrag::drop()
{
QQuickWindow window;