summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:11:53 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-23 01:11:53 (GMT)
commitb316de95032216a90a8262cce3708f781f8ccbd9 (patch)
treeeacd9c21652fd2bc2d870ace167a769b81434e54 /tests/auto/declarative
parent7de5a4981144648a158d893542bfe5ad82d6830d (diff)
downloadQt-b316de95032216a90a8262cce3708f781f8ccbd9.zip
Qt-b316de95032216a90a8262cce3708f781f8ccbd9.tar.gz
Qt-b316de95032216a90a8262cce3708f781f8ccbd9.tar.bz2
Test error messages.
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
index 95cf68e..f2ffb7b 100644
--- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
+++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
@@ -41,6 +41,7 @@
#include <qtest.h>
#include <QtDeclarative/private/qmllistmodel_p.h>
#include <QtDeclarative/private/qmlexpression_p.h>
+#include <QmlComponent>
#include <QDebug>
class tst_QmlListModel : public QObject
@@ -52,6 +53,8 @@ public:
private slots:
void dynamic_data();
void dynamic();
+ void error_data();
+ void error();
};
void tst_QmlListModel::dynamic_data()
@@ -155,6 +158,56 @@ void tst_QmlListModel::dynamic()
QCOMPARE(actual,result);
}
+void tst_QmlListModel::error_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("id not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { id: fred } }"
+ << "ListElement: cannot use reserved \"id\" property";
+
+ QTest::newRow("id allowed in ListModel")
+ << "import Qt 4.6\nListModel { id:model }"
+ << "";
+
+ QTest::newRow("random properties not allowed in ListModel")
+ << "import Qt 4.6\nListModel { foo:123 }"
+ << "ListModel: undefined property 'foo'";
+
+ QTest::newRow("random properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo:123 } }"
+ << "";
+
+ QTest::newRow("random object list properties allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
+ << "";
+
+ QTest::newRow("default properties not allowed in ListElement")
+ << "import Qt 4.6\nListModel { ListElement { Item { } } }"
+ << "QTBUG-6082 ListElement should not allow child objects";
+}
+
+void tst_QmlListModel::error()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, error);
+
+ QmlEngine engine;
+ QmlComponent component(&engine, qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ if (error.isEmpty()) {
+ QVERIFY(!component.isError());
+ } else {
+ if (error.startsWith(QLatin1String("QTBUG-")))
+ QEXPECT_FAIL("",error.toLatin1(),Abort);
+ QVERIFY(component.isError());
+ QList<QmlError> errors = component.errors();
+ QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.at(0).description(),error);
+ }
+}
+
QTEST_MAIN(tst_QmlListModel)
#include "tst_qmllistmodel.moc"