19 #include "../itemcontext.h"
20 #include <qtest_kde.h>
21 #include <Akonadi/Item>
33 void ItemContextTest::shouldHaveDefaultValue()
35 Akonadi::Item item(42);
37 QCOMPARE(itemContext.item(), item);
38 QVERIFY(!itemContext.moveTargetCollection().isValid());
39 QVERIFY(!itemContext.needsPayloadStore());
40 QVERIFY(!itemContext.needsFlagStore());
41 QVERIFY(itemContext.needsFullPayload());
42 QVERIFY(!itemContext.deleteItem());
45 QCOMPARE(itemContext2.item(), item);
46 QVERIFY(!itemContext2.moveTargetCollection().isValid());
47 QVERIFY(!itemContext2.needsPayloadStore());
48 QVERIFY(!itemContext2.needsFlagStore());
49 QVERIFY(!itemContext2.needsFullPayload());
50 QVERIFY(!itemContext2.deleteItem());
53 void ItemContextTest::shouldAssignContext_data()
55 QTest::addColumn<bool>(
"needspayloadstore" );
56 QTest::addColumn<bool>(
"needsflagstore" );
57 QTest::addColumn<bool>(
"needsfullpayload" );
58 QTest::addColumn<bool>(
"deleteitem" );
59 QTest::newRow(
"no boolean" ) <<
false <<
false <<
false <<
false;
60 QTest::newRow(
"needspayloadstore" ) <<
true <<
false <<
false <<
false;
61 QTest::newRow(
"needsflagstore" ) <<
false <<
true <<
false <<
false;
62 QTest::newRow(
"needsfullpayload" ) <<
false <<
false <<
true <<
false;
63 QTest::newRow(
"deleteitem" ) <<
false <<
false <<
false <<
true;
69 QTest::newRow(
"F T F F" ) <<
false <<
true <<
false <<
false;
70 QTest::newRow(
"F F T F" ) <<
false <<
false <<
true <<
false;
73 QTest::newRow(
"F F F T" ) <<
false <<
false <<
false <<
true;
77 QTest::newRow(
"F F F T" ) <<
false <<
false <<
false <<
true;
82 void ItemContextTest::shouldAssignContext()
84 QFETCH(
bool, needspayloadstore );
85 QFETCH(
bool, needsflagstore );
86 QFETCH(
bool, needsfullpayload );
87 QFETCH(
bool, deleteitem );
89 Akonadi::Item item(42);
92 if (needspayloadstore) {
93 itemContext.setNeedsPayloadStore();
96 itemContext.setNeedsFlagStore();
99 itemContext.setDeleteItem();
101 QCOMPARE(itemContext.item(), item);
102 QCOMPARE(itemContext.needsFlagStore(), needsflagstore);
103 QCOMPARE(itemContext.needsFullPayload(), needsfullpayload);
104 QCOMPARE(itemContext.needsPayloadStore(), needspayloadstore);
105 QCOMPARE(itemContext.deleteItem(), deleteitem);
108 void ItemContextTest::shouldAssignCollection()
110 Akonadi::Item item(42);
111 Akonadi::Collection col(12);
113 itemContext.setMoveTargetCollection(col);
114 QCOMPARE(itemContext.item(), item);
115 QCOMPARE(itemContext.moveTargetCollection(), col);
ItemContextTest(QObject *parent=0)
QTestData & newRow(const char *dataTag)
A helper class for the filtering process.