diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2016-04-12 23:14:46 +0300 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-04-26 08:27:08 +0000 |
commit | 9cf3895f4dbb5d0678e2030316c1693581f754c9 (patch) | |
tree | 3e1bb611b721ea8e1aa45b0435db719f35263483 /tests | |
parent | 2e6f7f362e62c3285e7d395aca607502c8e8160e (diff) |
QQuickDragAttached: fix updating of "active" property
The d->active member variable should be changed regardless of the value
of Drag.dragType.
Task-number: QTBUG-52540
Change-Id: I7fa39ccf11b1200e9c2f6fe57cba58657b6cff74
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 46 |
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; |