diff options
Diffstat (limited to 'tests/auto/controls/data/tst_swipedelegate.qml')
-rw-r--r-- | tests/auto/controls/data/tst_swipedelegate.qml | 299 |
1 files changed, 221 insertions, 78 deletions
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 98c99438..a36a2770 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -40,7 +40,7 @@ import QtQuick 2.6 import QtTest 1.0 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 TestCase { @@ -128,10 +128,8 @@ TestCase { ignoreWarning(warningMessage); - var control = data.component.createObject(testCase); + var control = createTemporaryObject(data.component, testCase); verify(control.contentItem); - - control.destroy(); } Component { @@ -204,11 +202,11 @@ TestCase { } function test_settingDelegates() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":158:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; // Shouldn't be any warnings when unsetting delegates. @@ -217,7 +215,7 @@ TestCase { // right is still set. ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":158:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.behind = itemComponent; control.swipe.right = null; @@ -226,11 +224,11 @@ TestCase { control.swipe.behind = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":158:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.left = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: cannot set both behind and left/right properties") + ":158:9: QML SwipeDelegate: cannot set both behind and left/right properties") control.swipe.right = itemComponent; control.swipe.behind = null; @@ -245,7 +243,7 @@ TestCase { var oldLeft = control.swipe.left; var oldLeftItem = control.swipe.leftItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":158:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.left = null; compare(control.swipe.left, oldLeft); compare(control.swipe.leftItem, oldLeftItem); @@ -256,7 +254,7 @@ TestCase { var oldRight = control.swipe.right; var oldRightItem = control.swipe.rightItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":158:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.right = null; compare(control.swipe.right, oldRight); compare(control.swipe.rightItem, oldRightItem); @@ -282,24 +280,20 @@ TestCase { var oldBehind = control.swipe.behind; var oldBehindItem = control.swipe.behindItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":160:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + ":158:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") control.swipe.behind = null; compare(control.swipe.behind, oldBehind); compare(control.swipe.behindItem, oldBehindItem); - - control.destroy(); } function test_defaults() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset); compare(control.swipe.position, 0); verify(!control.pressed); verify(!control.swipe.complete); - - control.destroy(); } SignalSequenceSpy { @@ -308,7 +302,7 @@ TestCase { } function test_swipe() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); var overDragDistance = Math.round(dragDistance * 1.1); @@ -317,6 +311,14 @@ TestCase { verify(completedSpy); verify(completedSpy.valid); + var openedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "opened" }); + verify(openedSpy); + verify(openedSpy.valid); + + var closedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "closed" }); + verify(closedSpy); + verify(closedSpy.valid); + mouseSignalSequenceSpy.target = control; mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); @@ -324,6 +326,8 @@ TestCase { compare(control.swipe.position, 0.0); verify(!control.swipe.complete); compare(completedSpy.count, 0); + compare(openedSpy.count, 0); + compare(closedSpy.count, 0); verify(mouseSignalSequenceSpy.success); verify(!control.swipe.leftItem); verify(!control.swipe.rightItem); @@ -334,6 +338,8 @@ TestCase { compare(control.swipe.position, overDragDistance / control.width); verify(!control.swipe.complete); compare(completedSpy.count, 0); + compare(openedSpy.count, 0); + compare(closedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); compare(control.swipe.leftItem.parent, control); @@ -346,6 +352,8 @@ TestCase { compare(control.swipe.position, 0.0); verify(!control.swipe.complete); compare(completedSpy.count, 0); + compare(openedSpy.count, 0); + compare(closedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); compare(control.swipe.leftItem.parent, control); @@ -359,6 +367,8 @@ TestCase { compare(control.swipe.position, -overDragDistance / control.width); verify(!control.swipe.complete); compare(completedSpy.count, 0); + compare(openedSpy.count, 0); + compare(closedSpy.count, 0); verify(control.swipe.leftItem); verify(!control.swipe.leftItem.visible); verify(control.swipe.rightItem); @@ -372,6 +382,8 @@ TestCase { compare(control.swipe.position, 0.6); verify(!control.swipe.complete); compare(completedSpy.count, 0); + compare(openedSpy.count, 0); + compare(closedSpy.count, 0); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); verify(control.swipe.rightItem); @@ -380,9 +392,11 @@ TestCase { mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width / 2, control.height / 2); verify(!control.pressed); - compare(control.swipe.position, 1.0); - verify(control.swipe.complete); + tryCompare(control.swipe, "position", 1.0); + tryCompare(control.swipe, "complete", true); compare(completedSpy.count, 1); + compare(openedSpy.count, 1); + compare(closedSpy.count, 0); verify(mouseSignalSequenceSpy.success); verify(control.swipe.leftItem); verify(control.swipe.leftItem.visible); @@ -399,21 +413,27 @@ TestCase { // haven't started grabbing behind's mouse events. verify(control.swipe.complete); compare(completedSpy.count, 1); + compare(openedSpy.count, 1); + compare(closedSpy.count, 0); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); verify(control.pressed); verify(!control.swipe.complete); compare(completedSpy.count, 1); + compare(openedSpy.count, 1); + compare(closedSpy.count, 0); compare(control.swipe.position, 1.0 - overDragDistance / control.width); // Since we went over the drag distance, we should expect canceled() to be emitted. mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width * 0.4, control.height / 2); verify(!control.pressed); - compare(control.swipe.position, 1.0); - verify(control.swipe.complete); + tryCompare(control.swipe, "position", 1.0); + tryCompare(control.swipe, "complete", true); compare(completedSpy.count, 2); + compare(openedSpy.count, 2); + compare(closedSpy.count, 0); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.width + control.leftPadding); @@ -424,24 +444,28 @@ TestCase { compare(control.swipe.position, 1.0); verify(control.swipe.complete); compare(completedSpy.count, 2); + compare(openedSpy.count, 2); + compare(closedSpy.count, 0); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width * -0.1, control.height / 2); verify(control.pressed); verify(!control.swipe.complete); compare(completedSpy.count, 2); + compare(openedSpy.count, 2); + compare(closedSpy.count, 0); compare(control.swipe.position, 0.4); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width * -0.1, control.height / 2); verify(!control.pressed); - compare(control.swipe.position, 0.0); + tryCompare(control.swipe, "position", 0.0); verify(!control.swipe.complete); compare(completedSpy.count, 2); + compare(openedSpy.count, 2); + tryCompare(closedSpy, "count", 1); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.leftPadding); - - control.destroy(); } function test_swipeVelocity_data() { @@ -454,7 +478,7 @@ TestCase { function test_swipeVelocity(data) { skip("QTBUG-52003"); - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); var distance = Math.round(dragDistance * 1.1); @@ -514,8 +538,6 @@ TestCase { verify(expectedVisibleItem.visible); verify(!expectedHiddenItem); tryCompare(control.contentItem, "x", expectedContentItemX); - - control.destroy(); } Component { @@ -532,9 +554,13 @@ TestCase { } function test_eventsToLeftAndRight() { - var control = swipeDelegateWithButtonComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateWithButtonComponent, testCase); verify(control); + var closedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "closed" }); + verify(closedSpy); + verify(closedSpy.valid); + // The button should be pressed instead of the SwipeDelegate. mouseDrag(control, control.width / 2, control.height / 2, -control.width, 0); // Mouse has been released by this stage. @@ -572,18 +598,17 @@ TestCase { // Returning back to a position of 0 and pressing on the control should // result in the control being pressed. mouseDrag(control, control.width / 2, control.height / 2, control.width * 0.6, 0); + tryCompare(closedSpy, "count", 1); compare(control.swipe.position, 0); mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); verify(!button.pressed); mouseRelease(control, control.width / 2, control.height / 2); verify(!control.pressed); - - control.destroy(); } function test_mouseButtons() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); // click @@ -644,8 +669,6 @@ TestCase { mouseRelease(control); compare(control.pressed, false); verify(mouseSignalSequenceSpy.success); - - control.destroy(); } Component { @@ -709,7 +732,7 @@ TestCase { } function test_removableDelegates() { - var listView = removableDelegatesComponent.createObject(testCase); + var listView = createTemporaryObject(removableDelegatesComponent, testCase); verify(listView); compare(listView.count, 3); @@ -730,8 +753,8 @@ TestCase { mouseRelease(listView, firstItem.width / 2, firstItem.height / 2); verify(!firstItem.pressed); - compare(firstItem.swipe.position, 1.0); - verify(firstItem.swipe.complete); + tryCompare(firstItem.swipe, "position", 1.0); + tryCompare(firstItem.swipe, "complete", true); compare(listView.count, 3); // Wait for it to settle down. @@ -767,8 +790,6 @@ TestCase { break; } compare(listView.count, 2); - - listView.destroy(); } Component { @@ -825,7 +846,7 @@ TestCase { } function test_leadingTrailing(data) { - var control = data.component.createObject(testCase); + var control = createTemporaryObject(data.component, testCase); verify(control); mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); @@ -833,12 +854,10 @@ TestCase { verify(control.swipe.leftItem); compare(control.swipe.leftItem.x, -control.width / 2); mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); - - control.destroy(); } function test_minMaxPosition() { - var control = leadingTrailingXComponent.createObject(testCase); + var control = createTemporaryObject(leadingTrailingXComponent, testCase); verify(control); // Should be limited within the range -1.0 to 1.0. @@ -850,8 +869,6 @@ TestCase { mouseMove(control, control.width * -1.6, control.height / 2, Qt.LeftButton); compare(control.swipe.position, -1.0); mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); - - control.destroy(); } Component { @@ -876,7 +893,7 @@ TestCase { // swipe.position should be scaled to the width of the relevant delegate, // and it shouldn't be possible to drag past the delegate (so that content behind the control is visible). function test_delegateWidth() { - var control = emptySwipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(emptySwipeDelegateComponent, testCase); verify(control); control.swipe.left = smallLeftComponent; @@ -901,8 +918,6 @@ TestCase { mouseRelease(control, control.width / 2 + control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); compare(control.swipe.position, 1.0); tryCompare(control.background, "x", control.swipe.leftItem.width, 1000); - - control.destroy(); } SignalSpy { @@ -916,7 +931,7 @@ TestCase { } function test_positionAfterSwipeCompleted() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); // Ensure that both delegates are constructed. @@ -960,8 +975,6 @@ TestCase { compare(control.swipe.position, 1.0); tryCompare(control.background, "x", control.swipe.leftItem.width, 1000); mouseRelease(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); - - control.destroy(); } // TODO: this somehow results in the behind item having a negative width @@ -1012,7 +1025,7 @@ TestCase { } function test_leadingTrailingBehindItem() { - var control = behindSwipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(behindSwipeDelegateComponent, testCase); verify(control); swipe(control, 0.0, 1.0); @@ -1032,7 +1045,7 @@ TestCase { mouseMove(control, control.width / 2 + control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); compare(control.swipe.position, -0.2); mouseRelease(control, control.width / 2 + control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.swipe.position, 0.0); + tryCompare(control.swipe, "position", 0.0); // Try wrapping the other way. swipe(control, 0.0, -1.0); @@ -1043,9 +1056,7 @@ TestCase { mouseMove(control, control.width / 2 - control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); compare(control.swipe.position, 0.2); mouseRelease(control, control.width / 2 - control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.swipe.position, 0.0); - - control.destroy(); + tryCompare(control.swipe, "position", 0.0); } Component { @@ -1065,9 +1076,13 @@ TestCase { } function test_close() { - var control = closeSwipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(closeSwipeDelegateComponent, testCase); verify(control); + var closedSpy = signalSpyComponent.createObject(control, { target: control.swipe, signalName: "closed" }); + verify(closedSpy); + verify(closedSpy.valid); + swipe(control, 0.0, -1.0); compare(control.swipe.rightItem.visible, true); // Should animate, so it shouldn't change right away. @@ -1079,12 +1094,11 @@ TestCase { mouseRelease(control); verify(!control.swipe.rightItem.SwipeDelegate.pressed); - tryCompare(control.swipe, "position", 0); + tryCompare(closedSpy, "count", 1); + compare(control.swipe.position, 0); // Swiping after closing should work as normal. swipe(control, 0.0, -1.0); - - control.destroy(); } Component { @@ -1133,7 +1147,7 @@ TestCase { // Tests that it's possible to have multiple non-interactive items in one delegate // (e.g. left/right/behind) that can each receive clicks. function test_multipleClickableActions() { - var control = multiActionSwipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(multiActionSwipeDelegateComponent, testCase); verify(control); swipe(control, 0.0, -1.0); @@ -1178,8 +1192,6 @@ TestCase { compare(control.swipe.rightItem.secondAction.SwipeDelegate.pressed, false); compare(secondClickedSpy.count, 1); compare(control.swipe.rightItem.secondClickCount, 1); - - control.destroy(); } // Pressing on a "side action" and then dragging should eventually @@ -1187,7 +1199,7 @@ TestCase { // When this happens, it will grab the mouse and hence we must clear // that action's pressed state so that it doesn't stay pressed after releasing. function test_dragSideAction() { - var listView = removableDelegatesComponent.createObject(testCase); + var listView = createTemporaryObject(removableDelegatesComponent, testCase); verify(listView); var control = listView.itemAt(0, 0); @@ -1208,15 +1220,13 @@ TestCase { verify(listView.contentY !== 0); compare(control.swipe.leftItem.SwipeDelegate.pressed, false); - - listView.destroy(); } // When the width of a SwipeDelegate changes (as it does upon portrait => landscape // rotation, for example), the positions of the contentItem and background items // should be updated accordingly. function test_contentItemPosOnWidthChanged() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); swipe(control, 0.0, 1.0); @@ -1226,12 +1236,10 @@ TestCase { control.width += 100; compare(control.contentItem.x, oldContentItemX + 100); compare(control.background.x, oldBackgroundX + 100); - - control.destroy(); } function test_contentItemHeightOnHeightChanged() { - var control = swipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(swipeDelegateComponent, testCase); verify(control); // Try when swipe.complete is false. @@ -1250,8 +1258,6 @@ TestCase { compare(control.contentItem.height, control.availableHeight); verify(control.contentItem.height < originalContentItemHeight); compare(control.contentItem.y, control.topPadding); - - control.destroy(); } function test_releaseOutside_data() { @@ -1262,7 +1268,7 @@ TestCase { } function test_releaseOutside(data) { - var control = data.component.createObject(testCase); + var control = createTemporaryObject(data.component, testCase); verify(control); // Press and then release below the control. @@ -1345,7 +1351,7 @@ TestCase { } function test_beginSwipeOverRightItem() { - var control = leftRightWithLabelsComponent.createObject(testCase); + var control = createTemporaryObject(leftRightWithLabelsComponent, testCase); verify(control); // Swipe to the left, exposing the right item. @@ -1364,8 +1370,146 @@ TestCase { mouseRelease(rightLabel, rightLabel.width / 2 - overDragDistance, control.height / 2, Qt.LeftButton); verify(!control.swipe.leftItem); + } + + Component { + id: swipeDelegateDisabledComponent + + SwipeDelegate { + id: swipeDelegate + text: "SwipeDelegate" + width: parent.width + height: checked ? implicitHeight * 2 : implicitHeight + checkable: true + + swipe.enabled: false + swipe.right: Label { + text: swipeDelegate.checked ? qsTr("Expanded") : qsTr("Collapsed") + width: parent.width + height: parent.height + padding: 12 + color: "white" + verticalAlignment: Label.AlignVCenter + horizontalAlignment: Label.AlignRight + } + } + } + + function test_swipeEnabled() { + var control = createTemporaryObject(swipeDelegateDisabledComponent, testCase); + + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); + + // It shouldn't be possible to swipe. + var overDragDistance = Math.round(dragDistance * 1.1); + mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); + verify(control.pressed); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); + + // Now move outside the right edge of the control and release. + mouseMove(control, control.width * 1.1, control.height / 2); + verify(control.pressed); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); + + mouseRelease(control, control.width / 2, control.height / 2); + verify(!control.pressed); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); + + // Now enabled swiping so that we can swipe to the left. + control.swipe.enabled = true; + swipe(control, 0, -1); + verify(control.swipe.complete); + + // Now that the swipe is complete, disable swiping and then try to swipe again. + // It should stay at its position of -1. + control.swipe.enabled = false; + + mousePress(control, control.width / 2, control.height / 2); + verify(control.pressed); + compare(control.swipe.position, -1.0); + + mouseMove(control, control.width / 2 + overDragDistance, control.height / 2); + verify(control.pressed); + compare(control.swipe.position, -1.0); + verify(control.swipe.complete); + + mouseRelease(control, control.width / 2 + overDragDistance, control.height / 2); + verify(!control.pressed); + compare(control.swipe.position, -1.0); + verify(control.swipe.complete); + } + + function test_side() { + compare(SwipeDelegate.Left, 1.0); + compare(SwipeDelegate.Right, -1.0); + } + + function test_open_side_data() { + return [ + { tag: "left", side: SwipeDelegate.Left, position: 1, complete: true, left: greenLeftComponent, right: null, behind: null }, + { tag: "right", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: redRightComponent, behind: null }, + { tag: "behind,left", side: SwipeDelegate.Left, position: 1, complete: true, left: null, right: null, behind: greenLeftComponent }, + { tag: "behind,right", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: null, behind: redRightComponent }, + { tag: "left,behind", side: SwipeDelegate.Left, position: 1, complete: true, left: null, right: null, behind: greenLeftComponent }, + { tag: "right,behind", side: SwipeDelegate.Right, position: -1, complete: true, left: null, right: null, behind: redRightComponent }, + { tag: "left,null", side: SwipeDelegate.Left, position: 0, complete: false, left: null, right: null, behind: null }, + { tag: "right,null", side: SwipeDelegate.Right, position: 0, complete: false, left: null, right: null, behind: null }, + { tag: "invalid", side: 0, position: 0, complete: false, left: greenLeftComponent, right: null, behind: null } + ] + } + + function test_open_side(data) { + var control = createTemporaryObject(emptySwipeDelegateComponent, testCase, + {"swipe.left": data.left, "swipe.right": data.right, "swipe.behind": data.behind}); + verify(control); + + control.swipe.open(data.side); + tryCompare(control.swipe, "position", data.position); + tryCompare(control.swipe, "complete", data.complete); + } + + Component { + id: openSwipeDelegateComponent + + SwipeDelegate { + text: "SwipeDelegate" + width: 150 - control.destroy(); + onClicked: swipe.open(SwipeDelegate.Right) + + swipe.right: Item { + width: parent.width + height: parent.height + } + } + } + + function test_open() { + var control = createTemporaryObject(openSwipeDelegateComponent, testCase); + verify(control); + + mouseClick(control); + tryCompare(control.swipe, "position", SwipeDelegate.Right); + tryCompare(control.background, "x", -control.background.width); + + // Swiping after opening should work as normal. + swipe(control, SwipeDelegate.Right, 0.0); + tryCompare(control.swipe, "position", 0.0); + tryCompare(control.background, "x", 0); } Component { @@ -1377,6 +1521,7 @@ TestCase { width: 150 swipe.left: greenLeftComponent swipe.right: redRightComponent + swipe.transition: null property alias behavior: xBehavior property alias animation: numberAnimation @@ -1400,7 +1545,7 @@ TestCase { function test_animations() { // Test that animations are run when releasing from a drag. - var control = animationSwipeDelegateComponent.createObject(testCase); + var control = createTemporaryObject(animationSwipeDelegateComponent, testCase); verify(control); mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); @@ -1413,7 +1558,5 @@ TestCase { verify(!control.down); verify(control.behavior.enabled); verify(control.animation.running); - - control.destroy(); } } |