summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarius Bugge Monsen <mmonsen@trolltech.com>2009-09-30 12:08:51 +0200
committerMarius Bugge Monsen <mmonsen@trolltech.com>2009-09-30 12:08:51 +0200
commit053a9a4a293eed32ed625e961a5ec8570f154d4a (patch)
tree0bc67302fe554450bdb405bd12a4a2239ff52b67 /tests
parent35f07e0ad9ddcf9660f36d4b30d5627170951f71 (diff)
Compile after converting from int role to QByteArray role names.
Diffstat (limited to 'tests')
-rw-r--r--tests/qlistfromtreeadaptor/tst_qlistfromtreeadaptor.cpp17
-rw-r--r--tests/qlistmodeladaptor/tst_qlistmodeladaptor.cpp33
-rw-r--r--tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp18
3 files changed, 35 insertions, 33 deletions
diff --git a/tests/qlistfromtreeadaptor/tst_qlistfromtreeadaptor.cpp b/tests/qlistfromtreeadaptor/tst_qlistfromtreeadaptor.cpp
index f2882fe..e0f131e 100644
--- a/tests/qlistfromtreeadaptor/tst_qlistfromtreeadaptor.cpp
+++ b/tests/qlistfromtreeadaptor/tst_qlistfromtreeadaptor.cpp
@@ -24,6 +24,7 @@
#include <qlistfromtreeadaptor.h>
#include <qtreedefaultmodel.h>
+#include <qdataroles_p.h>
class tst_QtListFromTreeAdaptor : public QObject
{
@@ -170,21 +171,19 @@ void tst_QtListFromTreeAdaptor::dataCheck()
QFETCH(int, signalCount);
int x;
- QSignalSpy sourceItemsChanged(source,
- SIGNAL(itemsChanged(const QtTreeModelBase::iterator_base&,int,QList<int>)));
- QSignalSpy adaptorItemsChanged(adaptor,
- SIGNAL(itemsChanged(int,int,QList<int>)));
+ QSignalSpy sourceItemsChanged(source, SIGNAL(itemsChanged(const QtTreeModelBase::iterator_base&, int, QList<QByteArray>)));
+ QSignalSpy adaptorItemsChanged(adaptor, SIGNAL(itemsChanged(int, int, QList<QByteArray>)));
for (x = 0; x < itemCount; x++) {
new QtTreeDefaultItem(QString::number(x), source->rootItem());
- QCOMPARE(source->rootItem()->children().at(x)->data(0, QList<int>() << Qt::DisplayRole),
- adaptor->data(x, QList<int>() << Qt::DisplayRole));
+ QCOMPARE(source->rootItem()->children().at(x)->data(0, QList<QByteArray>() << "DisplayRole"),
+ adaptor->data(x, QList<QByteArray>() << "DisplayRole"));
- source->rootItem()->children().at(x)->setData(QString("changed text"), 0, Qt::DisplayRole);
+ source->rootItem()->children().at(x)->setData(QString("changed text"), 0, "DisplayRole");
- QCOMPARE(source->rootItem()->children().at(x)->data(0, QList<int>() << Qt::DisplayRole),
- adaptor->data(x, QList<int>() << Qt::DisplayRole));
+ QCOMPARE(source->rootItem()->children().at(x)->data(0, QList<QByteArray>() << "DisplayRole"),
+ adaptor->data(x, QList<QByteArray>() << "DisplayRole"));
}
QCOMPARE(sourceItemsChanged.count(), signalCount);
diff --git a/tests/qlistmodeladaptor/tst_qlistmodeladaptor.cpp b/tests/qlistmodeladaptor/tst_qlistmodeladaptor.cpp
index d148d5a..e8680f2 100644
--- a/tests/qlistmodeladaptor/tst_qlistmodeladaptor.cpp
+++ b/tests/qlistmodeladaptor/tst_qlistmodeladaptor.cpp
@@ -24,6 +24,7 @@
#include <QtGui/qstandarditemmodel.h>
#include <qlistmodeladaptor.h>
+#include <qdataroles_p.h>
class tst_QtListModelAdaptor : public QObject
{
@@ -109,19 +110,19 @@ void tst_QtListModelAdaptor::count()
void tst_QtListModelAdaptor::getData_data()
{
QTest::addColumn<QStringList>("items");
- QTest::addColumn<int>("role");
+ QTest::addColumn<QByteArray>("role");
QTest::addColumn<QStringList>("data");
QTest::addColumn<int>("signalCount");
QTest::newRow("no items")
<< QStringList()
- << int(Qt::DisplayRole)
+ << "DisplayRole"
<< QStringList()
<< 0;
QTest::newRow("three items")
<< (QStringList() << "one" << "two" << "three")
- << int(Qt::DisplayRole)
+ << "DisplayRole"
<< (QStringList() << "four" << "five" << "six")
<< 3;
}
@@ -129,24 +130,24 @@ void tst_QtListModelAdaptor::getData_data()
void tst_QtListModelAdaptor::getData()
{
QFETCH(QStringList, items);
- QFETCH(int, role);
+ QFETCH(QByteArray, role);
QFETCH(QStringList, data);
QFETCH(int, signalCount);
- QSignalSpy itemsChanged(adaptor, SIGNAL(itemsChanged(int,int,const QList<int>&)));
+ QSignalSpy itemsChanged(adaptor, SIGNAL(itemsChanged(int,int,const QList<QByteArray>&)));
for (int i = 0; i < items.count(); ++i)
source->appendRow(new QStandardItem(items.at(i)));
QCOMPARE(adaptor->count(), items.count());
for (int j = 0; j < items.count(); ++j)
- QCOMPARE(adaptor->data(j, QList<int>() << role).value(role).toString(), items.at(j));
+ QCOMPARE(adaptor->data(j, QList<QByteArray>() << role).value(role).toString(), items.at(j));
for (int k = 0; k < data.count(); ++k)
- source->setData(source->index(k, 0), data.at(k), role);
+ source->setData(source->index(k, 0), data.at(k), QtDataRoles::value(role));
for (int l = 0; l < data.count(); ++l)
- QCOMPARE(adaptor->data(l, QList<int>() << role).value(role).toString(), data.at(l));
+ QCOMPARE(adaptor->data(l, QList<QByteArray>() << role).value(role).toString(), data.at(l));
QCOMPARE(itemsChanged.count(), signalCount);
}
@@ -154,19 +155,19 @@ void tst_QtListModelAdaptor::getData()
void tst_QtListModelAdaptor::setData_data()
{
QTest::addColumn<QStringList>("items");
- QTest::addColumn<int>("role");
+ QTest::addColumn<QByteArray>("role");
QTest::addColumn<QStringList>("data");
QTest::addColumn<int>("signalCount");
QTest::newRow("no items")
<< QStringList()
- << int(Qt::DisplayRole)
+ << "DisplayRole"
<< QStringList()
<< 0;
QTest::newRow("three items")
<< (QStringList() << "one" << "two" << "three")
- << int(Qt::DisplayRole)
+ << "DisplayRole"
<< (QStringList() << "four" << "five" << "six")
<< 3;
}
@@ -174,27 +175,27 @@ void tst_QtListModelAdaptor::setData_data()
void tst_QtListModelAdaptor::setData()
{
QFETCH(QStringList, items);
- QFETCH(int, role);
+ QFETCH(QByteArray, role);
QFETCH(QStringList, data);
QFETCH(int, signalCount);
- QSignalSpy itemsChanged(adaptor, SIGNAL(itemsChanged(int,int,const QList<int>&)));
+ QSignalSpy itemsChanged(adaptor, SIGNAL(itemsChanged(int,int,const QList<QByteArray>&)));
for (int i = 0; i < items.count(); ++i)
source->appendRow(new QStandardItem(items.at(i)));
QCOMPARE(adaptor->count(), items.count());
for (int j = 0; j < items.count(); ++j)
- QCOMPARE(adaptor->data(j, QList<int>() << role).value(role).toString(), items.at(j));
+ QCOMPARE(adaptor->data(j, QList<QByteArray>() << role).value(role).toString(), items.at(j));
for (int k = 0; k < data.count(); ++k) {
- QHash<int, QVariant> hash;
+ QHash<QByteArray, QVariant> hash;
hash.insert(role, data.at(k));
adaptor->setData(k, hash);
}
for (int l = 0; l < data.count(); ++l)
- QCOMPARE(source->data(source->index(l, 0), role).toString(), data.at(l));
+ QCOMPARE(source->data(source->index(l, 0), QtDataRoles::value(role)).toString(), data.at(l));
QCOMPARE(itemsChanged.count(), signalCount);
}
diff --git a/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp b/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
index a1bd857..0124e7b 100644
--- a/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
+++ b/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
@@ -24,6 +24,7 @@
#include <QtTest/QtTest>
#include <qtreemodelinterface.h>
#include <qtreedefaultmodel.h>
+#include <qdataroles_p.h>
class tst_QtTreeDefaultModel : public QObject
{
@@ -58,6 +59,7 @@ protected:
Q_DECLARE_METATYPE(QList<int>)
Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QByteArray>)
Q_DECLARE_METATYPE(QtTreeModelBase::iterator_base)
tst_QtTreeDefaultModel::tst_QtTreeDefaultModel()
@@ -566,49 +568,49 @@ void tst_QtTreeDefaultModel::setData_data()
{
QTest::addColumn<QStringList>("initialChildren");
QTest::addColumn<QList<int> >("columns");
- QTest::addColumn<QList<int> >("roles");
+ QTest::addColumn<QList<QByteArray> >("roles");
QTest::addColumn<QList<QVariant> >("data");
QTest::addColumn<int>("signalCount");
QTest::newRow("no children")
<< QStringList()
<< QList<int>()
- << QList<int>()
+ << QList<QByteArray>()
<< QList<QVariant>()
<< 0;
QTest::newRow("one child, no data")
<< (QStringList() << "one")
<< QList<int>()
- << QList<int>()
+ << QList<QByteArray>()
<< QList<QVariant>()
<< 0;
QTest::newRow("one child, one column, one text")
<< (QStringList() << "one")
<< (QList<int>() << 0)
- << (QList<int>() << int(Qt::DisplayRole))
+ << (QList<QByteArray>() << "DisplayRole")
<< (QList<QVariant>() << QVariant("text"))
<< 1;
QTest::newRow("one child, two columns, one role")
<< (QStringList() << "one")
<< (QList<int>() << 0 << 1)
- << (QList<int>() << int(Qt::DisplayRole))
+ << (QList<QByteArray>() << "DisplayRole")
<< (QList<QVariant>() << QVariant("text") << QVariant("text"))
<< 2;
QTest::newRow("one child, one column, two roles")
<< (QStringList() << "one")
<< (QList<int>() << 0)
- << (QList<int>() << int(Qt::DisplayRole) << int(Qt::EditRole))
+ << (QList<QByteArray>() << "DisplayRole" << "EditRole")
<< (QList<QVariant>() << QVariant("text") << QVariant("edit"))
<< 2;
QTest::newRow("one child, two columns, two roles")
<< (QStringList() << "one")
<< (QList<int>() << 0 << 1)
- << (QList<int>() << int(Qt::DisplayRole) << int(Qt::EditRole))
+ << (QList<QByteArray>() << "DisplayRole" << "EditRole")
<< (QList<QVariant>() // for each column and for each role
<< QVariant("text") << QVariant("edit")
<< QVariant("text") << QVariant("edit"))
@@ -619,7 +621,7 @@ void tst_QtTreeDefaultModel::setData()
{
QFETCH(QStringList, initialChildren);
QFETCH(QList<int>, columns);
- QFETCH(QList<int>, roles);
+ QFETCH(QList<QByteArray>, roles);
QFETCH(QList<QVariant>, data);
QFETCH(int, signalCount);