• 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
filteractionwithurltest.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 "filteractionwithurltest.h"
19 #include "../filteractions/filteractionwithurl.h"
20 #include <KUrlRequester>
21 #include <KLineEdit>
22 #include <qtest_kde.h>
23 
24 class TestFilterActionWithUrl : public MailCommon::FilterActionWithUrl
25 {
26 public:
27  TestFilterActionWithUrl()
28  : MailCommon::FilterActionWithUrl(QLatin1String("test"), QLatin1String("label"))
29  {
30 
31  }
32  FilterAction::ReturnCode process(MailCommon::ItemContext &context , bool) const
33  {
34  return GoOn;
35  }
36 
37  MailCommon::SearchRule::RequiredPart requiredPart() const
38  {
39  return MailCommon::SearchRule::CompleteMessage;
40  }
41 };
42 
43 FilterActionWithUrlTest::FilterActionWithUrlTest(QObject *parent)
44  : QObject(parent)
45 {
46 
47 }
48 
49 FilterActionWithUrlTest::~FilterActionWithUrlTest()
50 {
51 
52 }
53 
54 void FilterActionWithUrlTest::shouldHaveDefaultValue()
55 {
56  TestFilterActionWithUrl filter;
57  QWidget *w = filter.createParamWidget(0);
58  KUrlRequester *requester = w->findChild<KUrlRequester *>(QLatin1String("requester"));
59  QVERIFY(requester);
60  QToolButton *toolButton = w->findChild<QToolButton *>(QLatin1String("helpbutton"));
61  QVERIFY(toolButton);
62 }
63 
64 void FilterActionWithUrlTest::shouldClearWidget()
65 {
66  TestFilterActionWithUrl filter;
67  QWidget *w = filter.createParamWidget(0);
68  KUrlRequester *requester = w->findChild<KUrlRequester *>(QLatin1String("requester"));
69  requester->setUrl(KUrl("/foo/bla"));
70  QVERIFY(!requester->url().isEmpty());
71  filter.clearParamWidget(w);
72  QVERIFY(requester->url().isEmpty());
73 }
74 
75 void FilterActionWithUrlTest::shouldAddValue()
76 {
77  TestFilterActionWithUrl filter;
78  QWidget *w = filter.createParamWidget(0);
79  KUrlRequester *requester = w->findChild<KUrlRequester *>(QLatin1String("requester"));
80  filter.argsFromString(QLatin1String("/foo"));
81  filter.setParamWidgetValue(w);
82  QCOMPARE(requester->lineEdit()->text(), QLatin1String("/foo"));
83 }
84 
85 void FilterActionWithUrlTest::shouldApplyValue()
86 {
87  TestFilterActionWithUrl filter;
88  QWidget *w = filter.createParamWidget(0);
89  filter.argsFromString(QLatin1String("foo"));
90  filter.setParamWidgetValue(w);
91  filter.applyParamWidgetValue(w);
92  QCOMPARE(filter.argsAsString(), QLatin1String("foo"));
93 }
94 
95 void FilterActionWithUrlTest::shouldTestUrl_data()
96 {
97  QTest::addColumn<QString>("urlstr");
98  QTest::addColumn<QString>("output");
99  QTest::newRow("fullpath") << QString(QLatin1String("/usr/bin/ls")) << QString(QLatin1String("/usr/bin/ls"));
100  QTest::newRow("local") << QString(QLatin1String("ls")) << QString(QLatin1String("ls"));
101  QTest::newRow("localwithargument") << QString(QLatin1String("ls -l")) << QString(QLatin1String("ls -l"));
102  QTest::newRow("fullpathwithargument") << QString(QLatin1String("/usr/bin/ls -l")) << QString(QLatin1String("/usr/bin/ls -l"));
103  QTest::newRow("url") << QString(QLatin1String("file:///usr/bin/ls -l")) << QString(QLatin1String("/usr/bin/ls -l"));
104  QTest::newRow("url2") << QString(QLatin1String("/usr/bin/ls -l")) << QString(QLatin1String("/usr/bin/ls -l"));
105 }
106 
107 void FilterActionWithUrlTest::shouldTestUrl()
108 {
109  QFETCH(QString, urlstr);
110  QFETCH(QString, output);
111  TestFilterActionWithUrl filter;
112  QWidget *w = filter.createParamWidget(0);
113  filter.argsFromString(urlstr);
114  filter.setParamWidgetValue(w);
115  filter.applyParamWidgetValue(w);
116  QCOMPARE(filter.argsAsString(), output);
117 }
118 
119 QTEST_KDEMAIN(FilterActionWithUrlTest, GUI)
filteractionwithurltest.h
QWidget
MailCommon::FilterAction::GoOn
Go on with applying filter actions.
Definition: filteraction.h:62
MailCommon::FilterAction::requiredPart
virtual SearchRule::RequiredPart requiredPart() const =0
Returns the required part from the item that is needed for the action to operate. ...
FilterActionWithUrlTest::~FilterActionWithUrlTest
~FilterActionWithUrlTest()
Definition: filteractionwithurltest.cpp:49
MailCommon::SearchRule::CompleteMessage
Definition: searchrule.h:82
MailCommon::FilterActionWithUrl
Definition: filteractionwithurl.h:56
QObject
MailCommon::SearchRule::RequiredPart
RequiredPart
Definition: searchrule.h:79
QString
FilterActionWithUrlTest::FilterActionWithUrlTest
FilterActionWithUrlTest(QObject *parent=0)
Definition: filteractionwithurltest.cpp:43
MailCommon::FilterActionWithUrl::FilterActionWithUrl
FilterActionWithUrl(const QString &name, const QString &label, QObject *parent=0)
Creates a new filter action.
Definition: filteractionwithurl.cpp:43
QToolButton
FilterActionWithUrlTest
Definition: filteractionwithurltest.h:23
QTest::newRow
QTestData & newRow(const char *dataTag)
QLatin1String
MailCommon::FilterAction::process
virtual ReturnCode process(ItemContext &context, bool applyOnOutbound) const =0
Execute action on given message (inside the item context).
context
const char * context
Definition: searchpatternedit.cpp:54
MailCommon::ItemContext
A helper class for the filtering process.
Definition: itemcontext.h:39
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