aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-07-24 15:43:49 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2019-07-25 13:13:16 +0200
commit53e7927fdf56617cfcd3b0e6c9f6db6e0b3d6483 (patch)
treed02e67623473b351c49e5b47cdfc7e770996f0c7 /tests
parentc0e0c755a1c927299607f0af83fadb4a0af6ce20 (diff)
qmllint: Improve signal handler recommendations
- Fix the case where multiple unqualified accesses would be mapped to the same signal (wrong in all but one cases), as the event parameter has the same name and we were using a QHash. Fixed by using QMultiHash and searching for the matching signal handler (by location) - Recommend arrow functions for single line event handlers Change-Id: I3cbb85fe0e49b454908ca03b4c86318ef02e364c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmllint/data/SignalHandler.qml10
-rw-r--r--tests/auto/qml/qmllint/main.cpp5
2 files changed, 13 insertions, 2 deletions
diff --git a/tests/auto/qml/qmllint/data/SignalHandler.qml b/tests/auto/qml/qmllint/data/SignalHandler.qml
index bdf503e3dc..865277cedb 100644
--- a/tests/auto/qml/qmllint/data/SignalHandler.qml
+++ b/tests/auto/qml/qmllint/data/SignalHandler.qml
@@ -1,5 +1,13 @@
import QtQuick 2.0
MouseArea {
- onDoubleClicked: console.log(mouse);
+ onDoubleClicked: {
+ console.log(mouse);
+ // do further things
+ }
+ onClicked: console.info(mouse)
+ onPositionChanged: {
+ console.log(mouse)
+ }
+ onPressAndHold: console.warn(mouse)
}
diff --git a/tests/auto/qml/qmllint/main.cpp b/tests/auto/qml/qmllint/main.cpp
index 038826790b..1069aa5a33 100644
--- a/tests/auto/qml/qmllint/main.cpp
+++ b/tests/auto/qml/qmllint/main.cpp
@@ -110,7 +110,10 @@ void TestQmllint::testUnqualified_data()
QTest::newRow("FromRootDirectParentDirect") << QStringLiteral("FromRootDirectParent.qml") << QStringLiteral("x: parent.unqualified") << 8 << 12;
QTest::newRow("FromRootDirectParentAccess") << QStringLiteral("FromRootDirectParent.qml") << QStringLiteral("property int check: parent.x") << 12 << 29;
// access injected name from signal
- QTest::newRow("SignalHandler") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onDoubleClicked: function(mouse) {...") << 4 << 34;
+ QTest::newRow("SignalHandler1") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onDoubleClicked: function(mouse) {...") << 5 << 21;
+ QTest::newRow("SignalHandler2") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onPositionChanged: function(mouse) {...") << 10 << 21;
+ QTest::newRow("SignalHandlerShort1") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onClicked: (mouse) => {...") << 8 << 29;
+ QTest::newRow("SignalHandlerShort2") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onPressAndHold: (mouse) => {...") << 12 << 34;
}