aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qml.pro1
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml14
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.3.qml18
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.js4
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.11.qml21
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.12.qml19
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.13.qml19
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.14.qml21
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.15.qml20
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp36
-rw-r--r--tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp52
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp26
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.2.qml12
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml5
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp20
-rw-r--r--tests/auto/quick/qquickimageprovider/qquickimageprovider.pro (renamed from tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro)4
-rw-r--r--tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp (renamed from tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp)62
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml2
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp6
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp2
-rw-r--r--tests/auto/quick/quick.pro1
23 files changed, 291 insertions, 80 deletions
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index 6892680d79..4d1644f6b3 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -32,7 +32,6 @@ PRIVATETESTS += \
qqmlecmascript \
qqmlcontext \
qqmlexpression \
- qqmlimageprovider \
qqmlinstruction \
qqmllanguage \
qqmlproperty \
diff --git a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
index 122c6a87c8..989b295cb5 100644
--- a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
@@ -37,7 +37,7 @@ Item{
root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white", "border.width":3, "innerRect.border.width": 20});
root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root});
- root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) }) // use root.width
- root.bindingThisTestObject = c.createObject(root, {'testValue': (function(){return this.width * 3}) }) // use width of Item within 'c'
+ root.bindingTestObject = c.createObject(root, {'testValue': Qt.binding(function(){return width * 3}) }) // use root.width
+ root.bindingThisTestObject = c.createObject(root, {'testValue': Qt.binding(function(){return this.width * 3}) }) // use width of Item within 'c'
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
index 09540f1f6e..0b1b45b41b 100644
--- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
@@ -2,4 +2,6 @@ import Qt.test 1.0
MyQmlObject {
property variant a: function myFunction() { return 2; }
+ property variant b: Qt.binding(function() { return 2; })
+ property var c: Qt.binding(function() { return 2; })
}
diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
index 0f78eaf1dc..3d8fd85a88 100644
--- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
@@ -24,7 +24,7 @@ MyQmlObject {
function myFunction() {
return aNumber * 10;
}
- a = myFunction;
+ a = Qt.binding(myFunction);
}
property QtObject obj: QtObject {
@@ -34,7 +34,7 @@ MyQmlObject {
}
}
onAssignWithThisChanged: {
- a = obj.myFunction;
+ a = Qt.binding(obj.myFunction);
}
onAssignToPropertyFromJsFileChanged: {
@@ -47,8 +47,8 @@ MyQmlObject {
property Text text: Text { }
onAssignToValueTypeChanged: {
- text.font.pixelSize = (function() { return aNumber * 10; })
- a = (function() { return text.font.pixelSize; })
+ text.font.pixelSize = Qt.binding(function() { return aNumber * 10; })
+ a = Qt.binding(function() { return text.font.pixelSize; })
}
@@ -57,17 +57,17 @@ MyQmlObject {
onAssignFuncWithoutReturnChanged: {
function myFunction() {
}
- a = myFunction;
+ a = Qt.binding(myFunction);
}
onAssignWrongTypeChanged: {
function myFunction() {
return 'a string';
}
- aNumber = myFunction;
+ aNumber = Qt.binding(myFunction);
}
onAssignWrongTypeToValueTypeChanged: {
- text.font.pixelSize = (function() { return 'a string'; })
+ text.font.pixelSize = Qt.binding(function() { return 'a string'; })
}
}
diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.3.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.3.qml
new file mode 100644
index 0000000000..c34a868949
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.3.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.0
+
+Item {
+ property int t1: 1
+ property int t2: 2
+
+ function randomNumber() {
+ return 4;
+ }
+
+ Component.onCompleted: {
+ // shouldn't "convert" the randomNumber function into a binding permanently
+ t1 = Qt.binding(randomNumber)
+
+ // therefore, the following assignment should fail.
+ t2 = randomNumber
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.js b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
index 14daa7629f..3ba4e193e6 100644
--- a/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
@@ -1,6 +1,6 @@
function bindProperty()
{
- a = (function(){ return aNumber * 10 })
+ a = Qt.binding(function(){ return aNumber * 10 })
}
@@ -13,5 +13,5 @@ var testObj = new TestObject()
function bindPropertyWithThis()
{
- a = testObj.bindFunction
+ a = Qt.binding(testObj.bindFunction)
}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.11.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.11.qml
new file mode 100644
index 0000000000..63be26717e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.11.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property var fnResult: testFunction(5)
+ property var f1: testFunction
+ property var f2
+
+ function testFunction(x) {
+ return x;
+ }
+
+ Component.onCompleted: {
+ f2 = testFunction;
+ if (fnResult != 5) return;
+ if (f1(6) != 6) return;
+ if (f2(7) != 7) return;
+ if (f1 != f2) return;
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.12.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.12.qml
new file mode 100644
index 0000000000..3510bd2350
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.12.qml
@@ -0,0 +1,19 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property var nullOne: null
+ property var nullTwo
+ property var undefOne: undefined
+ property var undefTwo
+
+ Component.onCompleted: {
+ nullTwo = null;
+ undefTwo = undefined;
+ if (nullOne != null) return;
+ if (nullOne != nullTwo) return;
+ if (undefOne != undefined) return;
+ if (undefOne != undefTwo) return;
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.13.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.13.qml
new file mode 100644
index 0000000000..14c7c677ae
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.13.qml
@@ -0,0 +1,19 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property var f: b + 12
+ property int a: 100
+ property int b: testFunction()
+
+ function testFunction() {
+ return a * 3;
+ }
+
+ Component.onCompleted: {
+ if (f != 312) return;
+ a = 120;
+ if (f != 372) return;
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.14.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.14.qml
new file mode 100644
index 0000000000..a1e26661bb
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.14.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property var f
+ property int a: 100
+ property int b
+
+ function testFunction() {
+ return a * 3;
+ }
+
+ Component.onCompleted: {
+ b = Qt.binding(testFunction);
+ f = Qt.binding(function() { return b + 12; });
+ if (f != 312) return;
+ a = 120;
+ if (f != 372) return;
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.15.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.15.qml
new file mode 100644
index 0000000000..5e5071fc2d
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.15.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Item {
+ property bool test: false
+ property var storedBinding: [ Qt.binding(function() { return testFunction() + 12; }) ]
+ property int a: 100
+ property int b
+
+ function testFunction() {
+ return a * 3;
+ }
+
+ Component.onCompleted: {
+ b = storedBinding[0];
+ if (b != 312) return;
+ a = 120;
+ if (b != 372) return;
+ test = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 79eaa3316f..861ff2e641 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -195,6 +195,7 @@ private slots:
void functionAssignment_fromJS();
void functionAssignment_fromJS_data();
void functionAssignmentfromJS_invalid();
+ void functionAssignment_afterBinding();
void eval();
void function();
void functionException();
@@ -3792,6 +3793,11 @@ void tst_qqmlecmascript::propertyVar_data()
QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
+ QTest::newRow("javascript function assignment") << testFileUrl("propertyVar.11.qml");
+ QTest::newRow("javascript special assignment") << testFileUrl("propertyVar.12.qml");
+ QTest::newRow("declarative binding assignment") << testFileUrl("propertyVar.13.qml");
+ QTest::newRow("imperative binding assignment") << testFileUrl("propertyVar.14.qml");
+ QTest::newRow("stored binding assignment") << testFileUrl("propertyVar.15.qml");
}
void tst_qqmlecmascript::propertyVar()
@@ -4639,7 +4645,7 @@ void tst_qqmlecmascript::sequenceConversionWrite()
QVERIFY(seq != 0);
// we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
- QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void");
+ QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to an unregistered type");
QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
QMetaObject::invokeMethod(object, "performTest");
@@ -5054,9 +5060,13 @@ void tst_qqmlecmascript::functionAssignment_fromBinding()
QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
QString url = component.url().toString();
- QString warning = url + ":4:25: Unable to assign a function to a property.";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
+ QString w1 = url + ":4:25: Unable to assign a function to a property of any type other than var.";
+ QString w2 = url + ":5:25: Invalid use of Qt.binding() in a binding declaration.";
+ QString w3 = url + ":6:21: Invalid use of Qt.binding() in a binding declaration.";
+ QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, w2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, w3.toLatin1().constData());
+
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(o != 0);
@@ -5123,6 +5133,24 @@ void tst_qqmlecmascript::functionAssignmentfromJS_invalid()
delete o;
}
+void tst_qqmlecmascript::functionAssignment_afterBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.3.qml"));
+
+ QString url = component.url().toString();
+ //QString w1 = url + ":16: Error: Cannot assign JavaScript function to int"; // for now, function assignment = binding assignment
+ QString w1 = QLatin1String("WARNING: function assignment is DEPRECATED and will be removed! Wrap RHS in Qt.binding(): ") + url + QLatin1String(":16");
+ QTest::ignoreMessage(QtWarningMsg, w1.toLatin1().constData());
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("t1"), QVariant::fromValue<int>(4)); // should have bound
+ //QCOMPARE(o->property("t2"), QVariant::fromValue<int>(2)); // should not have changed
+ QCOMPARE(o->property("t2"), QVariant::fromValue<int>(4)); // for now, function assignment = binding assignment
+
+ delete o;
+}
+
void tst_qqmlecmascript::eval()
{
QQmlComponent component(&engine, testFileUrl("eval.qml"));
diff --git a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
index f2c50ddbef..ca48f027e0 100644
--- a/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
+++ b/tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp
@@ -211,10 +211,10 @@ void tst_QQmlMetaObject::property()
QCOMPARE(prop.name(), "test");
QCOMPARE(QByteArray(prop.typeName()), cppTypeName);
- QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue);
- QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue);
if (prop.userType() < QMetaType::User)
QCOMPARE(prop.type(), QVariant::Type(cppType));
+ else
+ QCOMPARE(prop.type(), QVariant::UserType);
QCOMPARE(prop.userType(), cppType);
QVERIFY(!prop.isConstant());
@@ -244,12 +244,15 @@ void tst_QQmlMetaObject::property()
QVERIFY(prop.notifySignalIndex() != -1);
QMetaMethod signal = prop.notifySignal();
QCOMPARE(signal.methodType(), QMetaMethod::Signal);
- QCOMPARE(signal.signature(), "testChanged()");
+ QCOMPARE(signal.name(), QByteArray("testChanged"));
+ QCOMPARE(signal.methodSignature(), QByteArray("testChanged()"));
QCOMPARE(signal.access(), QMetaMethod::Protected);
+ QCOMPARE(signal.parameterCount(), 0);
QCOMPARE(signal.parameterTypes(), QList<QByteArray>());
QCOMPARE(signal.parameterNames(), QList<QByteArray>());
QCOMPARE(signal.tag(), "");
QCOMPARE(signal.typeName(), "");
+ QCOMPARE(signal.returnType(), int(QMetaType::Void));
QSignalSpy changedSpy(object, SIGNAL(testChanged()));
QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater()));
@@ -277,62 +280,73 @@ void tst_QQmlMetaObject::method_data()
QTest::addColumn<QString>("testFile");
QTest::addColumn<QString>("signature");
QTest::addColumn<QMetaMethod::MethodType>("methodType");
+ QTest::addColumn<int>("returnType");
QTest::addColumn<QString>("returnTypeName");
+ QTest::addColumn<QList<int> >("parameterTypes");
QTest::addColumn<QList<QByteArray> >("parameterTypeNames");
QTest::addColumn<QList<QByteArray> >("parameterNames");
QTest::newRow("testFunction()") << "method.1.qml"
<< "testFunction()"
<< QMetaMethod::Slot
- << "QVariant"
+ << int(QMetaType::QVariant) << "QVariant"
+ << QList<int>()
<< QList<QByteArray>()
<< QList<QByteArray>();
QTest::newRow("testFunction(foo)") << "method.2.qml"
<< "testFunction(QVariant)"
<< QMetaMethod::Slot
- << "QVariant"
+ << int(QMetaType::QVariant) << "QVariant"
+ << (QList<int>() << QMetaType::QVariant)
<< (QList<QByteArray>() << "QVariant")
<< (QList<QByteArray>() << "foo");
QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml"
<< "testFunction(QVariant,QVariant,QVariant)"
<< QMetaMethod::Slot
- << "QVariant"
+ << int(QMetaType::QVariant) << "QVariant"
+ << (QList<int>() << QMetaType::QVariant << QMetaType::QVariant << QMetaType::QVariant)
<< (QList<QByteArray>() << "QVariant" << "QVariant" << "QVariant")
<< (QList<QByteArray>() << "foo" << "bar" << "baz");
QTest::newRow("testSignal") << "signal.1.qml"
<< "testSignal()"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << QList<int>()
<< QList<QByteArray>()
<< QList<QByteArray>();
QTest::newRow("testSignal(string foo)") << "signal.2.qml"
<< "testSignal(QString)"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << (QList<int>() << QMetaType::QString)
<< (QList<QByteArray>() << "QString")
<< (QList<QByteArray>() << "foo");
QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml"
<< "testSignal(int,bool,double)"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << (QList<int>() << QMetaType::Int << QMetaType::Bool << QMetaType::Double)
<< (QList<QByteArray>() << "int" << "bool" << "double")
<< (QList<QByteArray>() << "foo" << "bar" << "baz");
QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml"
<< "testSignal(QVariant,QVariant)"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << (QList<int>() << QMetaType::QVariant << QMetaType::QVariant)
<< (QList<QByteArray>() << "QVariant" << "QVariant")
<< (QList<QByteArray>() << "foo" << "bar");
QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml"
<< "testSignal(QColor,QDateTime,QUrl)"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << (QList<int>() << QMetaType::QColor << QMetaType::QDateTime << QMetaType::QUrl)
<< (QList<QByteArray>() << "QColor" << "QDateTime" << "QUrl")
<< (QList<QByteArray>() << "foo" << "bar" << "baz");
QTest::newRow("testSignal(double foo)") << "signal.6.qml"
<< "testSignal(double)"
<< QMetaMethod::Signal
- << ""
+ << int(QMetaType::Void) << ""
+ << (QList<int>() << QMetaType::Double)
<< (QList<QByteArray>() << "double")
<< (QList<QByteArray>() << "foo");
}
@@ -342,10 +356,13 @@ void tst_QQmlMetaObject::method()
QFETCH(QString, testFile);
QFETCH(QString, signature);
QFETCH(QMetaMethod::MethodType, methodType);
+ QFETCH(int, returnType);
QFETCH(QString, returnTypeName);
+ QFETCH(QList<int>, parameterTypes);
QFETCH(QList<QByteArray>, parameterTypeNames);
QFETCH(QList<QByteArray>, parameterNames);
+ QCOMPARE(parameterTypes.size(), parameterTypeNames.size());
QCOMPARE(parameterTypeNames.size(), parameterNames.size());
QQmlEngine engine;
@@ -361,12 +378,21 @@ void tst_QQmlMetaObject::method()
QMetaMethod method = mo->method(mo->methodOffset());
QCOMPARE(method.methodType(), methodType);
- QCOMPARE(QString::fromUtf8(method.signature()), signature);
+ QCOMPARE(QString::fromUtf8(method.methodSignature().constData()), signature);
QCOMPARE(method.access(), QMetaMethod::Protected);
+
+ QString computedName = signature.left(signature.indexOf('('));
+ QCOMPARE(QString::fromUtf8(method.name()), computedName);
+
+ QCOMPARE(method.parameterCount(), parameterTypes.size());
+ for (int i = 0; i < parameterTypes.size(); ++i)
+ QCOMPARE(method.parameterType(i), parameterTypes.at(i));
QCOMPARE(method.parameterTypes(), parameterTypeNames);
QCOMPARE(method.parameterNames(), parameterNames);
QCOMPARE(method.tag(), "");
+
QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName);
+ QCOMPARE(method.returnType(), returnType);
delete object;
}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 5ef8937dc1..aa22450bd3 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -161,7 +161,7 @@ void tst_qqmlproperty::qmlmetaproperty()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Invalid);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -264,7 +264,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Invalid);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -311,7 +311,7 @@ void tst_qqmlproperty::qmlmetaproperty_object()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Property);
QCOMPARE(prop.isProperty(), true);
QCOMPARE(prop.isWritable(), false);
@@ -365,7 +365,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Invalid);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -412,7 +412,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Property);
QCOMPARE(prop.isProperty(), true);
QCOMPARE(prop.isWritable(), false);
@@ -461,7 +461,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(QString(prop.method().methodSignature()), QString("clicked()"));
QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -509,7 +509,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(QString(prop.method().methodSignature()), QString("oddlyNamedNotifySignal()"));
QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -562,7 +562,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Invalid);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -609,7 +609,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Property);
QCOMPARE(prop.isProperty(), true);
QCOMPARE(prop.isWritable(), false);
@@ -663,7 +663,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Invalid);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -710,7 +710,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
+ QVERIFY(!prop.method().isValid());
QCOMPARE(prop.type(), QQmlProperty::Property);
QCOMPARE(prop.isProperty(), true);
QCOMPARE(prop.isWritable(), false);
@@ -759,7 +759,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(QString(prop.method().methodSignature()), QString("clicked()"));
QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
@@ -807,7 +807,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context()
QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(QString(prop.method().methodSignature()), QString("oddlyNamedNotifySignal()"));
QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
QCOMPARE(prop.isProperty(), false);
QCOMPARE(prop.isWritable(), false);
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.2.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.2.qml
new file mode 100644
index 0000000000..0da717ba5c
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.2.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.0
+import Test 1.0
+
+MyTypeObject {
+ property int value: 10
+ rect.y: Qt.binding(function() { return value; }); // error.
+
+ Component.onCompleted: {
+ rect.x = 5;
+ rect.x = (function() { return value; }); // error.
+ }
+}
diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
index a65218669b..9b10803649 100644
--- a/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
@@ -1,7 +1,12 @@
+import QtQuick 2.0
import Test 1.0
MyTypeObject {
property int value: 10
rect.x: value
+
+ Component.onCompleted: {
+ rect.y = Qt.binding(function() { return value + 5; });
+ }
}
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 0aa223e733..54791fc340 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -871,17 +871,37 @@ void tst_qqmlvaluetypes::color()
// Test bindings can write to value types
void tst_qqmlvaluetypes::bindingAssignment()
{
+ // binding declaration
+ {
QQmlComponent component(&engine, testFileUrl("bindingAssignment.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->rect().x(), 10);
+ QCOMPARE(object->rect().y(), 15);
object->setProperty("value", QVariant(92));
QCOMPARE(object->rect().x(), 92);
+ QCOMPARE(object->rect().y(), 97);
delete object;
+ }
+
+ // function assignment should fail without crashing
+ {
+ QString warning1 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":6:13: Invalid use of Qt.binding() in a binding declaration.");
+ QString warning2 = testFileUrl("bindingAssignment.2.qml").toString() + QLatin1String(":10: Error: Cannot assign JavaScript function to value-type property");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QQmlComponent component(&engine, testFileUrl("bindingAssignment.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->rect().x(), 5);
+ object->setProperty("value", QVariant(92));
+ QCOMPARE(object->rect().x(), 5);
+ delete object;
+ }
}
// Test bindings can read from value types
diff --git a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro b/tests/auto/quick/qquickimageprovider/qquickimageprovider.pro
index 9feeee15fd..269f06a046 100644
--- a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro
+++ b/tests/auto/quick/qquickimageprovider/qquickimageprovider.pro
@@ -1,8 +1,8 @@
CONFIG += testcase
-TARGET = tst_qqmlimageprovider
+TARGET = tst_qquickimageprovider
macx:CONFIG -= app_bundle
-SOURCES += tst_qqmlimageprovider.cpp
+SOURCES += tst_qquickimageprovider.cpp
CONFIG += parallel_test
diff --git a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
index bc53544566..7f9a0efb33 100644
--- a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp
+++ b/tests/auto/quick/qquickimageprovider/tst_qquickimageprovider.cpp
@@ -41,18 +41,18 @@
#include <qtest.h>
#include <QtTest/QtTest>
#include <QtQml/qqmlengine.h>
-#include <QtQml/qqmlimageprovider.h>
+#include <QtQuick/qquickimageprovider.h>
#include <private/qquickimage_p.h>
#include <QImageReader>
#include <QWaitCondition>
-Q_DECLARE_METATYPE(QQmlImageProvider*);
+Q_DECLARE_METATYPE(QQuickImageProvider*);
-class tst_qqmlimageprovider : public QObject
+class tst_qquickimageprovider : public QObject
{
Q_OBJECT
public:
- tst_qqmlimageprovider()
+ tst_qquickimageprovider()
{
}
@@ -74,15 +74,15 @@ private slots:
private:
QString newImageFileName() const;
void fillRequestTestsData(const QString &id);
- void runTest(bool async, QQmlImageProvider *provider);
+ void runTest(bool async, QQuickImageProvider *provider);
};
-class TestQImageProvider : public QQmlImageProvider
+class TestQImageProvider : public QQuickImageProvider
{
public:
TestQImageProvider(bool *deleteWatch = 0)
- : QQmlImageProvider(Image), deleteWatch(deleteWatch)
+ : QQuickImageProvider(Image), deleteWatch(deleteWatch)
{
}
@@ -115,11 +115,11 @@ public:
Q_DECLARE_METATYPE(TestQImageProvider*);
-class TestQPixmapProvider : public QQmlImageProvider
+class TestQPixmapProvider : public QQuickImageProvider
{
public:
TestQPixmapProvider(bool *deleteWatch = 0)
- : QQmlImageProvider(Pixmap), deleteWatch(deleteWatch)
+ : QQuickImageProvider(Pixmap), deleteWatch(deleteWatch)
{
}
@@ -152,7 +152,7 @@ public:
Q_DECLARE_METATYPE(TestQPixmapProvider*);
-QString tst_qqmlimageprovider::newImageFileName() const
+QString tst_qquickimageprovider::newImageFileName() const
{
// need to generate new filenames each time or else images are loaded
// from cache and we won't get loading status changes when testing
@@ -161,7 +161,7 @@ QString tst_qqmlimageprovider::newImageFileName() const
return QString("image://test/image-%1.png").arg(count++);
}
-void tst_qqmlimageprovider::fillRequestTestsData(const QString &id)
+void tst_qquickimageprovider::fillRequestTestsData(const QString &id)
{
QTest::addColumn<QString>("source");
QTest::addColumn<QString>("imageId");
@@ -207,7 +207,7 @@ void tst_qqmlimageprovider::fillRequestTestsData(const QString &id)
<< "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
}
-void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider)
+void tst_qquickimageprovider::runTest(bool async, QQuickImageProvider *provider)
{
QFETCH(QString, source);
QFETCH(QString, imageId);
@@ -260,46 +260,46 @@ void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider)
delete obj;
}
-void tst_qqmlimageprovider::requestImage_sync_data()
+void tst_qquickimageprovider::requestImage_sync_data()
{
fillRequestTestsData("qimage|sync");
}
-void tst_qqmlimageprovider::requestImage_sync()
+void tst_qquickimageprovider::requestImage_sync()
{
bool deleteWatch = false;
runTest(false, new TestQImageProvider(&deleteWatch));
QVERIFY(deleteWatch);
}
-void tst_qqmlimageprovider::requestImage_async_data()
+void tst_qquickimageprovider::requestImage_async_data()
{
fillRequestTestsData("qimage|async");
}
-void tst_qqmlimageprovider::requestImage_async()
+void tst_qquickimageprovider::requestImage_async()
{
bool deleteWatch = false;
runTest(true, new TestQImageProvider(&deleteWatch));
QVERIFY(deleteWatch);
}
-void tst_qqmlimageprovider::requestPixmap_sync_data()
+void tst_qquickimageprovider::requestPixmap_sync_data()
{
fillRequestTestsData("qpixmap");
}
-void tst_qqmlimageprovider::requestPixmap_sync()
+void tst_qquickimageprovider::requestPixmap_sync()
{
bool deleteWatch = false;
runTest(false, new TestQPixmapProvider(&deleteWatch));
QVERIFY(deleteWatch);
}
-void tst_qqmlimageprovider::requestPixmap_async()
+void tst_qquickimageprovider::requestPixmap_async()
{
QQmlEngine engine;
- QQmlImageProvider *provider = new TestQPixmapProvider();
+ QQuickImageProvider *provider = new TestQPixmapProvider();
engine.addImageProvider("test", provider);
QVERIFY(engine.imageProvider("test") != 0);
@@ -314,17 +314,17 @@ void tst_qqmlimageprovider::requestPixmap_async()
delete obj;
}
-void tst_qqmlimageprovider::removeProvider_data()
+void tst_qquickimageprovider::removeProvider_data()
{
- QTest::addColumn<QQmlImageProvider*>("provider");
+ QTest::addColumn<QQuickImageProvider*>("provider");
- QTest::newRow("qimage") << static_cast<QQmlImageProvider*>(new TestQImageProvider);
- QTest::newRow("qpixmap") << static_cast<QQmlImageProvider*>(new TestQPixmapProvider);
+ QTest::newRow("qimage") << static_cast<QQuickImageProvider*>(new TestQImageProvider);
+ QTest::newRow("qpixmap") << static_cast<QQuickImageProvider*>(new TestQPixmapProvider);
}
-void tst_qqmlimageprovider::removeProvider()
+void tst_qquickimageprovider::removeProvider()
{
- QFETCH(QQmlImageProvider*, provider);
+ QFETCH(QQuickImageProvider*, provider);
QQmlEngine engine;
@@ -353,10 +353,10 @@ void tst_qqmlimageprovider::removeProvider()
delete obj;
}
-class TestThreadProvider : public QQmlImageProvider
+class TestThreadProvider : public QQuickImageProvider
{
public:
- TestThreadProvider() : QQmlImageProvider(Image), ok(false) {}
+ TestThreadProvider() : QQuickImageProvider(Image), ok(false) {}
~TestThreadProvider() {}
@@ -384,7 +384,7 @@ class TestThreadProvider : public QQmlImageProvider
};
-void tst_qqmlimageprovider::threadTest()
+void tst_qquickimageprovider::threadTest()
{
QQmlEngine engine;
@@ -419,6 +419,6 @@ void tst_qqmlimageprovider::threadTest()
}
-QTEST_MAIN(tst_qqmlimageprovider)
+QTEST_MAIN(tst_qquickimageprovider)
-#include "tst_qqmlimageprovider.moc"
+#include "tst_qquickimageprovider.moc"
diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
index e0df50a74a..2ee60b0b50 100644
--- a/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
@@ -16,6 +16,6 @@ Item {
}
Component.onCompleted: {
- loader.setSource("InitialPropertyValuesComponent.qml", {"canary": (function() { return root.bindable })});
+ loader.setSource("InitialPropertyValuesComponent.qml", {"canary": Qt.binding(function() { return root.bindable })});
}
}
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
index 855322e376..8d2eb66e08 100644
--- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -42,7 +42,7 @@
#include <QtTest/QtTest>
#include <QtQuick/private/qquickpixmapcache_p.h>
#include <QtQml/qqmlengine.h>
-#include <QtQml/qqmlimageprovider.h>
+#include <QtQuick/qquickimageprovider.h>
#include <QNetworkReply>
#include "../../shared/util.h"
#include "testhttpserver.h"
@@ -335,11 +335,11 @@ void tst_qquickpixmapcache::cancelcrash()
}
}
-class MyPixmapProvider : public QQmlImageProvider
+class MyPixmapProvider : public QQuickImageProvider
{
public:
MyPixmapProvider()
- : QQmlImageProvider(Pixmap) {}
+ : QQuickImageProvider(Pixmap) {}
virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
Q_UNUSED(d)
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index fc8194f6ca..7fd8fc4498 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -245,7 +245,7 @@ void tst_qquickstates::basicChanges()
QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
QVERIFY(prop.hasNotifySignal());
- QString notifySignal = QByteArray(prop.notifySignal().signature());
+ QString notifySignal = prop.notifySignal().methodSignature();
QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
QCOMPARE(rect->color(), QColor(Qt::red));
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index c8014be820..654b1c86f0 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -15,6 +15,7 @@ PRIVATETESTS += \
qquickapplication \
qquickbehaviors \
qquickfontloader \
+ qquickimageprovider \
qquickpath \
qquicksmoothedanimation \
qquickspringanimation \