aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-02-11 11:21:03 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-02-11 15:45:45 +0100
commit2f4c131805f4009f42abe991e0f92f096bbc55fd (patch)
tree36068f58c7e3bea9c7a3a26fac9f649e624cc6d5 /tests
parent2e98ccde7b89bdb45c87c154d27566215533ac76 (diff)
Fix QQmlProperty and Connections for properties starting with '_'
We do a weird renaming for the change handler of properties starting with '_', now we do it at least in a consistent way. Fixes: QTBUG-82017 Change-Id: I1535a5ee462f3a344c972461f1fb954f039aa854 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlconnections/data/underscore.qml14
-rw-r--r--tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp15
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp20
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlconnections/data/underscore.qml b/tests/auto/qml/qqmlconnections/data/underscore.qml
new file mode 100644
index 0000000000..0f73dc8f17
--- /dev/null
+++ b/tests/auto/qml/qqmlconnections/data/underscore.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.12
+
+Item {
+ id: item
+ property bool success: false
+ property bool sanityCheck: false
+ property int __underscore_property: 0
+ on__Underscore_propertyChanged: item.sanityCheck = true
+
+ Connections {
+ target: item
+ on__Underscore_propertyChanged: item.success = true
+ }
+}
diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
index 07af519a3d..f144002875 100644
--- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
+++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp
@@ -77,6 +77,8 @@ private slots:
void noAcceleratedGlobalLookup_data() { prefixes(); }
void noAcceleratedGlobalLookup();
+ void bindToPropertyWithUnderscoreChangeHandler();
+
private:
QQmlEngine engine;
void prefixes();
@@ -474,6 +476,19 @@ void tst_qqmlconnections::noAcceleratedGlobalLookup()
QCOMPARE(val.toInt(), int(Proxy::EnumValue));
}
+void tst_qqmlconnections::bindToPropertyWithUnderscoreChangeHandler()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("underscore.qml"));
+ QScopedPointer<QObject> root {component.create()};
+ QVERIFY(root);
+ QQmlProperty underscoreProperty(root.get(), "__underscore_property");
+ QVERIFY(underscoreProperty.isValid());
+ underscoreProperty.write(42);
+ QVERIFY(root->property("sanityCheck").toBool());
+ QVERIFY(root->property("success").toBool());
+}
+
QTEST_MAIN(tst_qqmlconnections)
#include "tst_qqmlconnections.moc"
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index a15c00ad62..864a47e998 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -158,6 +158,8 @@ private slots:
void copy();
void nestedQQmlPropertyMap();
+
+ void underscorePropertyChangeHandler();
private:
QQmlEngine engine;
};
@@ -2230,6 +2232,24 @@ void tst_qqmlproperty::nestedQQmlPropertyMap()
QCOMPARE(success.read().toString(), QLatin1String("success"));
}
+void tst_qqmlproperty::underscorePropertyChangeHandler()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(R"(
+ import QtQuick 2.12
+
+ Item {
+ property int __withUnderScore
+ }
+ )", QUrl::fromLocalFile("."));
+ QScopedPointer<QObject> root { component.create() };
+ QVERIFY(root);
+ QQmlProperty changeHandler(root.get(), "on__WithUnderScoreChanged");
+ QVERIFY(changeHandler.isValid());
+ QVERIFY(changeHandler.isSignalProperty());
+}
+
QTEST_MAIN(tst_qqmlproperty)
#include "tst_qqmlproperty.moc"