summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp24
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml18
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml28
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h65
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp107
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml14
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml2
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml8
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h3
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp29
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.pngbin1563 -> 1578 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.pngbin1570 -> 1585 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.pngbin1553 -> 1568 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.pngbin1563 -> 1578 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.pngbin1569 -> 1584 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.pngbin1569 -> 1584 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.pngbin1566 -> 1581 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.pngbin1566 -> 1581 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml8
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml6
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml10
37 files changed, 437 insertions, 22 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 11d7c13..5441311 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
SUBDIRS += \
+ examples \
graphicswidgets \ # Cover
parserstress \ # Cover
qmetaobjectbuilder \ # Cover
@@ -62,7 +63,7 @@ SUBDIRS += \
qdeclarativeimageprovider \ # Cover
qdeclarativestyledtext \ # Cover
sql \ # Cover
- qmlvisual
+ qmlvisual # Cover
contains(QT_CONFIG, webkit) {
SUBDIRS += \
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index 678dd59..dbd1f92 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -185,10 +185,10 @@ void tst_examples::examples()
QFileInfo fi(file);
QFileInfo dir(fi.path());
- QString script = "data/"+dir.baseName()+"/"+fi.baseName();
+ QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName();
QFileInfo testdata(script+".qml");
QStringList arguments;
- arguments << "-script" << (testdata.exists() ? script : QLatin1String("data/dummytest"))
+ arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest"))
<< "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure"
<< file;
QProcess p;
diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
index 16ae7fc..9eaa400 100644
--- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
+++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp
@@ -372,6 +372,16 @@ void tst_qdeclarativeanchors::crash1()
QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml"));
QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill.";
+
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ // QT-3245 ... anchor loop detection needs improving.
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
QDeclarativeView *view = new QDeclarativeView(source);
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml
new file mode 100644
index 0000000..5b0bdcb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+AnimatedImage {
+ sourceSize: "240x180"
+ source: "stickman.gif"
+}
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml
new file mode 100644
index 0000000..f4d277a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+AnimatedImage {
+ width: 240
+ height: 180
+ source: "stickman.gif"
+}
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
index 31efc64..39ce9eb 100644
--- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
+++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp
@@ -72,6 +72,8 @@ private slots:
void frameCount();
void remote();
void remote_data();
+ void sourceSize();
+ void sourceSizeReadOnly();
void invalidSource();
};
@@ -155,10 +157,32 @@ void tst_qdeclarativeanimatedimage::remote()
TRY_WAIT(anim->isPaused());
QCOMPARE(anim->currentFrame(), 2);
}
+ QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error);
delete anim;
}
+void tst_qdeclarativeanimatedimage::sourceSize()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml"));
+ QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QCOMPARE(anim->width(),240.0);
+ QCOMPARE(anim->height(),180.0);
+ QCOMPARE(anim->sourceSize(),QSize(160,120));
+
+ delete anim;
+}
+
+void tst_qdeclarativeanimatedimage::sourceSizeReadOnly()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
+}
+
void tst_qdeclarativeanimatedimage::remote_data()
{
QTest::addColumn<QString>("fileName");
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index e8bbb86..1cbe2ac 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -274,7 +274,7 @@ void tst_qdeclarativedom::loadComposite()
void tst_qdeclarativedom::testValueSource()
{
QByteArray qml = "import Qt 4.6\n"
- "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
+ "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; to: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
QDeclarativeEngine freshEngine;
QDeclarativeDomDocument document;
@@ -297,7 +297,7 @@ void tst_qdeclarativedom::testValueSource()
QVERIFY(springValue.isLiteral());
QVERIFY(springValue.toLiteral().literal() == "1.4");
- const QDeclarativeDomValue sourceValue = valueSourceObject.property("source").value();
+ const QDeclarativeDomValue sourceValue = valueSourceObject.property("to").value();
QVERIFY(!sourceValue.isInvalid());
QVERIFY(sourceValue.isBinding());
QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
new file mode 100644
index 0000000..6c538fe
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+QtObject {
+ function calculate() {
+ return b * 13;
+ }
+
+ property int a: calculate()
+ property int b: 3
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml
new file mode 100644
index 0000000..4aca111
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+QtObject {
+ function myFunction() {
+ a = 10;
+ }
+
+ Component.onCompleted: myFunction();
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
new file mode 100644
index 0000000..1bf0b81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+QtObject {
+ property QtObject test
+ test: if (1) model
+ property ListModel model
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
new file mode 100644
index 0000000..30a77e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
@@ -0,0 +1,18 @@
+import Qt.test 1.0
+
+NumberAssignment {
+ test1: if (1) 6.7
+ test2: if (1) "6.7"
+ test3: if (1) 6
+ test4: if (1) "6"
+
+ test5: if (1) 6.7
+ test6: if (1) "6.7"
+ test7: if (1) 6
+ test8: if (1) "6"
+
+ test9: if (1) 6.7
+ test10: if (1) "6.7"
+ test11: if (1) 6
+ test12: if (1) "6"
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml
new file mode 100644
index 0000000..483179a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml
@@ -0,0 +1,28 @@
+import Qt 4.6
+
+QtObject {
+ id: root
+
+ property int a
+ property var b
+
+ Component.onCompleted: {
+ try {
+ root.a = undefined;
+ } catch(e) {
+ console.log (e.fileName + ":" + e.lineNumber + ":" + e);
+ }
+
+ try {
+ root.b = [ 10, root ]
+ } catch(e) {
+ console.log (e.fileName + ":" + e.lineNumber + ":" + e);
+ }
+
+ try {
+ root.a = "Hello";
+ } catch(e) {
+ console.log (e.fileName + ":" + e.lineNumber + ":" + e);
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index a3bcb6a..0d07055 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -80,6 +80,7 @@ void registerTypes()
qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
+ qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index faad8b7..4424419 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -600,6 +600,71 @@ private:
QVariantList m_actuals;
};
+class NumberAssignment : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(qreal test1 READ test1 WRITE setTest1);
+ qreal _test1;
+ qreal test1() const { return _test1; }
+ void setTest1(qreal v) { _test1 = v; }
+
+ Q_PROPERTY(qreal test2 READ test2 WRITE setTest2);
+ qreal _test2;
+ qreal test2() const { return _test2; }
+ void setTest2(qreal v) { _test2 = v; }
+
+ Q_PROPERTY(qreal test3 READ test3 WRITE setTest3);
+ qreal _test3;
+ qreal test3() const { return _test3; }
+ void setTest3(qreal v) { _test3 = v; }
+
+ Q_PROPERTY(qreal test4 READ test4 WRITE setTest4);
+ qreal _test4;
+ qreal test4() const { return _test4; }
+ void setTest4(qreal v) { _test4 = v; }
+
+ Q_PROPERTY(int test5 READ test5 WRITE setTest5);
+ int _test5;
+ int test5() const { return _test5; }
+ void setTest5(int v) { _test5 = v; }
+
+ Q_PROPERTY(int test6 READ test6 WRITE setTest6);
+ int _test6;
+ int test6() const { return _test6; }
+ void setTest6(int v) { _test6 = v; }
+
+ Q_PROPERTY(int test7 READ test7 WRITE setTest7);
+ int _test7;
+ int test7() const { return _test7; }
+ void setTest7(int v) { _test7 = v; }
+
+ Q_PROPERTY(int test8 READ test8 WRITE setTest8);
+ int _test8;
+ int test8() const { return _test8; }
+ void setTest8(int v) { _test8 = v; }
+
+ Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9);
+ unsigned int _test9;
+ unsigned int test9() const { return _test9; }
+ void setTest9(unsigned int v) { _test9 = v; }
+
+ Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10);
+ unsigned int _test10;
+ unsigned int test10() const { return _test10; }
+ void setTest10(unsigned int v) { _test10 = v; }
+
+ Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11);
+ unsigned int _test11;
+ unsigned int test11() const { return _test11; }
+ void setTest11(unsigned int v) { _test11 = v; }
+
+ Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12);
+ unsigned int _test12;
+ unsigned int test12() const { return _test12; }
+ void setTest12(unsigned int v) { _test12 = v; }
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 8e73afa..72f14f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -108,6 +108,8 @@ private slots:
void selfDeletingBinding();
void extendedObjectPropertyLookup();
void scriptErrors();
+ void functionErrors();
+ void propertyAssignmentErrors();
void signalTriggeredBindings();
void listProperties();
void exceptionClearsOnReeval();
@@ -130,10 +132,13 @@ private slots:
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
+ void numberAssignment();
void bug1();
void dynamicCreationCrash();
void regExpBug();
+ void nullObjectBinding();
+ void deletedEngine();
void callQtInvokables();
private:
@@ -995,6 +1000,46 @@ void tst_qdeclarativeecmascript::scriptErrors()
}
/*
+Test file/lineNumbers for inline functions.
+*/
+void tst_qdeclarativeecmascript::functionErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("functionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":5: Error: Invalid write to global property \"a\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+/*
+Test various errors that can occur when assigning a property from script
+*/
+void tst_qdeclarativeecmascript::propertyAssignmentErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("propertyAssignmentErrors.qml"));
+
+ QString url = component.url().toString();
+
+ QString warning1 = url + ":11:Error: Cannot assign [undefined] to int";
+ QString warning2 = url + ":17:Error: Cannot assign JavaScript array to QML variant property";
+ QString warning3 = url + ":23:Error: Cannot assign QString to int";
+
+ QTest::ignoreMessage(QtDebugMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtDebugMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtDebugMsg, warning3.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+/*
Test bindings still work when the reeval is triggered from within
a signal script.
*/
@@ -2074,6 +2119,68 @@ void tst_qdeclarativeecmascript::compiled()
delete object;
}
+// Test that numbers assigned in bindings as strings work consistently
+void tst_qdeclarativeecmascript::numberAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("numberAssignment.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test1") == QVariant((qreal)6.7));
+ QVERIFY(object->property("test2") == QVariant((qreal)6.7));
+ QVERIFY(object->property("test3") == QVariant((qreal)6));
+ QVERIFY(object->property("test4") == QVariant((qreal)6));
+
+ QVERIFY(object->property("test5") == QVariant((int)7));
+ QVERIFY(object->property("test6") == QVariant((int)7));
+ QVERIFY(object->property("test7") == QVariant((int)6));
+ QVERIFY(object->property("test8") == QVariant((int)6));
+
+ QVERIFY(object->property("test9") == QVariant((unsigned int)7));
+ QVERIFY(object->property("test10") == QVariant((unsigned int)7));
+ QVERIFY(object->property("test11") == QVariant((unsigned int)6));
+ QVERIFY(object->property("test12") == QVariant((unsigned int)6));
+
+ delete object;
+}
+
+// Test that assigning a null object works
+// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
+void tst_qdeclarativeecmascript::nullObjectBinding()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nullObjectBinding.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
+
+ delete object;
+}
+
+// Test that bindings don't evaluate once the engine has been destroyed
+void tst_qdeclarativeecmascript::deletedEngine()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine, TEST_FILE("deletedEngine.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 39);
+ object->setProperty("b", QVariant(9));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete engine;
+
+ QCOMPARE(object->property("a").toInt(), 117);
+ object->setProperty("b", QVariant(10));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
index a1aceb7..f4df130 100644
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -520,6 +520,24 @@ void tst_qdeclarativeinstruction::dump()
data->bytecode << i;
}
+ {
+ QDeclarativeInstruction i;
+ i.line = 51;
+ i.type = QDeclarativeInstruction::StoreVariantInteger;
+ i.storeInteger.value = 11;
+ i.storeInteger.propertyIndex = 32;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 52;
+ i.type = QDeclarativeInstruction::StoreVariantDouble;
+ i.storeDouble.value = 33.7;
+ i.storeDouble.propertyIndex = 19;
+ data->bytecode << i;
+ }
+
QStringList expect;
expect
<< "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
@@ -575,6 +593,8 @@ void tst_qdeclarativeinstruction::dump()
<< "47\t\tNA\tDEFER\t\t\t7"
<< "48\t\t48\tSTORE_IMPORTED_SCRIPT\t2"
<< "49\t\t50\tXXX UNKOWN INSTRUCTION\t1234"
+ << "50\t\t51\tSTORE_VARIANT_INTEGER\t\t32\t11"
+ << "51\t\t52\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
<< "-------------------------------------------------------------------------------";
messages = QStringList();
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
new file mode 100644
index 0000000..a1d33ef
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+QtObject {
+ property var test1: 1
+ property var test2: 1.7
+ property var test3: "Hello world!"
+ property var test4: "#FF008800"
+ property var test5: "10,10,10x10"
+ property var test6: "10,10"
+ property var test7: "10x10"
+ property var test8: "100,100,100"
+ property var test9: String("#FF008800")
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index bf10a01..bfb56ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -87,6 +87,7 @@ private slots:
void assignBasicTypes();
void assignTypeExtremes();
void assignCompositeToType();
+ void assignLiteralToVariant();
void customParserTypes();
void rootAsQmlComponent();
void inlineQmlComponents();
@@ -479,6 +480,37 @@ void tst_qdeclarativelanguage::assignCompositeToType()
QVERIFY(object != 0);
}
+// Test that literals are stored correctly in variant properties
+void tst_qdeclarativelanguage::assignLiteralToVariant()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+
+ QVERIFY(object->property("test1") == QVariant(1));
+ QVERIFY(object->property("test2") == QVariant((double)1.7));
+ QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
+ QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
+ QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
+ QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
+ QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
+ QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
+ QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
+
+ delete object;
+}
+
// Tests that custom parser types can be instantiated
void tst_qdeclarativelanguage::customParserTypes()
{
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
index 7c81fb5..ffbf7d5 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
@@ -1,7 +1,7 @@
import Qt 4.6
SpringFollow {
- source: 1.44; velocity: 0.9
+ to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
mass: 2.0; enabled: true
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
index 6fec55b..9a8f6f3 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
@@ -1,7 +1,7 @@
import Qt 4.6
SpringFollow {
- source: 1.44; velocity: 0.9
+ to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
mass: 2.0; enabled: false
diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
index 7a60e78..8a07d6b 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
+++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
@@ -72,7 +72,7 @@ void tst_qdeclarativespringfollow::defaultValues()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->to(), 0.);
QCOMPARE(obj->velocity(), 0.);
QCOMPARE(obj->spring(), 0.);
QCOMPARE(obj->damping(), 0.);
@@ -94,7 +94,7 @@ void tst_qdeclarativespringfollow::values()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->to(), 1.44);
QCOMPARE(obj->velocity(), 0.9);
QCOMPARE(obj->spring(), 1.0);
QCOMPARE(obj->damping(), 0.5);
@@ -117,7 +117,7 @@ void tst_qdeclarativespringfollow::disabled()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->to(), 1.44);
QCOMPARE(obj->velocity(), 0.9);
QCOMPARE(obj->spring(), 1.0);
QCOMPARE(obj->damping(), 0.5);
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml
new file mode 100644
index 0000000..7abe359
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyTypeObject {
+ property int s_width: sizereadonly.width
+ property int s_height: sizereadonly.height
+ property var copy: sizereadonly
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml
new file mode 100644
index 0000000..3254557
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+
+MyTypeObject {
+ sizereadonly: "13x88"
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml
new file mode 100644
index 0000000..656d718
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+
+MyTypeObject {
+ sizereadonly.width: if (true) 13
+ sizereadonly.height: if (true) 88
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
index 0ad8449..9057b4f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
@@ -63,6 +63,7 @@ class MyTypeObject : public QObject
Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
+ Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
@@ -134,6 +135,7 @@ QML_DECLARE_TYPE(MyTypeObject);
class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueSource)
public:
virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
};
@@ -142,6 +144,7 @@ QML_DECLARE_TYPE(MyConstantValueSource);
class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
{
Q_OBJECT
+ Q_INTERFACES(QDeclarativePropertyValueInterceptor)
public:
virtual void setTarget(const QDeclarativeProperty &p) { prop = p; }
virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); }
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index fb487f0..c74199f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -59,6 +59,7 @@ private slots:
void pointf();
void size();
void sizef();
+ void sizereadonly();
void rect();
void rectf();
void vector3d();
@@ -193,6 +194,34 @@ void tst_qdeclarativevaluetypes::sizef()
}
}
+void tst_qdeclarativevaluetypes::sizereadonly()
+{
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror2.qml"));
+ QEXPECT_FAIL("", "QTBUG-9685", Abort);
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+}
+
void tst_qdeclarativevaluetypes::rect()
{
{
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
index cf36d60..5b7b426 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
index 6069df8..7c27310 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
index b8bd5f3..cbfdb23 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
index cf36d60..5b7b426 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
index 831d6b4..5af705e 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
index f7079dc..af4395e 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
index a5f4451..cd12bc9 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
index e1261d0..471c86b 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
index 5a131e9..f3071e4 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
@@ -486,7 +486,7 @@ VisualTest {
}
Frame {
msec: 1840
- hash: "b6b4b2c7acddd23609caa9727911b981"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -498,7 +498,7 @@ VisualTest {
}
Frame {
msec: 1856
- hash: "b6b4b2c7acddd23609caa9727911b981"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -510,7 +510,7 @@ VisualTest {
}
Frame {
msec: 1872
- hash: "022610222cfbcf9e9a8991cdb60c7bbb"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -522,7 +522,7 @@ VisualTest {
}
Frame {
msec: 1888
- hash: "9b5201a3201a102b20592d81218b5e74"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
index 21bbc7f..fbab4b7 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
@@ -25,7 +25,7 @@ Rectangle {
origin.x: 7.5; origin.y: 73; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: (clock.hours * 30) + (clock.minutes * 0.5)
+ to: (clock.hours * 30) + (clock.minutes * 0.5)
}
}
}
@@ -39,7 +39,7 @@ Rectangle {
origin.x: 6.5; origin.y: 83; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: clock.minutes * 6
+ to: clock.minutes * 6
}
}
}
@@ -53,7 +53,7 @@ Rectangle {
origin.x: 2.5; origin.y: 80; angle: 0
SpringFollow on angle {
spring: 5; damping: 0.25; modulus: 360
- source: clock.seconds * 6
+ to: clock.seconds * 6
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
index 1659bb7..5368349 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
@@ -26,7 +26,7 @@ Rectangle {
color: "#ff0000"
x: rect.width; width: rect.width; height: 20
y: 200
- SpringFollow on y { source: rect.y; velocity: 200 }
+ SpringFollow on y { to: rect.y; velocity: 200 }
}
// Spring
@@ -34,13 +34,13 @@ Rectangle {
color: "#ff0000"
x: rect.width * 2; width: rect.width/2; height: 20
y: 200
- SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2 }
+ SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2 }
}
Rectangle {
color: "#880000"
x: rect.width * 2.5; width: rect.width/2; height: 20
y: 200
- SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
}
// Follow mouse
@@ -52,8 +52,8 @@ Rectangle {
width: 20; height: 20
radius: 10
color: "#0000ff"
- SpringFollow on x { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- SpringFollow on y { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ SpringFollow on x { id: f1; to: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ SpringFollow on y { id: f2; to: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
states: [
State {
name: "following"