summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml10
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/data/createObject.qml16
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp28
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp10
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro2
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp43
-rw-r--r--tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp6
11 files changed, 122 insertions, 12 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 4bb3518..484fbef 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -24,6 +24,7 @@ SUBDIRS += \
qdeclarativeecmascript \
qdeclarativeengine \
qdeclarativeerror \
+ qdeclarativefolderlistmodel \
qdeclarativefontloader \
qdeclarativeflickable \
qdeclarativeflipable \
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml
new file mode 100644
index 0000000..c052366
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml
@@ -0,0 +1,10 @@
+import Qt 4.7
+
+Rectangle {
+ width: 200
+ height: 200
+ Text {
+ Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } }
+ text: "Hello World"
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index 1dc4b53..45e5304 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -72,6 +72,7 @@ private slots:
void disabled();
void dontStart();
void startup();
+ void groupedPropertyCrash();
};
void tst_qdeclarativebehaviors::simpleBehavior()
@@ -351,6 +352,15 @@ void tst_qdeclarativebehaviors::startup()
}
}
+//QTBUG-10799
+void tst_qdeclarativebehaviors::groupedPropertyCrash()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect); //don't crash
+}
+
QTEST_MAIN(tst_qdeclarativebehaviors)
#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml
new file mode 100644
index 0000000..4ee1e75
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+Item{
+ id: root
+ property QtObject qobject : null
+ property QtObject declarativeitem : null
+ property QtObject graphicswidget: null
+ Component{id: a; QtObject{} }
+ Component{id: b; Item{} }
+ Component{id: c; QGraphicsWidget{} }
+ Component.onCompleted: {
+ root.qobject = a.createObject(root);
+ root.declarativeitem = b.createObject(root);
+ root.graphicswidget = c.createObject(root);
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
index c9e304c..faa1c21 100644
--- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
@@ -39,7 +39,9 @@
**
****************************************************************************/
#include <qtest.h>
+#include <QDebug>
+#include <QtGui/qgraphicsitem.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
@@ -51,6 +53,7 @@ public:
private slots:
void loadEmptyUrl();
+ void qmlCreateObject();
private:
QDeclarativeEngine engine;
@@ -70,6 +73,31 @@ void tst_qdeclarativecomponent::loadEmptyUrl()
QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
}
+void tst_qdeclarativecomponent::qmlCreateObject()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/createObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *testObject1 = object->property("qobject").value<QObject*>();
+ QVERIFY(testObject1);
+ QVERIFY(testObject1->parent() == object);
+
+ QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
+ QVERIFY(testObject2);
+ QVERIFY(testObject2->parent() == object);
+ QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem");
+
+ //Note that QGraphicsObjects are not exposed to QML for instantiation, and so can't be used in a component directly
+ //Also this is actually the extended type QDeclarativeGraphicsWidget, but it still doesn't inherit QDeclarativeItem
+ QGraphicsObject *testObject3 = qobject_cast<QGraphicsObject*>(object->property("graphicswidget").value<QObject*>());
+ QVERIFY(testObject3);
+ QVERIFY(testObject3->parent() == object);
+ QVERIFY(testObject3->parentItem() == qobject_cast<QGraphicsObject*>(object));
+ QCOMPARE(testObject3->metaObject()->className(), "QDeclarativeGraphicsWidget");
+}
+
QTEST_MAIN(tst_qdeclarativecomponent)
#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 9a8ad64..e75abac 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -564,7 +564,7 @@ void tst_qdeclarativeecmascript::deferredPropertiesErrors()
QVERIFY(object->objectProperty() == 0);
QVERIFY(object->objectProperty2() == 0);
- QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject* objectProperty";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
qmlExecuteDeferred(object);
@@ -642,8 +642,8 @@ void tst_qdeclarativeecmascript::enums()
{
QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
- QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
- QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
+ QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int a";
+ QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int b";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
@@ -754,7 +754,7 @@ void tst_qdeclarativeecmascript::nonExistantAttachedObject()
{
QDeclarativeComponent component(&engine, TEST_FILE("nonExistantAttachedObject.qml"));
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString stringProperty";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QObject *object = component.create();
@@ -1001,7 +1001,7 @@ void tst_qdeclarativeecmascript::scriptErrors()
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning6 = url + ":7: Unable to assign [undefined] to int";
+ QString warning6 = url + ":7: Unable to assign [undefined] to int x";
QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
index b0db771..0aebea1 100644
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -266,7 +266,7 @@ void tst_qdeclarativeengine::outputWarningsToStandardError()
delete o;
QCOMPARE(warnings.count(), 1);
- QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
+ QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int a"));
warnings.clear();
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
index 8a8bfe7..3cf9613 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
@@ -93,7 +93,6 @@ void tst_qdeclarativefolderlistmodel::basicProperties()
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
-
flm->setProperty("folder",QUrl::fromLocalFile(SRCDIR "/data"));
QTRY_COMPARE(flm->property("count").toInt(),2); // wait for refresh
QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(SRCDIR "/data"));
@@ -105,7 +104,10 @@ void tst_qdeclarativefolderlistmodel::basicProperties()
QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
- QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
+ QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
+
+ flm->setProperty("folder",QUrl::fromLocalFile(""));
+ QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
}
QTEST_MAIN(tst_qdeclarativefolderlistmodel)
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
index 1bf1c58..7c006f1 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
@@ -1,5 +1,5 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,declarative): QT += declarative script gui
contains(QT_CONFIG,xmlpatterns) {
QT += xmlpatterns
DEFINES += QTEST_XMLPATTERNS
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 7769979..35790e4 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -81,6 +81,7 @@ private slots:
void source();
void source_data();
void data();
+ void get();
void reload();
void useKeys();
void useKeys_data();
@@ -223,6 +224,8 @@ void tst_qdeclarativexmllistmodel::roleErrors()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml"));
QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
+
//### make sure we receive all expected warning messages.
QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
QVERIFY(model != 0);
@@ -388,6 +391,46 @@ void tst_qdeclarativexmllistmodel::data()
delete model;
}
+void tst_qdeclarativexmllistmodel::get()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ QVERIFY(model->get(0).isUndefined());
+
+ QTRY_COMPARE(model->count(), 9);
+ QVERIFY(model->get(-1).isUndefined());
+
+ QScriptValue sv = model->get(0);
+ QCOMPARE(sv.property("name").toString(), QLatin1String("Polly"));
+ QCOMPARE(sv.property("type").toString(), QLatin1String("Parrot"));
+ QCOMPARE(sv.property("age").toNumber(), qsreal(12));
+ QCOMPARE(sv.property("size").toString(), QLatin1String("Small"));
+
+ sv = model->get(1);
+ QCOMPARE(sv.property("name").toString(), QLatin1String("Penny"));
+ QCOMPARE(sv.property("type").toString(), QLatin1String("Turtle"));
+ QCOMPARE(sv.property("age").toNumber(), qsreal(4));
+ QCOMPARE(sv.property("size").toString(), QLatin1String("Small"));
+
+ sv = model->get(7);
+ QCOMPARE(sv.property("name").toString(), QLatin1String("Rover"));
+ QCOMPARE(sv.property("type").toString(), QLatin1String("Dog"));
+ QCOMPARE(sv.property("age").toNumber(), qsreal(0));
+ QCOMPARE(sv.property("size").toString(), QLatin1String("Large"));
+
+ sv = model->get(8);
+ QCOMPARE(sv.property("name").toString(), QLatin1String("Tiny"));
+ QCOMPARE(sv.property("type").toString(), QLatin1String("Elephant"));
+ QCOMPARE(sv.property("age").toNumber(), qsreal(15));
+ QCOMPARE(sv.property("size").toString(), QLatin1String("Large"));
+
+ sv = model->get(9);
+ QVERIFY(sv.isUndefined());
+
+ delete model;
+}
+
void tst_qdeclarativexmllistmodel::reload()
{
// If no keys are used, the model should be rebuilt from scratch when
diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
index f105692..71dc451 100644
--- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
+++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp
@@ -81,11 +81,11 @@ QString tst_qmlvisual::viewer()
QString qmlruntime;
#if defined(Q_WS_MAC)
- qmlruntime = QDir(binaries).absoluteFilePath("qml.app/Contents/MacOS/qml");
+ qmlruntime = QDir(binaries).absoluteFilePath("QMLViewer.app/Contents/MacOS/QMLViewer");
#elif defined(Q_WS_WIN) || defined(Q_WS_S60)
- qmlruntime = QDir(binaries).absoluteFilePath("qml.exe");
+ qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer.exe");
#else
- qmlruntime = QDir(binaries).absoluteFilePath("qml");
+ qmlruntime = QDir(binaries).absoluteFilePath("qmlviewer");
#endif
return qmlruntime;