aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickdrag
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-06 09:17:24 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-06 09:17:24 +0200
commit9b6d55ddf361f14c05c2965b29184a95e3c6a989 (patch)
treea1b4327662b257f4d18541ed136062d3bc38b229 /tests/auto/quick/qquickdrag
parent9a7cf067a178c7a08a7ed9f2c6253e1feade5569 (diff)
parent9530a6a8744e9eb2b4ed947b528ab7c51d8c360f (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'tests/auto/quick/qquickdrag')
-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 a7b5f4943e..6a919d048e 100644
--- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -139,6 +139,8 @@ private slots:
void cleanupTestCase();
void active();
+ void setActive_data();
+ void setActive();
void drop();
void move();
void parentChange();
@@ -374,6 +376,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;