summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarius Bugge Monsen <mmonsen@trolltech.com>2009-05-07 15:08:03 +0200
committerMarius Bugge Monsen <mmonsen@trolltech.com>2009-05-07 15:08:03 +0200
commit4703e978285c50e9b7e61900cefa7c0d4b15959d (patch)
treeba69f6634d2c51dd609294ec57eecb8c0f7fe87d /tests
parent9a52edab19788830c1766624088674e1994adcde (diff)
Expand the QtTreeDefaultItem::setData() test with more data and columns.
Diffstat (limited to 'tests')
-rw-r--r--tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp b/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
index 32f8a9a..6ec9aef 100644
--- a/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
+++ b/tests/qtreedefaultmodel/tst_qtreedefaultmodel.cpp
@@ -592,12 +592,28 @@ void tst_QtTreeDefaultModel::setData_data()
<< (QList<QVariant>() << QVariant("text"))
<< 1;
- QTest::newRow("one child, two columns, two texts")
+ QTest::newRow("one child, two columns, one role")
<< (QStringList() << "one")
<< (QList<int>() << 0 << 1)
- << (QList<int>() << int(Qt::DisplayRole) << int(Qt::DisplayRole))
+ << (QList<int>() << int(Qt::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<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<QVariant>() // for each column and for each role
+ << QVariant("text") << QVariant("edit")
+ << QVariant("text") << QVariant("edit"))
+ << 2;
}
void tst_QtTreeDefaultModel::setData()
@@ -624,8 +640,11 @@ void tst_QtTreeDefaultModel::setData()
item->setColumnCount(columns.count());
QCOMPARE(item->columnCount(), columns.count());
for (int k = 0; k < columns.count(); ++k) {
- item->setData(data.at(k), columns.at(k), roles.at(k));
- QCOMPARE(item->data(columns.at(k), roles.at(k)), data.at(k));
+ for (int l = 0; l < roles.count(); ++l) {
+ int m = k * roles.count() + l;
+ item->setData(data.at(m), columns.at(k), roles.at(l));
+ QCOMPARE(item->data(columns.at(k), roles.at(l)), data.at(m));
+ }
}
}