diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-25 14:26:31 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-25 14:26:37 +0100 |
commit | 22769ac6a7667bf1d2d5b5e6421a15e4f6aadce1 (patch) | |
tree | dc76832e65fae17b99089d9cf7b41ef87aad1e7e /tests | |
parent | eba5b547e7f1c3817d172936293e03535225f8ee (diff) | |
parent | ac99683595e27b4157f9fd397fefa378955e275c (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: If528b9f4e502c50e0cd76df75404e257232f0d18
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_abstractbutton.qml | 22 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_swipedelegate.qml | 137 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tooltip.qml | 3 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_tumbler.qml | 8 |
4 files changed, 155 insertions, 15 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml index 27fc4525..83ca7980 100644 --- a/tests/auto/controls/data/tst_abstractbutton.qml +++ b/tests/auto/controls/data/tst_abstractbutton.qml @@ -60,6 +60,11 @@ TestCase { Item { } } + Component { + id: signalSpy + SignalSpy { } + } + function test_text() { var control = button.createObject(testCase); verify(control); @@ -103,4 +108,21 @@ TestCase { control.destroy() } + + function test_pressAndHold() { + var control = button.createObject(testCase, {checkable: true}) + verify(control) + + var pressAndHoldSpy = signalSpy.createObject(control, {target: control, signalName: "pressAndHold"}) + verify(pressAndHoldSpy.valid) + + mousePress(control) + pressAndHoldSpy.wait() + compare(control.checked, false) + + mouseRelease(control) + compare(control.checked, false) + + control.destroy() + } } diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index fa2d218f..92f25e2a 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -377,7 +377,7 @@ TestCase { verify(control.swipe.rightItem); verify(!control.swipe.rightItem.visible); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width / 2, control.height / 2); verify(!control.pressed); compare(control.swipe.position, 1.0); @@ -407,7 +407,8 @@ TestCase { compare(completedSpy.count, 1); compare(control.swipe.position, 1.0 - overDragDistance / control.width); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + // 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); @@ -431,7 +432,7 @@ TestCase { compare(completedSpy.count, 2); compare(control.swipe.position, 0.4); - mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "canceled"]; mouseRelease(control, control.width * -0.1, control.height / 2); verify(!control.pressed); compare(control.swipe.position, 0.0); @@ -1054,17 +1055,17 @@ TestCase { text: "SwipeDelegate" width: 150 - onClicked: close() - swipe.right: Item { width: parent.width height: parent.height + + SwipeDelegate.onClicked: swipe.close() } } } function test_close() { - var control = swipeDelegateComponent.createObject(testCase); + var control = closeSwipeDelegateComponent.createObject(testCase); verify(control); swipe(control, 0.0, -1.0); @@ -1073,6 +1074,16 @@ TestCase { compare(control.swipe.rightItem.x, 0); tryCompare(control.swipe.rightItem, "x", control.background.x + control.background.width); + mousePress(control); + verify(control.swipe.rightItem.SwipeDelegate.pressed); + + mouseRelease(control); + verify(!control.swipe.rightItem.SwipeDelegate.pressed); + tryCompare(control.swipe, "position", 0); + + // Swiping after closing should work as normal. + swipe(control, 0.0, -1.0); + control.destroy(); } @@ -1242,4 +1253,118 @@ TestCase { control.destroy(); } + + function test_releaseOutside_data() { + return [ + { tag: "no delegates", component: emptySwipeDelegateComponent }, + { tag: "delegates", component: swipeDelegateComponent }, + ]; + } + + function test_releaseOutside(data) { + var control = data.component.createObject(testCase); + verify(control); + + // Press and then release below the control. + mouseSignalSequenceSpy.target = control; + mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed", ["pressedChanged", { "pressed": false }]]; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width / 2, control.height + 10, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + + mouseSignalSequenceSpy.expectedSequence = ["canceled"]; + mouseRelease(control, control.width / 2, control.height + 10, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + + // Press and then release to the right of the control. + var hasDelegates = control.swipe.left || control.swipe.right || control.swipe.behind; + mouseSignalSequenceSpy.target = control; + mouseSignalSequenceSpy.expectedSequence = hasDelegates + ? [["pressedChanged", { "pressed": true }], "pressed"] + : [["pressedChanged", { "pressed": true }], "pressed", ["pressedChanged", { "pressed": false }]]; + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); + mouseMove(control, control.width + 10, control.height / 2, Qt.LeftButton); + if (hasDelegates) + verify(control.swipe.position > 0); + verify(mouseSignalSequenceSpy.success); + + mouseSignalSequenceSpy.expectedSequence = hasDelegates ? [["pressedChanged", { "pressed": false }], "canceled"] : ["canceled"]; + mouseRelease(control, control.width + 10, control.height / 2, Qt.LeftButton); + verify(mouseSignalSequenceSpy.success); + } + + Component { + id: leftRightWithLabelsComponent + + SwipeDelegate { + id: delegate + text: "SwipeDelegate" + width: 150 + + background.opacity: 0.5 + + swipe.left: Rectangle { + width: parent.width + height: parent.height + color: SwipeDelegate.pressed ? Qt.darker("green") : "green" + + property alias label: label + + Label { + id: label + text: "Left" + color: "white" + anchors.margins: 10 + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + } + + SwipeDelegate.onClicked: delegate.swipe.close() + } + + swipe.right: Rectangle { + width: parent.width + height: parent.height + anchors.right: parent.right + color: SwipeDelegate.pressed ? Qt.darker("green") : "red" + + property alias label: label + + Label { + id: label + text: "Right" + color: "white" + anchors.margins: 10 + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + } + + SwipeDelegate.onClicked: delegate.swipe.close() + } + } + } + + function test_beginSwipeOverRightItem() { + var control = leftRightWithLabelsComponent.createObject(testCase); + verify(control); + + // Swipe to the left, exposing the right item. + swipe(control, 0.0, -1.0); + + // Click to close it and go back to a position of 0. + mouseClick(control); + + // TODO: Swipe to the left, with the mouse over the Label in the right item. + // The left item should not become visible at any point. + var rightLabel = control.swipe.rightItem.label; + var overDragDistance = Math.round(dragDistance * 1.1); + mousePress(rightLabel, rightLabel.width / 2, rightLabel.height / 2, Qt.rightButton); + mouseMove(rightLabel, rightLabel.width / 2 - overDragDistance, rightLabel.height / 2, Qt.LeftButton); + verify(!control.swipe.leftItem); + + mouseRelease(rightLabel, rightLabel.width / 2 - overDragDistance, control.height / 2, Qt.LeftButton); + verify(!control.swipe.leftItem); + + control.destroy(); + } } diff --git a/tests/auto/controls/data/tst_tooltip.qml b/tests/auto/controls/data/tst_tooltip.qml index d9c95dbf..51601d66 100644 --- a/tests/auto/controls/data/tst_tooltip.qml +++ b/tests/auto/controls/data/tst_tooltip.qml @@ -240,8 +240,7 @@ TestCase { else control.visible = false verify(control.exit.running) - wait(100) // TODO: replace with tryVerify() in 5.8 - verify(control.opacity < 1) + tryVerify(function() { return control.opacity < 1; }) if (data.imperative) control.open() diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index 8fde5e8c..cde319ea 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -83,16 +83,10 @@ TestCase { } function cleanup() { - var destroyed = false; - cleanupItem.Component.destruction.connect(function() { destroyed = true; }); - cleanupItem.destroy(); - // Waiting until it's deleted before continuing makes debugging // test failures much easier, because there aren't unrelated items hanging around. - // TODO: Replace with tryVerify(!tumbler) in 5.8. - while (!destroyed) - wait(0) + tryVerify(function() { return !tumbler; }); } function createTumbler(args) { |