diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-12-13 15:24:35 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-12-14 19:46:13 +0000 |
commit | e2cf98bcedb65c1c28eaaa8e045523cb0857fa9e (patch) | |
tree | 78b5419d5dae7e5888d2912498ce997903f38ef3 /tests/auto/controls/data/tst_swipedelegate.qml | |
parent | a506a0ac792ce3fc01408fb2948eb247fc4c7181 (diff) |
tst_swipedelegate: use more reliable swipe.closed()
Interactive SwipeDelegate auto tests wait for animations to finish,
before they continue sending next mouse events, because sending mouse
events while a transition is running would lead to unexpected results.
(Fuzzy) comparing swipe.position is no longer a reliable way to test
that the delegate has been fully opened or closed. Since the value is
animated smoothly and updates frequently during the transition, fuzzy
compare often succeeds right before the transition finishes.
Change-Id: Id83cac6bc3b3ba4e2c34ab15837e033d1ffb1c1e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_swipedelegate.qml')
-rw-r--r-- | tests/auto/controls/data/tst_swipedelegate.qml | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 134fad85..dc746c33 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -567,6 +567,10 @@ TestCase { var control = swipeDelegateWithButtonComponent.createObject(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. @@ -604,7 +608,8 @@ 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(control.swipe, "position", 0); + tryCompare(closedSpy, "count", 1); + compare(control.swipe.position, 0); mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); verify(!button.pressed); @@ -1100,6 +1105,10 @@ TestCase { var control = closeSwipeDelegateComponent.createObject(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. @@ -1111,7 +1120,8 @@ 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); |