• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi/contact

  • akonadi
  • contact
  • editor
  • autotests
emaileditwidgettest.cpp
1/*
2 Copyright (c) 2015 Laurent Montel <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public 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
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20
21#include "emaileditwidgettest.h"
22#include "../emaileditwidget.h"
23#include <KLineEdit>
24#include <QToolButton>
25#include <qtest_kde.h>
26#include "kabc/addressee.h"
27EmailEditWidgetTest::EmailEditWidgetTest(QObject *parent)
28 : QObject(parent)
29{
30
31}
32
33EmailEditWidgetTest::~EmailEditWidgetTest()
34{
35
36}
37
38void EmailEditWidgetTest::shouldHaveDefaultValue()
39{
40 EmailEditWidget widget;
41 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget, QLatin1String("emailedit"));
42 QVERIFY(lineedit);
43 QVERIFY(lineedit->text().isEmpty());
44
45 QToolButton *toolButton = qFindChild<QToolButton *>(&widget, QLatin1String("editbutton"));
46 QVERIFY(toolButton);
47}
48
49void EmailEditWidgetTest::shouldReadOnly()
50{
51 EmailEditWidget widget;
52 widget.setReadOnly(true);
53 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget, QLatin1String("emailedit"));
54
55 QToolButton *toolButton = qFindChild<QToolButton *>(&widget, QLatin1String("editbutton"));
56 QVERIFY(lineedit->isReadOnly());
57 QVERIFY(!toolButton->isEnabled());
58}
59
60void EmailEditWidgetTest::shouldSelectFirstEmail()
61{
62 EmailEditWidget widget;
63 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget, QLatin1String("emailedit"));
64 KABC::Addressee addr;
65 KABC::Email::List lst;
66 const QString firstEmail(QLatin1String("foo@kde.org"));
67 lst << KABC::Email(firstEmail);
68 lst << KABC::Email(QLatin1String("foo2@kde.org"));
69 addr.setEmailList(lst);
70 widget.loadContact(addr);
71 QCOMPARE(lineedit->text(), firstEmail);
72}
73
74void EmailEditWidgetTest::shouldChangeEmail()
75{
76 EmailEditWidget widget;
77 KLineEdit *lineedit = qFindChild<KLineEdit *>(&widget, QLatin1String("emailedit"));
78 KABC::Addressee addr;
79 KABC::Email::List lst;
80 const QString firstEmail(QLatin1String("foo@kde.org"));
81 lst << KABC::Email(firstEmail);
82 lst << KABC::Email(QLatin1String("foo2@kde.org"));
83 addr.setEmailList(lst);
84 widget.loadContact(addr);
85 const QString changedEmail(QLatin1String("foo3@kde.org"));
86 lineedit->setText(changedEmail);
87 KABC::Addressee result;
88 widget.storeContact(result);
89 QVERIFY(!result.emailList().isEmpty());
90 QCOMPARE(result.emailList().first().mail(), changedEmail);
91}
92
93QTEST_KDEMAIN(EmailEditWidgetTest, GUI)
EmailEditWidget
A widget for editing email addresses.
Definition: emaileditwidget.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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