aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Bugaev <freedbrt@gmail.com>2021-06-21 16:10:45 +0300
committerShawn Rutledge <shawn.rutledge@qt.io>2021-07-12 11:25:57 +0200
commit98ebf99f32004dc6184e3026eafd29448f623335 (patch)
treec1172e33a7537bda87851181fe7b6dda77c747a5
parentd739972285e7126f157a31019597331210212029 (diff)
Fix tests due to QQuickItem::contains() function behavior change
A lot of tests broke because they used to rely on the behavior that you can send an event to an item on its right and bottom edge, and the ability to send an event to an item of zero size. Change-Id: I9c5883ddb327c751221b4f03bb9a699d69961d3a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 6ea8c21ccf1bf4f88361bc1ad99944b1cf38aba4)
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml5
-rw-r--r--tests/auto/controls/data/tst_button.qml2
-rw-r--r--tests/auto/controls/data/tst_rangeslider.qml26
-rw-r--r--tests/auto/controls/data/tst_scrollbar.qml6
-rw-r--r--tests/auto/controls/data/tst_slider.qml6
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml13
-rw-r--r--tests/auto/controls/data/tst_switch.qml13
-rw-r--r--tests/auto/controls/data/tst_switchdelegate.qml5
8 files changed, 42 insertions, 34 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index 40c6f21d..00f8affd 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -62,7 +62,10 @@ TestCase {
Component {
id: button
- AbstractButton {}
+ AbstractButton {
+ width: 100
+ height: 50
+ }
}
Component {
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index dbfacff0..a6ec4faa 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -210,7 +210,7 @@ TestCase {
verify(pressedSpy1.valid)
var touch = touchEvent(control1)
- touch.press(0, control1, 0, 0).commit().move(0, control1, control1.width, control1.height).commit()
+ touch.press(0, control1, 0, 0).commit().move(0, control1, control1.width - 1, control1.height - 1).commit()
compare(pressedSpy1.count, ++pressedCount1)
compare(control1.pressed, true)
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml
index c42a1d1e..13687397 100644
--- a/tests/auto/controls/data/tst_rangeslider.qml
+++ b/tests/auto/controls/data/tst_rangeslider.qml
@@ -301,7 +301,7 @@ TestCase {
verify(secondMovedSpy.valid)
// Press and release the first handle without moving it.
- mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton)
+ mousePress(control, control.leftPadding, control.height - control.bottomPadding - 1, Qt.LeftButton)
compare(firstPressedSpy.count, 1)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 0)
@@ -313,7 +313,7 @@ TestCase {
compare(control.second.value, 1.0)
compare(control.second.position, 1.0)
- mouseRelease(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton)
+ mouseRelease(control, control.leftPadding, control.height - control.bottomPadding - 1, Qt.LeftButton)
compare(firstPressedSpy.count, 2)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 0)
@@ -326,7 +326,7 @@ TestCase {
compare(control.second.position, 1.0)
// Press and release the second handle without moving it.
- mousePress(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton)
+ mousePress(control, control.width - control.rightPadding - 1, control.topPadding, Qt.LeftButton)
compare(firstPressedSpy.count, 2)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 1)
@@ -338,7 +338,7 @@ TestCase {
compare(control.second.value, 1.0)
compare(control.second.position, 1.0)
- mouseRelease(control, control.width - control.rightPadding, control.topPadding, Qt.LeftButton)
+ mouseRelease(control, control.width - control.rightPadding - 1, control.topPadding, Qt.LeftButton)
compare(firstPressedSpy.count, 2)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 2)
@@ -351,7 +351,7 @@ TestCase {
compare(control.second.position, 1.0)
// Press and release on the bottom left corner of the control without moving the handle.
- mousePress(control, 0, control.height, Qt.LeftButton)
+ mousePress(control, 0, control.height - 1, Qt.LeftButton)
compare(firstPressedSpy.count, 3)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 2)
@@ -363,7 +363,7 @@ TestCase {
compare(control.second.value, 1.0)
compare(control.second.position, 1.0)
- mouseRelease(control, 0, control.height, Qt.LeftButton)
+ mouseRelease(control, 0, control.height - 1, Qt.LeftButton)
compare(firstPressedSpy.count, 4)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 2)
@@ -376,7 +376,7 @@ TestCase {
compare(control.second.position, 1.0)
// Drag the first handle.
- mousePress(control, control.leftPadding, control.height - control.bottomPadding, Qt.LeftButton)
+ mousePress(control, control.leftPadding, control.height - control.bottomPadding - 1, Qt.LeftButton)
compare(firstPressedSpy.count, 5)
compare(firstMovedSpy.count, 0)
compare(secondPressedSpy.count, 2)
@@ -493,7 +493,7 @@ TestCase {
compare(control.second.position, 1.0)
// Press and release on the bottom left corner of the control without moving the handle.
- touch.press(0, control, 0, control.height).commit()
+ touch.press(0, control, 0, control.height - 1).commit()
compare(firstPressedSpy.count, 3)
compare(secondPressedSpy.count, 2)
compare(control.first.pressed, true)
@@ -503,7 +503,7 @@ TestCase {
compare(control.second.value, 1.0)
compare(control.second.position, 1.0)
- touch.release(0, control, 0, control.height).commit()
+ touch.release(0, control, 0, control.height - 1).commit()
compare(firstPressedSpy.count, 4)
compare(secondPressedSpy.count, 2)
compare(control.first.pressed, false)
@@ -565,7 +565,7 @@ TestCase {
compare(control1.second.position, 1.0)
// press and move the second handle of the first slider
- touch.stationary(0).press(1, control1, control1.width, control1.height).commit()
+ touch.stationary(0).press(1, control1, control1.width - 1, control1.height - 1).commit()
touch.stationary(0).move(1, control1, control1.width / 2, control1.height / 2).commit()
compare(control1.first.pressed, true)
compare(control1.first.position, 0.5)
@@ -588,7 +588,7 @@ TestCase {
compare(control2.second.position, 1.0)
// press and move the second handle of the second slider
- touch.stationary(0).stationary(1).stationary(2).press(3, control2, control2.width, control2.height).commit()
+ touch.stationary(0).stationary(1).stationary(2).press(3, control2, control2.width - 1, control2.height - 1).commit()
touch.stationary(0).stationary(1).stationary(2).move(3, control2, control2.width / 2, control2.height / 2).commit()
compare(control1.first.pressed, true)
compare(control1.first.position, 0.5)
@@ -962,11 +962,11 @@ TestCase {
compare(control.first.pressed, false)
compare(control.second.pressed, false)
- mousePress(control, control.width - control.rightPadding, control.height / 2)
+ mousePress(control, control.width - control.rightPadding - 1, control.height / 2)
compare(control.first.pressed, false)
compare(control.second.pressed, true)
- mouseRelease(control, control.width - control.rightPadding, control.height / 2)
+ mouseRelease(control, control.width - control.rightPadding - 1, control.height / 2)
compare(control.first.pressed, false)
compare(control.second.pressed, false)
}
diff --git a/tests/auto/controls/data/tst_scrollbar.qml b/tests/auto/controls/data/tst_scrollbar.qml
index 9e649e37..f15983a9 100644
--- a/tests/auto/controls/data/tst_scrollbar.qml
+++ b/tests/auto/controls/data/tst_scrollbar.qml
@@ -277,9 +277,11 @@ TestCase {
compare(control.pressed, false)
compare(control.position, 0.5)
- mousePress(control, control.width, control.height, Qt.LeftButton)
+ mousePress(control, control.width - 1, control.height - 1, Qt.LeftButton)
compare(pressedSpy.count, 3)
compare(control.pressed, true)
+ // We can't click on right and bottom edge, so click to (width-1, height-1), and move mouse to (width,height)
+ mouseMove(control, control.width, control.height, 0)
compare(control.position, 1.0)
mouseMove(control, control.width * 2, control.height * 2, 0)
@@ -354,7 +356,7 @@ TestCase {
compare(control.pressed, false)
compare(control.position, 0.5)
- touch.press(0, control, control.width, control.height).commit()
+ touch.press(0, control, control.width - 1, control.height - 1).commit()
compare(pressedSpy.count, 3)
compare(control.pressed, true)
compare(control.position, 0.5)
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 73031a70..d105473c 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -236,7 +236,7 @@ TestCase {
var movedSpy = signalSpy.createObject(control, {target: control, signalName: "moved"})
verify(movedSpy.valid)
- mousePress(control, 0, control.height, Qt.LeftButton)
+ mousePress(control, 0, control.height - 1, Qt.LeftButton)
compare(pressedSpy.count, ++pressedCount)
compare(movedSpy.count, movedCount)
compare(control.pressed, true)
@@ -265,7 +265,7 @@ TestCase {
compare(control.value, 0.5)
compare(control.position, 0.5)
- mousePress(control, control.width, 0, Qt.LeftButton)
+ mousePress(control, control.width - 1, 0, Qt.LeftButton)
compare(pressedSpy.count, ++pressedCount)
compare(movedSpy.count, ++movedCount)
compare(control.pressed, true)
@@ -355,7 +355,7 @@ TestCase {
compare(control.value, 0.5)
compare(control.position, 0.5)
- touch.press(0, control, control.width, control.height).commit()
+ touch.press(0, control, control.width - 1, control.height - 1).commit()
compare(pressedSpy.count, ++pressedCount)
compare(movedSpy.count, movedCount)
compare(control.pressed, true)
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 17440042..7b4fdcd1 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -963,25 +963,26 @@ TestCase {
// Swipe from right to left without exposing the right item,
// and make sure that the right item never becomes visible
// (and hence that the left item never loses visibility).
- mousePress(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton);
+ mousePress(control, control.swipe.leftItem.width - 1, control.height / 2, Qt.LeftButton);
compare(leftVisibleSpy.count, 0);
compare(rightVisibleSpy.count, 0);
- var newX = control.swipe.leftItem.width - Math.round(dragDistance * 1.1);
+ var newX = control.swipe.leftItem.width - Math.round(dragDistance * 1.1) -1;
mouseMove(control, newX, control.height / 2);
compare(leftVisibleSpy.count, 0);
compare(rightVisibleSpy.count, 0);
- compare(control.swipe.position, newX / control.swipe.leftItem.width);
+ compare(control.swipe.position, (newX + 1) / control.swipe.leftItem.width);
mouseMove(control, 0, control.height / 2);
- compare(control.swipe.position, 0);
+ compare(control.swipe.position, 1 / control.swipe.leftItem.width);
+ // Because we move from (width - 1) to 0, so one pixel remains
// Test swiping over a distance that is greater than the width of the left item.
mouseMove(control, -1, control.height / 2);
verify(control.swipe.rightItem);
- compare(control.swipe.position, -1 / control.swipe.rightItem.width);
+ compare(control.swipe.position, 0);
// Now go back to 1.0.
- mouseMove(control, control.swipe.leftItem.width, control.height / 2);
+ mouseMove(control, control.swipe.leftItem.width - 1, control.height / 2);
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);
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index 9050964f..7bd09399 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -334,7 +334,7 @@ TestCase {
compare(control.pressed, true)
verify(spy.success)
- mouseMove(control.indicator, control.width)
+ mouseMove(control.indicator, control.width - 1)
compare(control.position, 1.0)
compare(control.checked, false)
compare(control.pressed, true)
@@ -344,7 +344,7 @@ TestCase {
"toggled",
"released",
"clicked"]
- mouseRelease(control.indicator, control.indicator.width)
+ mouseRelease(control.indicator, control.indicator.width - 1)
compare(control.position, 1.0)
compare(control.checked, true)
compare(control.pressed, false)
@@ -379,7 +379,7 @@ TestCase {
"toggled",
"released",
"clicked"]
- mouseRelease(control, control.width)
+ mouseRelease(control, control.width - 1)
compare(control.position, 0.0)
compare(control.checked, false)
compare(control.pressed, false)
@@ -388,7 +388,7 @@ TestCase {
// press-drag-release from and to outside the indicator
spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
"pressed"]
- mousePress(control, control.width)
+ mousePress(control, control.width - 1)
compare(control.position, 0.0)
compare(control.checked, false)
compare(control.pressed, true)
@@ -414,7 +414,7 @@ TestCase {
"toggled",
"released",
"clicked"]
- mouseRelease(control, control.width)
+ mouseRelease(control, control.width - 1)
compare(control.position, 1.0)
compare(control.checked, true)
compare(control.pressed, false)
@@ -495,7 +495,8 @@ TestCase {
// press-drag-release from and to outside the indicator
spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
"pressed"]
- touch.press(0, control, control.width).commit()
+ wait(Qt.styleHints.mouseDoubleClickInterval + 50)
+ touch.press(0, control, control.width - 1).commit()
compare(control.position, 0.0)
compare(control.checked, false)
compare(control.pressed, true)
diff --git a/tests/auto/controls/data/tst_switchdelegate.qml b/tests/auto/controls/data/tst_switchdelegate.qml
index fabd6279..a1ff9f4a 100644
--- a/tests/auto/controls/data/tst_switchdelegate.qml
+++ b/tests/auto/controls/data/tst_switchdelegate.qml
@@ -384,7 +384,7 @@ TestCase {
// press-drag-release from and to outside the indicator
spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
"pressed"]
- mousePress(control, control.width)
+ mousePress(control, control.width - 1)
compare(control.position, 0.0)
compare(control.checked, false)
compare(control.pressed, true)
@@ -491,7 +491,8 @@ TestCase {
// press-drag-release from and to outside the indicator
spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
"pressed"]
- touch.press(0, control, control.width).commit()
+ wait(Qt.styleHints.mouseDoubleClickInterval + 50)
+ touch.press(0, control, control.width - 1).commit()
compare(control.position, 0.0)
compare(control.checked, false)
compare(control.pressed, true)