From e1c895912a89824af6b8a826b6c28865ac13b392 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 14:07:33 +1000 Subject: Various declarative autotest additions. --- .../qdeclarativeconnection/data/error-object.qml | 7 +++++ .../qdeclarativeconnection/data/error-property.qml | 5 ++++ .../data/error-property2.qml | 5 ++++ .../qdeclarativeconnection/data/error-syntax.qml | 9 +++++++ .../tst_qdeclarativeconnection.cpp | 31 ++++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-object.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml (limited to 'tests/auto/declarative/qdeclarativeconnection') diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml new file mode 100644 index 0000000000..a8127a4dfe --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + Connections { + onClicked: Item {} + } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml new file mode 100644 index 0000000000..2791f569c5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +Item { + Connections { fakeProperty: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml new file mode 100644 index 0000000000..0205c0a350 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +Item { + Connections { onfakeProperty: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml new file mode 100644 index 0000000000..867e4e2a13 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml @@ -0,0 +1,9 @@ +import Qt 4.7 + +Item { + Connections { + onClicked { + onPressed: {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index d38437272d..a623e96ce6 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -66,6 +66,8 @@ private slots: void targetChanged(); void unknownSignals_data(); void unknownSignals(); + void errors_data(); + void errors(); private: QDeclarativeEngine engine; @@ -195,9 +197,38 @@ void tst_qdeclarativeconnection::unknownSignals() QDeclarativeConnections *connections = item->findChild("connections"); QVERIFY(connections); + if (file == "connection-unknownsignals-ignored.qml") + QVERIFY(connections->ignoreUnknownSignals()); + delete item; } +void tst_qdeclarativeconnection::errors_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\""; + QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\""; + QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed"; + QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error"; +} + +void tst_qdeclarativeconnection::errors() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QVERIFY(c.isError() == true); + QList errors = c.errors(); + QVERIFY(errors.count() == 1); + QCOMPARE(errors.at(0).description(), error); +} + QTEST_MAIN(tst_qdeclarativeconnection) #include "tst_qdeclarativeconnection.moc" -- cgit v1.2.1