aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml11
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml14
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml1
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h4
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp37
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp39
-rw-r--r--tests/auto/qml/qquickconnection/data/rewriteError-global.qml8
-rw-r--r--tests/auto/qml/qquickconnection/data/rewriteError-unnamed.qml8
-rw-r--r--tests/auto/qml/qquickconnection/tst_qquickconnection.cpp51
9 files changed, 149 insertions, 24 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml b/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml
new file mode 100644
index 0000000000..3ab714b800
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalArguments.1.qml
@@ -0,0 +1,11 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int argumentCount: -1
+ property bool calleeCorrect: false
+ onBasicSignal: {
+ argumentCount = arguments.length
+ calleeCorrect = (arguments.callee === onBasicSignal)
+ setString('pass')
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml b/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml
new file mode 100644
index 0000000000..8ecb8df6ee
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalArguments.2.qml
@@ -0,0 +1,14 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ property int argumentCount: -1
+ property bool calleeCorrect: false
+
+ onArgumentSignal: {
+ argumentCount = arguments.length
+ calleeCorrect = (arguments.callee === onArgumentSignal)
+ setString('pass ' + arguments[0] + ' ' + arguments[1] + ' '
+ + arguments[2] + ' ' + arguments[3] + ' '
+ + arguments[4])
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
index 49293edfb3..5b73430aa3 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
@@ -2,4 +2,5 @@ import Qt.test 1.0
MyQmlObject {
onSignalWithUnknownType: variantMethod(arg);
+ onSignalWithCompletelyUnknownType: variantMethod(arg)
}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index da6baa4e6c..2fc0568fda 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -193,6 +193,9 @@ public:
struct MyType {
int value;
};
+ struct MyOtherType {
+ int value;
+ };
QVariant variant() const { return m_variant; }
QJSValue qjsvalue() const { return m_qjsvalue; }
void setQJSValue(const QJSValue &value) { m_qjsvalue = value; emit qjsvalueChanged(); }
@@ -247,6 +250,7 @@ signals:
void anotherBasicSignal();
void thirdBasicSignal();
void signalWithUnknownType(const MyQmlObject::MyType &arg);
+ void signalWithCompletelyUnknownType(const MyQmlObject::MyOtherType &arg);
void signalWithVariant(const QVariant &arg);
void signalWithQJSValue(const QJSValue &arg);
void signalWithGlobalName(int parseInt);
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 196587160b..2ea91add2f 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -79,6 +79,7 @@ private slots:
void boolPropertiesEvaluateAsBool();
void methods();
void signalAssignment();
+ void signalArguments();
void bindingLoop();
void basicExpressions();
void basicExpressions_data();
@@ -513,21 +514,42 @@ void tst_qqmlecmascript::signalAssignment()
{
QQmlComponent component(&engine, testFileUrl("signalAssignment.3.qml"));
+ QVERIFY(component.isError());
+ QString expectedErrorString = component.url().toString() + QLatin1String(":4 Signal uses unnamed parameter followed by named parameter.\n");
+ QCOMPARE(component.errorString(), expectedErrorString);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
+ QVERIFY(component.isError());
+ QString expectedErrorString = component.url().toString() + QLatin1String(":5 Signal parameter \"parseInt\" hides global variable.\n");
+ QCOMPARE(component.errorString(), expectedErrorString);
+ }
+}
+
+void tst_qqmlecmascript::signalArguments()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("signalArguments.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->unnamedArgumentSignal(19, 10.25, "Hello world!");
- QCOMPARE(object->string(), QString("pass 19 Hello world!"));
+ emit object->basicSignal();
+ QCOMPARE(object->string(), QString("pass"));
+ QCOMPARE(object->property("argumentCount").toInt(), 0);
+ QCOMPARE(object->property("calleeCorrect").toBool(), true);
delete object;
}
{
- QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
+ QQmlComponent component(&engine, testFileUrl("signalArguments.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->signalWithGlobalName(19);
- QCOMPARE(object->string(), QString("pass 5"));
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
+ QCOMPARE(object->property("argumentCount").toInt(), 5);
+ QCOMPARE(object->property("calleeCorrect").toBool(), true);
delete object;
}
}
@@ -3432,6 +3454,11 @@ void tst_qqmlecmascript::signalWithUnknownTypes()
QCOMPARE(result.value, type.value);
+ MyQmlObject::MyOtherType othertype;
+ othertype.value = 17;
+ emit object->signalWithCompletelyUnknownType(othertype);
+
+ QVERIFY(!object->variant().isValid());
delete object;
}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index b8e47c80ec..fdb6d69075 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -49,6 +49,7 @@
#include <QtWidgets/QLineEdit>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
+#include <QtCore/private/qobject_p.h>
#include "../../shared/util.h"
#include <QDebug>
@@ -146,14 +147,14 @@ void tst_qqmlproperty::qmlmetaproperty()
{
QQmlProperty prop;
+ QObject *obj = new QObject;
+
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
- QObject *obj = new QObject;
-
QCOMPARE(prop.name(), QString());
QCOMPARE(prop.read(), QVariant());
QCOMPARE(prop.write(QVariant()), false);
@@ -366,7 +367,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -414,7 +415,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -469,7 +470,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -517,7 +518,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -567,7 +568,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -616,7 +617,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -670,7 +671,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -718,7 +719,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -773,7 +774,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -821,7 +822,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -871,7 +872,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -920,7 +921,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())));
static_cast<QQmlBinding *>(binding.data())->setTarget(prop);
QVERIFY(binding != 0);
- QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
+ QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1);
QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr);
QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted());
@@ -1102,7 +1103,7 @@ void tst_qqmlproperty::read()
QQmlProperty p(&o, "onClicked");
QCOMPARE(p.read(), QVariant());
- QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
+ QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
QCOMPARE(p.read(), QVariant());
@@ -1114,7 +1115,7 @@ void tst_qqmlproperty::read()
QQmlProperty p(&o, "onPropertyWithNotifyChanged");
QCOMPARE(p.read(), QVariant());
- QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
+ QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
QCOMPARE(p.read(), QVariant());
@@ -1270,7 +1271,7 @@ void tst_qqmlproperty::write()
QQmlProperty p(&o, "onClicked");
QCOMPARE(p.write(QVariant("console.log(1921)")), false);
- QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
+ QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
QCOMPARE(p.write(QVariant("console.log(1921)")), false);
@@ -1284,7 +1285,7 @@ void tst_qqmlproperty::write()
QQmlProperty p(&o, "onPropertyWithNotifyChanged");
QCOMPARE(p.write(QVariant("console.log(1921)")), false);
- QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
+ QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), false, QString(), -1, -1)));
QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
QCOMPARE(p.write(QVariant("console.log(1921)")), false);
diff --git a/tests/auto/qml/qquickconnection/data/rewriteError-global.qml b/tests/auto/qml/qquickconnection/data/rewriteError-global.qml
new file mode 100644
index 0000000000..bd18b9df9a
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/data/rewriteError-global.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+import Test 1.0
+
+TestObject {
+ property QtObject connection: Connections {
+ onSignalWithGlobalName: { ran = true }
+ }
+}
diff --git a/tests/auto/qml/qquickconnection/data/rewriteError-unnamed.qml b/tests/auto/qml/qquickconnection/data/rewriteError-unnamed.qml
new file mode 100644
index 0000000000..a4849e994b
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/data/rewriteError-unnamed.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+import Test 1.0
+
+TestObject {
+ property QtObject connection: Connections {
+ onUnnamedArgumentSignal: { ran = true }
+ }
+}
diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
index 118d89e41e..9796872035 100644
--- a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
+++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
@@ -62,6 +62,7 @@ private slots:
void unknownSignals();
void errors_data();
void errors();
+ void rewriteErrors();
void singletonTypeTarget();
private:
@@ -224,6 +225,56 @@ void tst_qquickconnection::errors()
QCOMPARE(errors.at(0).description(), error);
}
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool ran READ ran WRITE setRan)
+
+public:
+ TestObject(QObject *parent = 0) : m_ran(false) {}
+ ~TestObject() {}
+
+ bool ran() const { return m_ran; }
+ void setRan(bool arg) { m_ran = arg; }
+
+signals:
+ void unnamedArgumentSignal(int a, qreal, QString c);
+ void signalWithGlobalName(int parseInt);
+
+private:
+ bool m_ran;
+};
+
+void tst_qquickconnection::rewriteErrors()
+{
+ qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("rewriteError-unnamed.qml"));
+ TestObject *obj = qobject_cast<TestObject*>(c.create());
+ QVERIFY(obj != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, (c.url().toString() + ":5:35: QML Connections: Signal uses unnamed parameter followed by named parameter.").toLatin1());
+ obj->unnamedArgumentSignal(1, .5, "hello");
+ QCOMPARE(obj->ran(), false);
+
+ delete obj;
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("rewriteError-global.qml"));
+ TestObject *obj = qobject_cast<TestObject*>(c.create());
+ QVERIFY(obj != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, (c.url().toString() + ":5:35: QML Connections: Signal parameter \"parseInt\" hides global variable.").toLatin1());
+ obj->signalWithGlobalName(10);
+ QCOMPARE(obj->ran(), false);
+
+ delete obj;
+ }
+}
+
class MyTestSingletonType : public QObject
{