diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-01-27 15:02:00 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-31 12:41:53 +0000 |
commit | 802f081151b6fc188db5974ff7cd2e1e6337a691 (patch) | |
tree | 072f6d60aecf52816b62ba0fb5393bba067f1cc7 /tests | |
parent | 63b4180aeb60afd4e991786eb3002baa2a628a35 (diff) |
Distinguish property change signals from user-defined signals
Do not expose this information to qmltypes just yet, though,
as this seems irrelevant at the moment
Change-Id: Iffd8901ef9899a0fff226e8799bf45c1d688b92b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit b1bb4c8e5f0d4a65f36b2002bcdaf9bfcbed8c77)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmljsscope/data/signalCreationDifferences.qml | 9 | ||||
-rw-r--r-- | tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp | 23 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmljsscope/data/signalCreationDifferences.qml b/tests/auto/qml/qqmljsscope/data/signalCreationDifferences.qml new file mode 100644 index 0000000000..a241a4a84a --- /dev/null +++ b/tests/auto/qml/qqmljsscope/data/signalCreationDifferences.qml @@ -0,0 +1,9 @@ +import QtQml +QtObject { + property string myProperty: "foobar" + + signal mySignal() + + property int conflictingProperty: 42 + signal conflictingPropertyChanged(a: real, c: string) +} diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp index f95e48d51e..69eb271984 100644 --- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp +++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp @@ -97,6 +97,7 @@ private Q_SLOTS: void initTestCase() override; void orderedBindings(); + void signalCreationDifferences(); public: tst_qqmljsscope() : QQmlDataTest(QT_QMLTEST_DATADIR) { } @@ -140,5 +141,27 @@ void tst_qqmljsscope::orderedBindings() QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_qs); } +void tst_qqmljsscope::signalCreationDifferences() +{ + QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_qs); + QVERIFY(root); + + QVERIFY(root->hasOwnProperty(u"myProperty"_qs)); + QVERIFY(root->hasOwnProperty(u"conflictingProperty"_qs)); + QCOMPARE(root->ownMethods(u"mySignal"_qs).size(), 1); + + const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_qs); + QCOMPARE(conflicting.size(), 2); + QCOMPARE(conflicting[0].methodType(), QQmlJSMetaMethod::Signal); + QCOMPARE(conflicting[1].methodType(), QQmlJSMetaMethod::Signal); + + const QQmlJSMetaMethod *explicitMethod = nullptr; + if (conflicting[0].isImplicitQmlPropertyChangeSignal()) + explicitMethod = &conflicting[1]; + else + explicitMethod = &conflicting[0]; + QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_qs, u"c"_qs })); +} + QTEST_MAIN(tst_qqmljsscope) #include "tst_qqmljsscope.moc" |