From 85d39c72c6427ff9fd11be25c42a5c7abc277b8b Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Fri, 26 Jul 2013 17:58:00 -0300 Subject: Fix tst_QQuickDrag::recursion() Process events and handle number of move events correctly. Change-Id: I555582ad4e10d5c76bbdc8ce9203b8f5897d0f56 Reviewed-by: Frederik Gladhorn --- tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 46 ++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index dbb4736c05..15282d4b02 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -1070,106 +1070,131 @@ void tst_QQuickDrag::recursion_data() { QTest::addColumn("script"); QTest::addColumn("type"); + QTest::addColumn("moveEvents"); QTest::addColumn("warning"); QTest::newRow("Drag.start() in Enter") << QString("Drag.start()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Enter") << QString("Drag.cancel()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Enter") << QString("Drag.drop()") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Enter") << QString("Drag.active = true") << int(QEvent::DragEnter) + << 1 << QByteArray(); QTest::newRow("Drag.active = false in Enter") << QString("Drag.active = false") << int(QEvent::DragEnter) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("move in Enter") << QString("x = 23") << int(QEvent::DragEnter) + << 1 << QByteArray(); QTest::newRow("Drag.start() in Move") << QString("Drag.start()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Move") << QString("Drag.cancel()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Move") << QString("Drag.drop()") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Move") << QString("Drag.active = true") << int(QEvent::DragMove) + << 1 << QByteArray(); QTest::newRow("Drag.active = false in Move") << QString("Drag.active = false") << int(QEvent::DragMove) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("move in Move") << QString("x = 23") << int(QEvent::DragMove) + << 2 << QByteArray(); QTest::newRow("Drag.start() in Leave") << QString("Drag.start()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Leave") << QString("Drag.cancel()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Leave") << QString("Drag.drop()") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Leave") << QString("Drag.active = true") << int(QEvent::DragLeave) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Leave") << QString("Drag.active = false") << int(QEvent::DragLeave) + << 1 << QByteArray(); QTest::newRow("move in Leave") << QString("x = 23") << int(QEvent::DragLeave) + << 1 << QByteArray(); QTest::newRow("Drag.start() in Drop") << QString("Drag.start()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Drop") << QString("Drag.cancel()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Drop") << QString("Drag.drop()") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Drop") << QString("Drag.active = true") << int(QEvent::Drop) + << 1 << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Drop") << QString("Drag.active = false") << int(QEvent::Drop) + << 1 << QByteArray(); QTest::newRow("move in Drop") << QString("x = 23") << int(QEvent::Drop) + << 1 << QByteArray(); } @@ -1177,6 +1202,7 @@ void tst_QQuickDrag::recursion() { QFETCH(QString, script); QFETCH(int, type); + QFETCH(int, moveEvents); QFETCH(QByteArray, warning); if (!warning.isEmpty()) @@ -1206,22 +1232,36 @@ void tst_QQuickDrag::recursion() QCOMPARE(dropTarget.leaveEvents, 0); evaluate(item, "y = 15"); + + // the evaluate statement above, y = 15, will cause + // QQuickItem::setY(15) to be called, leading to an + // event being posted that will be delivered + // to RecursingDropTarget::dragMoveEvent(), hence + // the following call to QCoreApplication::processEvents() QCoreApplication::processEvents(); + + + // Regarding 'move in Move' when + // RecursingDropTarget::dragMoveEvent() runs, + // its call 'evaluate' triggers a second + // move event (x = 23) that needs to be delivered. + QCoreApplication::processEvents(); + QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); if (type == QEvent::Drop) { QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); } else { evaluate(item, "Drag.cancel()"); QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.moveEvents, moveEvents); QCOMPARE(dropTarget.dropEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); } -- cgit v1.2.3