• 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
filteractionaddtoaddressbooktest.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 "filteractionaddtoaddressbooktest.h"
19 #include "../filteractions/filteractionaddtoaddressbook.h"
20 #include <qtest_kde.h>
21 #include <QWidget>
22 #include <QLabel>
23 #include <klineedit.h>
24 #include <widgets/minimumcombobox.h>
25 #include <widgets/tagwidgets.h>
26 #include <akonadi/collectioncombobox.h>
27 
28 FilterActionAddToAddressBookTest::FilterActionAddToAddressBookTest(QObject *parent)
29  : QObject(parent)
30 {
31 
32 }
33 
34 FilterActionAddToAddressBookTest::~FilterActionAddToAddressBookTest()
35 {
36 
37 }
38 
39 void FilterActionAddToAddressBookTest::shouldHaveDefaultValue()
40 {
41  MailCommon::FilterActionAddToAddressBook filter;
42  QWidget *w = filter.createParamWidget(0);
43 
44  PimCommon::MinimumComboBox *headerCombo = w->findChild<PimCommon::MinimumComboBox *>(QLatin1String("HeaderComboBox"));
45  QVERIFY(headerCombo);
46 
47  QLabel *label = w->findChild<QLabel *>(QLatin1String("label_with_category"));
48  QVERIFY(label);
49 
50  KPIM::TagWidget *categoryEdit = w->findChild<KPIM::TagWidget *>( QLatin1String("CategoryEdit") );
51  QVERIFY(categoryEdit);
52 
53  label = w->findChild<QLabel *>(QLatin1String("label_in_addressbook"));
54  QVERIFY(label);
55 
56  Akonadi::CollectionComboBox *collectionComboBox = w->findChild<Akonadi::CollectionComboBox *>(QLatin1String("AddressBookComboBox") );
57  QVERIFY(collectionComboBox);
58 }
59 
60 void FilterActionAddToAddressBookTest::shouldReportErrorWhenArgumentIsEmpty()
61 {
62  MailCommon::FilterActionAddToAddressBook filter;
63  KMime::Message::Ptr msgPtr = KMime::Message::Ptr(new KMime::Message());
64  Akonadi::Item item;
65  item.setPayload<KMime::Message::Ptr>(msgPtr);
66  MailCommon::ItemContext context(item, false);
67 
68  filter.argsFromString("");
69  QVERIFY(filter.isEmpty());
70  QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
71  QCOMPARE(context.needsPayloadStore(), false);
72  QCOMPARE(context.needsFlagStore(), false);
73  QCOMPARE(context.needsFullPayload(), false);
74 }
75 
76 void FilterActionAddToAddressBookTest::shouldReportErrorWhenCollectionIsInvalid()
77 {
78  MailCommon::FilterActionAddToAddressBook filter;
79  KMime::Message::Ptr msgPtr = KMime::Message::Ptr(new KMime::Message());
80  Akonadi::Item item;
81  item.setPayload<KMime::Message::Ptr>(msgPtr);
82  MailCommon::ItemContext context(item, false);
83 
84  filter.argsFromString("foo\t-1\tddd");
85  QVERIFY(filter.isEmpty());
86  QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
87  QCOMPARE(context.needsPayloadStore(), false);
88  QCOMPARE(context.needsFlagStore(), false);
89  QCOMPARE(context.needsFullPayload(), false);
90 }
91 
92 void FilterActionAddToAddressBookTest::shouldRequiresPart()
93 {
94  MailCommon::FilterActionAddToAddressBook filter;
95  QCOMPARE(filter.requiredPart(), MailCommon::SearchRule::Envelope);
96 }
97 
98 QTEST_KDEMAIN(FilterActionAddToAddressBookTest, GUI)
QWidget
FilterActionAddToAddressBookTest::~FilterActionAddToAddressBookTest
~FilterActionAddToAddressBookTest()
Definition: filteractionaddtoaddressbooktest.cpp:34
FilterActionAddToAddressBookTest
Definition: filteractionaddtoaddressbooktest.h:23
MailCommon::FilterAction::ErrorButGoOn
A non-critical error occurred.
Definition: filteraction.h:63
QObject
MailCommon::FilterActionAddToAddressBook::createParamWidget
QWidget * createParamWidget(QWidget *parent) const
Creates a widget for setting the filter action parameter.
Definition: filteractionaddtoaddressbook.cpp:104
MailCommon::FilterActionAddToAddressBook::requiredPart
SearchRule::RequiredPart requiredPart() const
Returns the required part from the item that is needed for the action to operate. ...
Definition: filteractionaddtoaddressbook.cpp:98
MailCommon::SearchRule::Envelope
Definition: searchrule.h:80
MailCommon::FilterActionAddToAddressBook::process
ReturnCode process(ItemContext &context, bool applyOnOutbound) const
Execute action on given message (inside the item context).
Definition: filteractionaddtoaddressbook.cpp:60
MailCommon::FilterActionAddToAddressBook
Definition: filteractionaddtoaddressbook.h:31
QLatin1String
filteractionaddtoaddressbooktest.h
MailCommon::FilterActionAddToAddressBook::argsFromString
void argsFromString(const QString &argsStr)
Read extra arguments from given string.
Definition: filteractionaddtoaddressbook.cpp:227
context
const char * context
Definition: searchpatternedit.cpp:54
FilterActionAddToAddressBookTest::FilterActionAddToAddressBookTest
FilterActionAddToAddressBookTest(QObject *parent=0)
Definition: filteractionaddtoaddressbooktest.cpp:28
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
QLabel
MailCommon::FilterActionAddToAddressBook::isEmpty
bool isEmpty() const
Determines whether this action is valid.
Definition: filteractionaddtoaddressbook.cpp:55
QObject::findChild
T findChild(const QString &name) const
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