• 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
filteractiondeletetest.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 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 "filteractiondeletetest.h"
19 #include "../filteractions/filteractiondelete.h"
20 #include <qtest_kde.h>
21 #include <QLabel>
22 FilterActionDeleteTest::FilterActionDeleteTest(QObject *parent)
23  : QObject(parent)
24 {
25 
26 }
27 
28 FilterActionDeleteTest::~FilterActionDeleteTest()
29 {
30 
31 }
32 
33 void FilterActionDeleteTest::shouldHaveDefaultValue()
34 {
35  MailCommon::FilterActionDelete filter(0);
36  QWidget *w = filter.createParamWidget(0);
37  QVERIFY(w);
38 
39  QLabel *lab = dynamic_cast<QLabel *>(w);
40  QVERIFY(lab);
41  QCOMPARE(lab->objectName(), QLatin1String("label_delete"));
42 }
43 
44 void FilterActionDeleteTest::shouldReturnSieveValue()
45 {
46  MailCommon::FilterActionDelete filter(0);
47  QCOMPARE(filter.sieveCode(), QLatin1String("discard;"));
48 }
49 
50 void FilterActionDeleteTest::shouldBeNotEmpty()
51 {
52  MailCommon::FilterActionDelete filter;
53  QVERIFY(!filter.isEmpty());
54 }
55 
56 void FilterActionDeleteTest::shouldRequiresPart()
57 {
58  MailCommon::FilterActionDelete filter;
59  QCOMPARE(filter.requiredPart(), MailCommon::SearchRule::Envelope);
60 }
61 
62 void FilterActionDeleteTest::shouldDeleteItem()
63 {
64  MailCommon::FilterActionDelete filter(this);
65  KMime::Message::Ptr msgPtr = KMime::Message::Ptr(new KMime::Message());
66  Akonadi::Item item;
67  item.setPayload<KMime::Message::Ptr>(msgPtr);
68  MailCommon::ItemContext context(item, false);
69 
70  filter.argsFromString("");
71  QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn);
72  QCOMPARE(context.needsPayloadStore(), false);
73  QCOMPARE(context.deleteItem(), true);
74  QCOMPARE(context.needsFlagStore(), false);
75  QCOMPARE(context.needsFullPayload(), false);
76 }
77 
78 
79 QTEST_KDEMAIN(FilterActionDeleteTest, GUI)
QWidget
MailCommon::FilterActionDelete
Definition: filteractiondelete.h:30
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterActionDelete::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractiondelete.cpp:40
FilterActionDeleteTest::~FilterActionDeleteTest
~FilterActionDeleteTest()
Definition: filteractiondeletetest.cpp:28
QObject
QObject::objectName
objectName
MailCommon::FilterAction::isEmpty
virtual bool isEmpty() const
Determines whether this action is valid.
Definition: filteraction.cpp:55
MailCommon::FilterActionWithNone::argsFromString
virtual void argsFromString(const QString &)
Read extra arguments from given string.
Definition: filteractionwithnone.cpp:34
MailCommon::SearchRule::Envelope
Definition: searchrule.h:80
QLatin1String
MailCommon::FilterActionDelete::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractiondelete.cpp:34
FilterActionDeleteTest
Definition: filteractiondeletetest.h:23
context
const char * context
Definition: searchpatternedit.cpp:54
filteractiondeletetest.h
QtConcurrent::filter
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
QLabel
FilterActionDeleteTest::FilterActionDeleteTest
FilterActionDeleteTest(QObject *parent=0)
Definition: filteractiondeletetest.cpp:22
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