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

libkdepim

  • sources
  • kde-4.14
  • kdepim
  • libkdepim
  • addressline
  • blacklistbaloocompletion
  • autotests
blacklistbalooemailcompletionwidgettest.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "blacklistbalooemailcompletionwidgettest.h"
22 #include "../blacklistbalooemailcompletionwidget.h"
23 #include "../blacklistbalooemaillist.h"
24 #include <QLabel>
25 #include <klineedit.h>
26 #include <kpushbutton.h>
27 #include <qtest_kde.h>
28 
29 BlackListBalooEmailCompletionWidgetTest::BlackListBalooEmailCompletionWidgetTest(QObject *parent)
30  : QObject(parent)
31 {
32 
33 }
34 
35 BlackListBalooEmailCompletionWidgetTest::~BlackListBalooEmailCompletionWidgetTest()
36 {
37 
38 }
39 
40 void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
41 {
42  KPIM::BlackListBalooEmailCompletionWidget widget;
43  widget.show();
44  widget.show();
45  QTest::qWaitForWindowShown(&widget);
46  QLabel *searchLabel = qFindChild<QLabel *>(&widget, QLatin1String("search_label"));
47  QVERIFY(searchLabel);
48 
49  KLineEdit *searchLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("search_lineedit"));
50  QVERIFY(searchLineEdit);
51  QVERIFY(searchLineEdit->isClearButtonShown());
52  QVERIFY(searchLineEdit->trapReturnKey());
53  QVERIFY(searchLineEdit->text().isEmpty());
54 
55 
56  QLabel *moreResult = qFindChild<QLabel *>(&widget, QLatin1String("moreresultlabel"));
57  QVERIFY(moreResult);
58  QVERIFY(!moreResult->isVisible());
59 
60  KPushButton *seachButton = qFindChild<KPushButton *>(&widget, QLatin1String("search_button"));
61  QVERIFY(seachButton);
62  QVERIFY(!seachButton->isEnabled());
63 
64  KPIM::BlackListBalooEmailList *emailList = qFindChild<KPIM::BlackListBalooEmailList *>(&widget, QLatin1String("email_list"));
65  QVERIFY(emailList);
66 
67  KPushButton *selectButton = qFindChild<KPushButton *>(&widget, QLatin1String("select_email"));
68  QVERIFY(selectButton);
69  QVERIFY(!selectButton->isEnabled());
70  KPushButton *unselectButton = qFindChild<KPushButton *>(&widget, QLatin1String("unselect_email"));
71  QVERIFY(unselectButton);
72  QVERIFY(!unselectButton->isEnabled());
73 
74 
75  QLabel *excludeDomainLabel = qFindChild<QLabel *>(&widget, QLatin1String("domain_label"));
76  QVERIFY(excludeDomainLabel);
77 
78  KLineEdit *excludeDomainLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("domain_lineedit"));
79  QVERIFY(excludeDomainLineEdit);
80  QVERIFY(excludeDomainLineEdit->trapReturnKey());
81  QVERIFY(excludeDomainLineEdit->text().isEmpty());
82  QVERIFY(excludeDomainLineEdit->isClearButtonShown());
83  QVERIFY(!excludeDomainLineEdit->clickMessage().isEmpty());
84 }
85 
86 void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
87 {
88  KPIM::BlackListBalooEmailCompletionWidget widget;
89  KLineEdit *searchLineEdit = qFindChild<KLineEdit *>(&widget, QLatin1String("search_lineedit"));
90  KPushButton *seachButton = qFindChild<KPushButton *>(&widget, QLatin1String("search_button"));
91  QVERIFY(!seachButton->isEnabled());
92  searchLineEdit->setText(QLatin1String("fo"));
93  QVERIFY(!seachButton->isEnabled());
94  searchLineEdit->setText(QLatin1String("foo"));
95  QVERIFY(seachButton->isEnabled());
96 
97  searchLineEdit->setText(QLatin1String("o "));
98  QVERIFY(!seachButton->isEnabled());
99  searchLineEdit->setText(QLatin1String(" o "));
100  QVERIFY(!seachButton->isEnabled());
101 }
102 
103 void BlackListBalooEmailCompletionWidgetTest::shouldChangeEnableSelectUnSelectButton()
104 {
105  KPIM::BlackListBalooEmailCompletionWidget widget;
106 
107  KPushButton *selectButton = qFindChild<KPushButton *>(&widget, QLatin1String("select_email"));
108  QVERIFY(!selectButton->isEnabled());
109 
110  KPushButton *unselectButton = qFindChild<KPushButton *>(&widget, QLatin1String("unselect_email"));
111  QVERIFY(!unselectButton->isEnabled());
112 
113  KPIM::BlackListBalooEmailList *emailList = qFindChild<KPIM::BlackListBalooEmailList *>(&widget, QLatin1String("email_list"));
114  emailList->slotEmailFound(QStringList() << QLatin1String("foo") << QLatin1String("bla") << QLatin1String("bli"));
115 
116  emailList->selectAll();
117  QVERIFY(unselectButton->isEnabled());
118  QVERIFY(selectButton->isEnabled());
119 
120  emailList->clearSelection();
121  QVERIFY(!unselectButton->isEnabled());
122  QVERIFY(!selectButton->isEnabled());
123 
124 }
125 
126 QTEST_KDEMAIN(BlackListBalooEmailCompletionWidgetTest, GUI)
QTest::qWaitForWindowShown
bool qWaitForWindowShown(QWidget *window)
KPIM::BlackListBalooEmailList
Definition: blacklistbalooemaillist.h:44
QObject
BlackListBalooEmailCompletionWidgetTest::~BlackListBalooEmailCompletionWidgetTest
~BlackListBalooEmailCompletionWidgetTest()
Definition: blacklistbalooemailcompletionwidgettest.cpp:35
KPIM::BlackListBalooEmailList::slotEmailFound
void slotEmailFound(const QStringList &)
Definition: blacklistbalooemaillist.cpp:67
QStringList
KPIM::BlackListBalooEmailCompletionWidget
Definition: blacklistbalooemailcompletionwidget.h:30
KLineEdit
QLatin1String
BlackListBalooEmailCompletionWidgetTest
Definition: blacklistbalooemailcompletionwidgettest.h:26
BlackListBalooEmailCompletionWidgetTest::BlackListBalooEmailCompletionWidgetTest
BlackListBalooEmailCompletionWidgetTest(QObject *parent=0)
Definition: blacklistbalooemailcompletionwidgettest.cpp:29
QWidget::show
void show()
QLabel
blacklistbalooemailcompletionwidgettest.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdepim

Skip menu "libkdepim"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

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