summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-03-04 05:58:26 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-03-05 01:53:28 (GMT)
commit34052400e537c188af883c4152df760bc531060d (patch)
tree679292b0a5fcdcee0d0f54448defcc439fb3f2a6 /tests/auto
parent2a2ad1e632352849c1ae54a8116f2eb699268515 (diff)
downloadQt-34052400e537c188af883c4152df760bc531060d.zip
Qt-34052400e537c188af883c4152df760bc531060d.tar.gz
Qt-34052400e537c188af883c4152df760bc531060d.tar.bz2
Add missing NOTIFYs to timer, xmllistmodel, xmlrole
Reviewed-by: akennedy
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp70
3 files changed, 117 insertions, 0 deletions
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/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"