From b9ff90423879c9b27d049b47b1b19a6695878ccd Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 24 Nov 2015 10:59:09 +0100 Subject: Properly check the arguments of mapFrom/ToItem Check that we have the right type and number of arguments and throw a type error if they don't match. Change-Id: I23d37074bf0a6f88e656897862eedc8f7c9f9f8f Task-number: QTBUG-41686 Reviewed-by: Simon Hausmann --- tests/auto/quick/qquickitem2/data/mapCoordinates.qml | 16 ++++++++++++---- tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml index 0b0b15a767..a9c5030e12 100644 --- a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml +++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml @@ -65,12 +65,20 @@ Item { } function checkMapAToInvalid(x, y) { - var pos = itemA.mapToItem(1122, x, y) - return pos == undefined; + try { + itemA.mapToItem(1122, x, y) + } catch (e) { + return e instanceof TypeError + } + return false } function checkMapAFromInvalid(x, y) { - var pos = itemA.mapFromItem(1122, x, y) - return pos == undefined; + try { + itemA.mapFromItem(1122, x, y) + } catch (e) { + return e instanceof TypeError + } + return false } } diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml index e21aab1f01..c127407eae 100644 --- a/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml +++ b/tests/auto/quick/qquickitem2/data/mapCoordinatesRect.qml @@ -66,12 +66,20 @@ Item { } function checkMapAToInvalid(x, y, w, h) { - var pos = itemA.mapToItem(1122, x, y, w, h) - return pos == undefined; + try { + itemA.mapToItem(1122, x, y, w, h) + } catch (e) { + return e instanceof TypeError + } + return false; } function checkMapAFromInvalid(x, y, w, h) { - var pos = itemA.mapFromItem(1122, x, y, w, h) - return pos == undefined; + try { + itemA.mapFromItem(1122, x, y, w, h) + } catch (e) { + return e instanceof TypeError + } + return false; } } -- cgit v1.2.3