aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2016-03-31 17:42:43 +0200
committerAlbert Astals Cid <albert.astals@canonical.com>2016-04-01 15:26:02 +0000
commit886662d409f6422bc43df500314470f776958bfd (patch)
tree2827ebd1b53bc70bca52a84bdc6ef00d78cba1bd /src/imports
parent3fb0f3fc8311b1e1d85e6f56d8d9cbc5c0be99b7 (diff)
Give a nicer error if the passed item doesn't exist
Instead of Cannot read property 'width' of null and a line pointing to TestCase.qml, you get No item given to mouseWheel and a line pointing to the offending code Change-Id: I8e035878035cb836a4c0c33a772ad4353d8dd000 Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/testlib/TestCase.qml24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index 8bedad40e9..c736a1a93a 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -966,6 +966,9 @@ Item {
\sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mousePress(item, x, y, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mousePress", 1)
+
if (button === undefined)
button = Qt.LeftButton
if (modifiers === undefined)
@@ -997,6 +1000,9 @@ Item {
\sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseRelease(item, x, y, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseRelease", 1)
+
if (button === undefined)
button = Qt.LeftButton
if (modifiers === undefined)
@@ -1030,6 +1036,9 @@ Item {
\sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseWheel()
*/
function mouseDrag(item, x, y, dx, dy, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseDrag", 1)
+
if (item.x === undefined || item.y === undefined)
return
if (button === undefined)
@@ -1077,6 +1086,9 @@ Item {
\sa mousePress(), mouseRelease(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseClick(item, x, y, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseClick", 1)
+
if (button === undefined)
button = Qt.LeftButton
if (modifiers === undefined)
@@ -1108,6 +1120,9 @@ Item {
\sa mouseDoubleClickSequence(), mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseDoubleClick(item, x, y, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseDoubleClick", 1)
+
if (button === undefined)
button = Qt.LeftButton
if (modifiers === undefined)
@@ -1146,6 +1161,9 @@ Item {
\sa mouseDoubleClick(), mousePress(), mouseRelease(), mouseClick(), mouseMove(), mouseDrag(), mouseWheel()
*/
function mouseDoubleClickSequence(item, x, y, button, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseDoubleClickSequence", 1)
+
if (button === undefined)
button = Qt.LeftButton
if (modifiers === undefined)
@@ -1175,6 +1193,9 @@ Item {
\sa mousePress(), mouseRelease(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseDrag(), mouseWheel()
*/
function mouseMove(item, x, y, delay, buttons) {
+ if (!item)
+ qtest_fail("No item given to mouseMove", 1)
+
if (delay == undefined)
delay = -1
if (buttons == undefined)
@@ -1200,6 +1221,9 @@ Item {
\sa mousePress(), mouseClick(), mouseDoubleClick(), mouseDoubleClickSequence(), mouseMove(), mouseRelease(), mouseDrag(), QWheelEvent::angleDelta()
*/
function mouseWheel(item, x, y, xDelta, yDelta, buttons, modifiers, delay) {
+ if (!item)
+ qtest_fail("No item given to mouseWheel", 1)
+
if (delay == undefined)
delay = -1
if (buttons == undefined)