aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/testlib/TestCase.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/testlib/TestCase.qml')
-rw-r--r--src/imports/testlib/TestCase.qml36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 160e0bdb62..8425b0641c 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -846,6 +846,8 @@ Item {
function waitForRendering(item, timeout) {
if (timeout === undefined)
timeout = 5000
+ if (!item)
+ qtest_fail("No item given to waitForRendering", 1)
return qtest_results.waitForRendering(item, timeout)
}
@@ -932,12 +934,13 @@ Item {
}
/*!
- \qmlmethod TestCase::mousePress(item, x, y, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+ \qmlmethod TestCase::mousePress(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
Simulates pressing a mouse \a button with an optional \a modifier
- on an \a item. The position is defined by \a x and \a y. If \a delay is
- specified, the test will wait for the specified amount of milliseconds
- before the press.
+ on an \a item. The position is defined by \a x and \a y.
+ If \a x or \a y are not defined the position will be the center of \a item.
+ If \a delay is specified, the test will wait for the specified amount of
+ milliseconds before the press.
The position given by \a x and \a y is transformed from the co-ordinate
system of \a item into window co-ordinates and then delivered.
@@ -953,15 +956,20 @@ Item {
modifiers = Qt.NoModifier
if (delay == undefined)
delay = -1
+ if (x === undefined)
+ x = item.width / 2
+ if (y === undefined)
+ y = item.height / 2
if (!qtest_events.mousePress(item, x, y, button, modifiers, delay))
qtest_fail("window not shown", 2)
}
/*!
- \qmlmethod TestCase::mouseRelease(item, x, y, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+ \qmlmethod TestCase::mouseRelease(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
Simulates releasing a mouse \a button with an optional \a modifier
on an \a item. The position of the release is defined by \a x and \a y.
+ If \a x or \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
milliseconds before releasing the button.
@@ -979,6 +987,10 @@ Item {
modifiers = Qt.NoModifier
if (delay == undefined)
delay = -1
+ if (x === undefined)
+ x = item.width / 2
+ if (y === undefined)
+ y = item.height / 2
if (!qtest_events.mouseRelease(item, x, y, button, modifiers, delay))
qtest_fail("window not shown", 2)
}
@@ -1033,10 +1045,11 @@ Item {
}
/*!
- \qmlmethod TestCase::mouseClick(item, x, y, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+ \qmlmethod TestCase::mouseClick(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
Simulates clicking a mouse \a button with an optional \a modifier
on an \a item. The position of the click is defined by \a x and \a y.
+ If \a x and \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
milliseconds before pressing and before releasing the button.
@@ -1054,15 +1067,20 @@ Item {
modifiers = Qt.NoModifier
if (delay == undefined)
delay = -1
+ if (x === undefined)
+ x = item.width / 2
+ if (y === undefined)
+ y = item.height / 2
if (!qtest_events.mouseClick(item, x, y, button, modifiers, delay))
qtest_fail("window not shown", 2)
}
/*!
- \qmlmethod TestCase::mouseDoubleClick(item, x, y, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
+ \qmlmethod TestCase::mouseDoubleClick(item, x = item.width / 2, y = item.height / 2, button = Qt.LeftButton, modifiers = Qt.NoModifier, delay = -1)
Simulates double-clicking a mouse \a button with an optional \a modifier
on an \a item. The position of the click is defined by \a x and \a y.
+ If \a x and \a y are not defined the position will be the center of \a item.
If \a delay is specified, the test will wait for the specified amount of
milliseconds before pressing and before releasing the button.
@@ -1080,6 +1098,10 @@ Item {
modifiers = Qt.NoModifier
if (delay == undefined)
delay = -1
+ if (x === undefined)
+ x = item.width / 2
+ if (y === undefined)
+ y = item.height / 2
if (!qtest_events.mouseDoubleClick(item, x, y, button, modifiers, delay))
qtest_fail("window not shown", 2)
}