diff options
Diffstat (limited to 'tests/auto')
11 files changed, 156 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt new file mode 100644 index 0000000..d4e0cc0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt @@ -0,0 +1 @@ +3:1:Element is not creatable. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml new file mode 100644 index 0000000..a723269 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +Font { +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 3ce15cb..da0bf1a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -326,6 +326,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false; QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; + QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; } diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp index b120d5d..1dfec50 100644 --- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include <QtTest/QSignalSpy> #include <qtest.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> @@ -161,6 +162,18 @@ void tst_qdeclarativetimer::repeat() QVERIFY(helper.count == oldCount); QVERIFY(timer->isRunning() == false); + QSignalSpy spy(timer, SIGNAL(repeatChanged())); + + timer->setRepeating(false); + QVERIFY(!timer->isRepeating()); + QCOMPARE(spy.count(),1); + + timer->setRepeating(false); + QCOMPARE(spy.count(),1); + + timer->setRepeating(true); + QCOMPARE(spy.count(),2); + delete timer; } @@ -184,6 +197,18 @@ void tst_qdeclarativetimer::triggeredOnStart() QCOMPARE(helper.count, 2); QVERIFY(timer->isRunning() == false); + QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); + + timer->setTriggeredOnStart(false); + QVERIFY(!timer->triggeredOnStart()); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(false); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(true); + QCOMPARE(spy.count(),2); + delete timer; } @@ -250,6 +275,18 @@ void tst_qdeclarativetimer::changeDuration() QCOMPARE(helper.count, 3); QVERIFY(timer->isRunning()); + QSignalSpy spy(timer, SIGNAL(intervalChanged())); + + timer->setInterval(200); + QCOMPARE(timer->interval(), 200); + QCOMPARE(spy.count(),1); + + timer->setInterval(200); + QCOMPARE(spy.count(),1); + + timer->setInterval(300); + QCOMPARE(spy.count(),2); + delete timer; } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml index 0eadd50..cb01a80 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml @@ -1,6 +1,6 @@ import Test 1.0 MyTypeObject { - font.capitalization: "MixedCase" + font.capitalization: "AllUppercase" } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml index 81f1c92..93f1ed5 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml @@ -1,6 +1,6 @@ import Test 1.0 MyTypeObject { - font.capitalization: if (1) "MixedCase" + font.capitalization: if (1) "AllUppercase" } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml new file mode 100644 index 0000000..3be5099 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + font.capitalization: Font.AllUppercase +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml new file mode 100644 index 0000000..6b494e4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import Qt 4.6 as MyQt + +MyTypeObject { + font.capitalization: MyQt.Font.AllUppercase +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 8732215..51f9a07 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -597,7 +597,7 @@ void tst_qdeclarativevaluetypes::enums() QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::MixedCase); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); delete object; } @@ -605,7 +605,23 @@ void tst_qdeclarativevaluetypes::enums() QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::MixedCase); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); delete object; } } diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml new file mode 100644 index 0000000..737ec81 --- /dev/null +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { objectName: "role"; name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 68029bc..6199234 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -74,6 +74,7 @@ private slots: void useKeys_data(); void noKeysValueChanges(); void keysChanged(); + void propertyChanges(); private: QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const @@ -440,6 +441,8 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges() model->setXml(xml); QTRY_COMPARE(model->count(), 2); + model->setXml(""); + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); @@ -476,6 +479,8 @@ void tst_qdeclarativexmllistmodel::keysChanged() model->setXml(xml); QTRY_COMPARE(model->count(), 2); + model->setXml(""); + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); QSignalSpy spyCount(model, SIGNAL(countChanged())); @@ -496,6 +501,71 @@ void tst_qdeclarativexmllistmodel::keysChanged() QCOMPARE(spyCount.count(), 0); } +void tst_qdeclarativexmllistmodel::propertyChanges() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QDeclarativeXmlListModelRole *role = model->findChild<QDeclarativeXmlListModelRole*>("role"); + QVERIFY(role); + + QSignalSpy nameSpy(role, SIGNAL(nameChanged())); + QSignalSpy querySpy(role, SIGNAL(queryChanged())); + QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged())); + + role->setName("size"); + role->setQuery("size/string()"); + role->setIsKey(true); + + QCOMPARE(role->name(), QString("size")); + QCOMPARE(role->query(), QString("size/string()")); + QVERIFY(role->isKey()); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + role->setName("size"); + role->setQuery("size/string()"); + role->setIsKey(true); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + QSignalSpy sourceSpy(model, SIGNAL(sourceChanged())); + QSignalSpy xmlSpy(model, SIGNAL(xmlChanged())); + QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged())); + QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged())); + + model->setSource(QUrl("")); + model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"); + model->setQuery("/Pets"); + model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(model->source(), QUrl("")); + QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>")); + QCOMPARE(model->query(), QString("/Pets")); + QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); + + model->setSource(QUrl("")); + model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"); + model->setQuery("/Pets"); + model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); +} + QTEST_MAIN(tst_qdeclarativexmllistmodel) #include "tst_qdeclarativexmllistmodel.moc" |