From 7811c2b31a8704e99474777ce21f3a22483b8a8c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 18 Nov 2019 11:44:47 +0100 Subject: tst_dial: fix test_dragging afer mouseDrag() changes 02ffe50af41526f604ae61d41bf2150037d67473 fixed some incorrect behavior in mouseDrag() that these tests were unknowingly relying on. Fixes: QTBUG-80153 Change-Id: I486061cc7d7fe44ef7b9ff8924c711572a01e44a Reviewed-by: Liang Qi --- tests/auto/controls/data/tst_dial.qml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index 86999594..26f30c33 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -223,33 +223,39 @@ TestCase { var minimumExpectedValueCount = data.live ? 2 : 1; // drag to the left - mouseDrag(dial, dial.width / 2, dial.height / 2, -dial.width / 2, 0, Qt.LeftButton); + // we always add or subtract 1 to ensure we start the drag from the opposite side + // of where we're dragging to, for more reliable tests + mouseDrag(dial, dial.width / 2 + 1, dial.height / 2, -dial.width / 2, 0, Qt.LeftButton); fuzzyCompare(dial.value, data.leftValue, 0.1); - verify(valueSpy.count >= minimumExpectedValueCount); + verify(valueSpy.count >= minimumExpectedValueCount, "expected valueChanged to be emitted at least " + + minimumExpectedValueCount + " time(s), but it was only emitted " + valueSpy.count + " time(s)"); valueSpy.clear(); verify(moveSpy.count > 0); moveSpy.clear(); // drag to the top - mouseDrag(dial, dial.width / 2, dial.height / 2, 0, -dial.height / 2, Qt.LeftButton); + mouseDrag(dial, dial.width / 2, dial.height / 2 + 1, 0, -dial.height / 2, Qt.LeftButton); fuzzyCompare(dial.value, data.topValue, 0.1); - verify(valueSpy.count >= minimumExpectedValueCount); + verify(valueSpy.count >= minimumExpectedValueCount, "expected valueChanged to be emitted at least " + + minimumExpectedValueCount + " time(s), but it was only emitted " + valueSpy.count + " time(s)"); valueSpy.clear(); verify(moveSpy.count > 0); moveSpy.clear(); // drag to the right - mouseDrag(dial, dial.width / 2, dial.height / 2, dial.width / 2, 0, Qt.LeftButton); + mouseDrag(dial, dial.width / 2 - 1, dial.height / 2, dial.width / 2, 0, Qt.LeftButton); fuzzyCompare(dial.value, data.rightValue, 0.1); - verify(valueSpy.count >= minimumExpectedValueCount); + verify(valueSpy.count >= minimumExpectedValueCount, "expected valueChanged to be emitted at least " + + minimumExpectedValueCount + " time(s), but it was only emitted " + valueSpy.count + " time(s)"); valueSpy.clear(); verify(moveSpy.count > 0); moveSpy.clear(); // drag to the bottom (* 0.6 to ensure we don't go over to the minimum position) - mouseDrag(dial, dial.width / 2, dial.height / 2, 10, dial.height / 2, Qt.LeftButton); + mouseDrag(dial, dial.width / 2, dial.height / 2 - 1, 10, dial.height / 2, Qt.LeftButton); fuzzyCompare(dial.value, data.bottomValue, 0.1); - verify(valueSpy.count >= minimumExpectedValueCount); + verify(valueSpy.count >= minimumExpectedValueCount, "expected valueChanged to be emitted at least " + + minimumExpectedValueCount + " time(s), but it was only emitted " + valueSpy.count + " time(s)"); valueSpy.clear(); verify(moveSpy.count > 0); moveSpy.clear(); -- cgit v1.2.3