Commit d142a19c authored by Laurent Montel's avatar Laurent Montel 😁

Fix enable/disable ok button . Add unittest here

parent 2ebf5587
...@@ -58,3 +58,5 @@ install(FILES ...@@ -58,3 +58,5 @@ install(FILES
DESTINATION ${DATA_INSTALL_DIR}/sieveeditor) DESTINATION ${DATA_INSTALL_DIR}/sieveeditor)
install(PROGRAMS sieveeditor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) install(PROGRAMS sieveeditor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
add_subdirectory(autotests)
set( sieveedit_serversievesettings_source serversievesettingstest.cpp ../serversievesettings.cpp)
kde4_add_ui_files(sieveedit_serversievesettings_source
../ui/serversievesettings.ui
)
kde4_add_unit_test( serversievesettingstest ${sieveedit_serversievesettings_source})
target_link_libraries( serversievesettingstest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS})
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "serversievesettingstest.h"
#include "../serversievesettings.h"
#include <qtest_kde.h>
ServerSieveSettingsTest::ServerSieveSettingsTest(QObject *parent)
: QObject(parent)
{
}
ServerSieveSettingsTest::~ServerSieveSettingsTest()
{
}
void ServerSieveSettingsTest::shouldHaveDefaultValue()
{
ServerSieveSettings widget;
QVERIFY(widget.serverName().isEmpty());
QVERIFY(widget.userName().isEmpty());
QVERIFY(widget.password().isEmpty());
}
void ServerSieveSettingsTest::shouldSetValue()
{
const QString password = QLatin1String("password");
const QString username = QLatin1String("username");
const QString servername = QLatin1String("servername");
ServerSieveSettings widget;
widget.setServerName(servername);
widget.setUserName(username);
widget.setPassword(password);
QCOMPARE(widget.serverName(), servername);
QCOMPARE(widget.userName(), username);
QCOMPARE(widget.password(), password);
}
QTEST_KDEMAIN(ServerSieveSettingsTest, GUI)
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef SERVERSIEVESETTINGSTEST_H
#define SERVERSIEVESETTINGSTEST_H
#include <QObject>
class ServerSieveSettingsTest : public QObject
{
Q_OBJECT
public:
explicit ServerSieveSettingsTest(QObject *parent = 0);
~ServerSieveSettingsTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldSetValue();
};
#endif // SERVERSIEVESETTINGSTEST_H
...@@ -107,7 +107,7 @@ void ServerSieveSettings::populateDefaultAuthenticationOptions() ...@@ -107,7 +107,7 @@ void ServerSieveSettings::populateDefaultAuthenticationOptions()
void ServerSieveSettings::slotUserServerNameChanged() void ServerSieveSettings::slotUserServerNameChanged()
{ {
Q_EMIT enableOkButton(!ui->userName->text().isEmpty() && !ui->serverName->text().isEmpty()); Q_EMIT enableOkButton(!ui->userName->text().trimmed().isEmpty() && !ui->serverName->text().trimmed().isEmpty());
} }
QString ServerSieveSettings::serverName() const QString ServerSieveSettings::serverName() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment