diff options
Diffstat (limited to 'tests/auto')
9 files changed, 109 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index dca5205..e1b4c1c 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -493,9 +493,11 @@ void tst_qdeclarativedom::loadDynamicProperty() { QByteArray qml = "import Qt 4.7\n" "Item {\n" + " id: item\n" " property int a: 12\n" " property int b: a + 6\n" " default property QtObject c\n" + " property alias d: item.a\n" "}\n"; QDeclarativeDomDocument document; @@ -504,11 +506,12 @@ void tst_qdeclarativedom::loadDynamicProperty() QDeclarativeDomObject rootObject = document.rootObject(); QVERIFY(rootObject.isValid()); - QCOMPARE(rootObject.dynamicProperties().count(), 3); + QCOMPARE(rootObject.dynamicProperties().count(), 4); { QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(0); QVERIFY(d.isDefaultProperty() == false); + QVERIFY(d.isAlias() == false); QVERIFY(d.defaultValue().isValid()); QVERIFY(d.defaultValue().propertyName() == "a"); QVERIFY(d.defaultValue().value().isLiteral()); @@ -517,6 +520,7 @@ void tst_qdeclarativedom::loadDynamicProperty() { QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(1); QVERIFY(d.isDefaultProperty() == false); + QVERIFY(d.isAlias() == false); QVERIFY(d.defaultValue().isValid()); QVERIFY(d.defaultValue().propertyName() == "b"); QVERIFY(d.defaultValue().value().isBinding()); @@ -525,8 +529,15 @@ void tst_qdeclarativedom::loadDynamicProperty() { QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(2); QVERIFY(d.isDefaultProperty() == true); + QVERIFY(d.isAlias() == false); QVERIFY(d.defaultValue().isValid() == false); } + + { + QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(3); + QVERIFY(d.isDefaultProperty() == false); + QVERIFY(d.isAlias() == true); + } } } diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp index 03df71f..7fd6279 100644 --- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp +++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp @@ -63,6 +63,8 @@ private slots: void nonQmlObject(); void nullObject(); void nonQmlContextedObject(); + void types(); + void chaining(); private: QDeclarativeEngine engine; @@ -139,6 +141,68 @@ void tst_qdeclarativeinfo::nonQmlContextedObject() qmlInfo(&object) << "Test Message"; } +void tst_qdeclarativeinfo::types() +{ + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false"); + qmlInfo(0) << false; + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1"); + qmlInfo(0) << 1.1; + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2"); + qmlInfo(0) << 1.2f; + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15"); + qmlInfo(0) << 15; + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'"); + qmlInfo(0) << QChar('b'); + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\""); + qmlInfo(0) << QByteArray("Qt"); + + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true"); + qmlInfo(0) << QBool(true); + + //### do we actually want QUrl to show up in the output? + //### why the extra space at the end? + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") "); + qmlInfo(0) << QUrl("http://qt.nokia.com"); + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello"); + qmlInfo(0) << QLatin1String("hello"); + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World"); + QString str("Hello World"); + QStringRef ref(&str, 6, 5); + qmlInfo(0) << ref; + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick"); + qmlInfo(0) << QString ("Quick"); +} + +void tst_qdeclarativeinfo::chaining() +{ + //### should more of these be automatically inserting spaces? + QString str("Hello World"); + QStringRef ref(&str, 6, 5); + QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick "); + qmlInfo(0) << false << ' ' + << 1.1 << ' ' + << 1.2f << ' ' + << 15 << ' ' + << QLatin1String("hello") << ' ' + << QChar('b') << ' ' + << QUrl("http://qt.nokia.com") + << ref + << QByteArray("Qt") + << QBool(true) + << QString ("Quick"); +} + QTEST_MAIN(tst_qdeclarativeinfo) #include "tst_qdeclarativeinfo.moc" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt new file mode 100644 index 0000000..af95a53 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt @@ -0,0 +1 @@ +3:1:UnavailableType is unavailable for testing diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml new file mode 100644 index 0000000..7c3c7ee --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +UnavailableType { +} diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp index 20cd976..e697aeb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp @@ -54,6 +54,8 @@ void registerTypes() qmlRegisterType<MyGroupedObject>(); qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser); + + qmlRegisterTypeNotAvailable("Test",1,0,"UnavailableType", "UnavailableType is unavailable for testing"); } QVariant myCustomVariantTypeConverter(const QString &data) diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index ac55bae..2b23a49 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -508,6 +508,12 @@ public: } }; +class UnavailableType : public QObject +{ + Q_OBJECT +public: + UnavailableType() {} +}; class MyDotPropertyObject : public QObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 1825991..37e074b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -376,6 +376,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false; QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false; + QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; } diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/declarative/qdeclarativeqt/data/quit.qml new file mode 100644 index 0000000..f4c8441 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/quit.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +QtObject { + Component.onCompleted: Qt.quit() +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 895ee6c..739b10a 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -50,6 +50,7 @@ #include <QVector3D> #include <QCryptographicHash> #include <QDeclarativeItem> +#include <QSignalSpy> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -84,6 +85,7 @@ private slots: void btoa(); void atob(); void fontFamilies(); + void quit(); private: QDeclarativeEngine engine; @@ -518,6 +520,18 @@ void tst_qdeclarativeqt::fontFamilies() delete object; } +void tst_qdeclarativeqt::quit() +{ + QDeclarativeComponent component(&engine, TEST_FILE("quit.qml")); + + QSignalSpy spy(&engine, SIGNAL(quit())); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(spy.count(), 1); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeqt) #include "tst_qdeclarativeqt.moc" |