• 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
  • autotests
recentaddresswidgettest.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 "recentaddresswidgettest.h"
22 #include "../recentaddress/recentaddresswidget.h"
23 #include <KLineEdit>
24 #include <KPushButton>
25 #include <qlistwidget.h>
26 #include <qtest_kde.h>
27 #include <qtestmouse.h>
28 
29 RecentAddressWidgetTest::RecentAddressWidgetTest(QObject *parent)
30  : QObject(parent)
31 {
32 
33 }
34 
35 RecentAddressWidgetTest::~RecentAddressWidgetTest()
36 {
37 
38 }
39 
40 void RecentAddressWidgetTest::shouldHaveDefaultValue()
41 {
42  KPIM::RecentAddressWidget w;
43  KLineEdit *lineedit = qFindChild<KLineEdit *>(&w, QLatin1String("line_edit"));
44  QVERIFY(lineedit);
45 
46  KPushButton *newButton = qFindChild<KPushButton *>(&w, QLatin1String("new_button"));
47  QVERIFY(newButton);
48 
49  KPushButton *removeButton = qFindChild<KPushButton *>(&w, QLatin1String("remove_button"));
50  QVERIFY(removeButton);
51 
52  QListWidget *listview = qFindChild<QListWidget *>(&w, QLatin1String("list_view"));
53  QVERIFY(listview);
54  QCOMPARE(listview->count(), 0);
55 }
56 
57 void RecentAddressWidgetTest::shouldAddAddresses()
58 {
59  KPIM::RecentAddressWidget w;
60  QListWidget *listview = qFindChild<QListWidget *>(&w, QLatin1String("list_view"));
61  QCOMPARE(listview->count(), 0);
62  QStringList lst;
63  lst << QLatin1String("foo");
64  lst << QLatin1String("foo1");
65  lst << QLatin1String("foo2");
66  w.setAddresses(lst);
67  QCOMPARE(listview->count(), lst.count());
68  //Clear list before to add
69  w.setAddresses(lst);
70  QCOMPARE(listview->count(), lst.count());
71 }
72 
73 void RecentAddressWidgetTest::shouldInformThatItWasChanged()
74 {
75  KPIM::RecentAddressWidget w;
76  QVERIFY(!w.wasChanged());
77  KPushButton *newButton = qFindChild<KPushButton *>(&w, QLatin1String("new_button"));
78  QVERIFY(newButton);
79  QTest::mouseClick(newButton, Qt::LeftButton);
80  QVERIFY(w.wasChanged());
81  QListWidget *listview = qFindChild<QListWidget *>(&w, QLatin1String("list_view"));
82  QCOMPARE(listview->count(), 1);
83 }
84 
85 void RecentAddressWidgetTest::shouldNotAddMultiEmptyLine()
86 {
87  KPIM::RecentAddressWidget w;
88  KLineEdit *lineedit = qFindChild<KLineEdit *>(&w, QLatin1String("line_edit"));
89  QVERIFY(lineedit);
90 
91  KPushButton *newButton = qFindChild<KPushButton *>(&w, QLatin1String("new_button"));
92  QVERIFY(newButton);
93 
94  QListWidget *listview = qFindChild<QListWidget *>(&w, QLatin1String("list_view"));
95  QCOMPARE(listview->count(), 0);
96 
97  QTest::mouseClick(newButton, Qt::LeftButton);
98  QCOMPARE(listview->count(), 1);
99 
100  QTest::mouseClick(newButton, Qt::LeftButton);
101  QCOMPARE(listview->count(), 1);
102 }
103 
104 QTEST_KDEMAIN(RecentAddressWidgetTest, GUI)
KPIM::RecentAddressWidget
Definition: recentaddresswidget.h:33
recentaddresswidgettest.h
QListWidget
QObject
RecentAddressWidgetTest
Definition: recentaddresswidgettest.h:26
QListWidget::count
count
QStringList
KLineEdit
QLatin1String
RecentAddressWidgetTest::~RecentAddressWidgetTest
~RecentAddressWidgetTest()
Definition: recentaddresswidgettest.cpp:35
RecentAddressWidgetTest::RecentAddressWidgetTest
RecentAddressWidgetTest(QObject *parent=0)
Definition: recentaddresswidgettest.cpp:29
KPIM::RecentAddressWidget::wasChanged
bool wasChanged() const
Definition: recentaddresswidget.cpp:191
QTest::mouseClick
void mouseClick(QWidget *widget, Qt::MouseButton button, QFlags< Qt::KeyboardModifier > modifier, QPoint pos, int delay)
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