aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml21
-rw-r--r--tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml30
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp23
3 files changed, 74 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml b/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml
new file mode 100644
index 0000000000..0424ac1534
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/SignalInlineComponentArg.qml
@@ -0,0 +1,21 @@
+import QtQuick
+
+Item {
+ component Abc: Item {
+ property string success
+ }
+
+ signal canYouFeelIt(arg1: Abc)
+ property Abc someAbc: Abc {
+ success: "Signal was called"
+ }
+ property string success: "Signal not called yet"
+
+ Component.onCompleted: {
+ canYouFeelIt(someAbc);
+ }
+
+ onCanYouFeelIt: (arg) => {
+ success = arg.success
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml b/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml
new file mode 100644
index 0000000000..e20710edd9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/signalInlineComponentArg1.qml
@@ -0,0 +1,30 @@
+import QtQuick
+
+// this file performs two tests: first, using a signal with a inline component from another file
+// and second, calling the signal from another file using an inline component from another file
+
+Item {
+ signal canYouFeelIt(arg1:SignalInlineComponentArg.Abc)
+
+ property SignalInlineComponentArg.Abc someAbc: SignalInlineComponentArg.Abc {
+ success: "Own signal was called with component from another file"
+ }
+
+ property SignalInlineComponentArg fromAnotherFile: SignalInlineComponentArg {}
+
+ // success of own signal call with parameter from another file
+ property string successFromOwnSignal: "Signal not called yet"
+ // makes it easier to test
+ property string successFromSignalFromFile: fromAnotherFile.success
+
+ Component.onCompleted: {
+ canYouFeelIt(someAbc);
+ fromAnotherFile.someAbc.success = "Signal was called from another file"
+ fromAnotherFile.canYouFeelIt(fromAnotherFile.someAbc)
+ }
+
+ onCanYouFeelIt: (arg) => {
+ successFromOwnSignal = arg.success
+ }
+}
+
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 11b6653b9f..7aacfcf044 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -397,6 +397,7 @@ private slots:
void bindingAliasToComponentUrl();
void badGroupedProperty();
void functionInGroupedProperty();
+ void signalInlineComponentArg();
private:
QQmlEngine engine;
@@ -7650,6 +7651,28 @@ void tst_qqmllanguage::functionInGroupedProperty()
.arg(url.toString()));
}
+void tst_qqmllanguage::signalInlineComponentArg()
+{
+ QQmlEngine engine;
+ {
+ QQmlComponent component(&engine, testFileUrl("SignalInlineComponentArg.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+
+ QCOMPARE(object->property("success"), u"Signal was called"_s);
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("signalInlineComponentArg1.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> object(component.create());
+
+ QCOMPARE(object->property("successFromOwnSignal"),
+ u"Own signal was called with component from another file"_s);
+ QCOMPARE(object->property("successFromSignalFromFile"),
+ u"Signal was called from another file"_s);
+ }
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"