aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativefolderlistmodel
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-21 09:06:26 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-21 15:35:22 +0100
commit8249c72213bc7d212c05aa086b3145a5742706a3 (patch)
tree4a34b97b0d57a05707c65b7328d5ab1bf4254920 /tests/auto/declarative/qdeclarativefolderlistmodel
parent3c211558f6b571555558bd1fc59774e36a6da710 (diff)
QDeclarative tests: Introduce base class for data tests.
In tests/auto/shared/util.* replace macros/find functions by a base class QDeclarativeDataTest with accessors for the data directory helper functions to create URLs from it. The class relies on QFINDTESTDATA, which is the standard way of locating test data. Using the class should reduce the number of calls to QFileInfo.exists(), etc significantly. In addition, provide utility functions for messages. Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Change-Id: Id2beacb157922ee9412f9e45cf9695cec1f8379a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativefolderlistmodel')
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro4
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp22
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
index b59d39f629..5f337161b9 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
+++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
@@ -2,7 +2,9 @@ CONFIG += testcase
TARGET = tst_qdeclarativefolderlistmodel
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativefolderlistmodel.cpp
+SOURCES += tst_qdeclarativefolderlistmodel.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
index f85a6f14b6..41f15f91b3 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
@@ -53,7 +53,7 @@ const int FileNameRole = Qt::UserRole+1;
const int FilePathRole = Qt::UserRole+2;
enum SortField { Unsorted, Name, Time, Size, Type };
-class tst_qdeclarativefolderlistmodel : public QObject
+class tst_qdeclarativefolderlistmodel : public QDeclarativeDataTest
{
Q_OBJECT
public:
@@ -98,16 +98,16 @@ void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent&
void tst_qdeclarativefolderlistmodel::basicProperties()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("basic.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("")));
+ flm->setProperty("folder", dataDirectoryUrl());
QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
- QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(TESTDATA("")));
- QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(TESTDATA("..")).canonicalPath()));
+ QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
+ QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
QCOMPARE(flm->property("sortField").toInt(), int(Name));
QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
QCOMPARE(flm->property("sortReversed").toBool(), false);
@@ -124,7 +124,7 @@ void tst_qdeclarativefolderlistmodel::basicProperties()
void tst_qdeclarativefolderlistmodel::resetFiltering()
{
// see QTBUG-17837
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("resetFiltering.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("resetFiltering.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
@@ -133,19 +133,19 @@ void tst_qdeclarativefolderlistmodel::resetFiltering()
connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
this, SLOT(removed(const QModelIndex&,int,int)));
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering")));
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
int count = flm->rowCount();
QCOMPARE(removeStart, 0);
QCOMPARE(removeEnd, count-1);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering/innerdir")));
+ flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
count = flm->rowCount();
QCOMPARE(removeStart, 0);
QCOMPARE(removeEnd, count-1);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering")));
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
count = flm->rowCount();
QCOMPARE(removeStart, 0);
@@ -154,13 +154,13 @@ void tst_qdeclarativefolderlistmodel::resetFiltering()
void tst_qdeclarativefolderlistmodel::refresh()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("basic.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("")));
+ flm->setProperty("folder", dataDirectoryUrl());
QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
int count = flm->rowCount();