• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.14
  • kdepim
  • mailcommon
  • filter
  • autotests
itemcontexttest.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014-2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "itemcontexttest.h"
19 #include "../itemcontext.h"
20 #include <qtest_kde.h>
21 #include <Akonadi/Item>
22 ItemContextTest::ItemContextTest(QObject *parent)
23  : QObject(parent)
24 {
25 
26 }
27 
28 ItemContextTest::~ItemContextTest()
29 {
30 
31 }
32 
33 void ItemContextTest::shouldHaveDefaultValue()
34 {
35  Akonadi::Item item(42);
36  MailCommon::ItemContext itemContext(item, true);
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());
43 
44  MailCommon::ItemContext itemContext2(item, false);
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());
51 }
52 
53 void ItemContextTest::shouldAssignContext_data()
54 {
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;
64  QTest::newRow( "all" ) << true << true << true << true;
65 
66  QTest::newRow( "T T F F" ) << true << true << false << false;
67  QTest::newRow( "T T T F" ) << true << true << true << false;
68 
69  QTest::newRow( "F T F F" ) << false << true << false << false;
70  QTest::newRow( "F F T F" ) << false << false << true << false;
71  QTest::newRow( "F T T F" ) << false << true << true << false;
72  QTest::newRow( "F T T T" ) << false << true << true << true;
73  QTest::newRow( "F F F T" ) << false << false << false << true;
74 
75 
76  QTest::newRow( "F T F T" ) << false << true << false << true;
77  QTest::newRow( "F F F T" ) << false << false << false << true;
78 
79 
80 }
81 
82 void ItemContextTest::shouldAssignContext()
83 {
84  QFETCH( bool, needspayloadstore );
85  QFETCH( bool, needsflagstore );
86  QFETCH( bool, needsfullpayload );
87  QFETCH( bool, deleteitem );
88 
89  Akonadi::Item item(42);
90  MailCommon::ItemContext itemContext(item, needsfullpayload);
91 
92  if (needspayloadstore) {
93  itemContext.setNeedsPayloadStore();
94  }
95  if (needsflagstore) {
96  itemContext.setNeedsFlagStore();
97  }
98  if (deleteitem) {
99  itemContext.setDeleteItem();
100  }
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);
106 }
107 
108 void ItemContextTest::shouldAssignCollection()
109 {
110  Akonadi::Item item(42);
111  Akonadi::Collection col(12);
112  MailCommon::ItemContext itemContext(item, true);
113  itemContext.setMoveTargetCollection(col);
114  QCOMPARE(itemContext.item(), item);
115  QCOMPARE(itemContext.moveTargetCollection(), col);
116 }
117 
118 QTEST_KDEMAIN(ItemContextTest, NoGUI)
ItemContextTest::ItemContextTest
ItemContextTest(QObject *parent=0)
Definition: itemcontexttest.cpp:22
ItemContextTest
Definition: itemcontexttest.h:23
QObject
QTest::newRow
QTestData & newRow(const char *dataTag)
itemcontexttest.h
ItemContextTest::~ItemContextTest
~ItemContextTest()
Definition: itemcontexttest.cpp:28
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal