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

Add more unittest

parent cf88f315
......@@ -90,6 +90,16 @@ void ConfigureAgentItem::setFailed(bool failed)
mFailed = failed;
}
bool ConfigureAgentItem::operator ==(const ConfigureAgentItem &other) const
{
return (mAgentName == other.agentName()) &&
(mDescription == other.description()) &&
(mPath == other.path()) &&
(mInterfaceName == other.interfaceName()) &&
(mChecked == other.checked()) &&
(mFailed == other.failed());
}
......
......@@ -44,6 +44,8 @@ public:
bool failed() const;
void setFailed(bool failed);
bool operator ==(const ConfigureAgentItem &other) const;
private:
QString mAgentName;
QString mDescription;
......
......@@ -35,3 +35,7 @@ ConfigureAgentListView::~ConfigureAgentListView()
}
void ConfigureAgentListView::setAgentItems(const QVector<ConfigureAgentItem> &lst)
{
//TODO
}
......@@ -19,13 +19,15 @@
#define CONFIGUREAGENTLISTVIEW_H
#include <QListView>
#include "configureagentitem.h"
class ConfigureAgentListView : public QListView
{
Q_OBJECT
public:
explicit ConfigureAgentListView(QWidget *parent = 0);
~ConfigureAgentListView();
void setAgentItems(const QVector<ConfigureAgentItem> &lst);
};
#endif // CONFIGUREAGENTLISTVIEW_H
......@@ -59,4 +59,7 @@ set( kmail_configureagentlistviewtest_source configureagentlistviewtest.cpp ../c
kde4_add_unit_test( configureagentlistviewtest ${kmail_configureagentlistviewtest_source})
target_link_libraries( configureagentlistviewtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} )
set( kmail_configureagentitemtest_source configureagentitemtest.cpp ../configuredialog/configureagents/configureagentitem.cpp)
kde4_add_unit_test( configureagentitemtest ${kmail_configureagentitemtest_source})
target_link_libraries( configureagentitemtest ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS} )
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "configureagentitemtest.h"
#include "../configuredialog/configureagents/configureagentitem.h"
#include <qtest_kde.h>
ConfigureAgentItemTest::ConfigureAgentItemTest(QObject *parent)
: QObject(parent)
{
}
ConfigureAgentItemTest::~ConfigureAgentItemTest()
{
}
void ConfigureAgentItemTest::shouldHaveDefaultValue()
{
ConfigureAgentItem item;
QVERIFY(item.agentName().isEmpty());
QVERIFY(!item.checked());
QVERIFY(!item.failed());
QVERIFY(item.description().isEmpty());
QVERIFY(item.path().isEmpty());
QVERIFY(item.interfaceName().isEmpty());
}
void ConfigureAgentItemTest::shouldAssignValue()
{
ConfigureAgentItem item;
QString agentName = QLatin1String("foo");
QString description = QLatin1String("bla");
QString interface = QLatin1String("interface");
QString path = QLatin1String("path");
bool failed = true;
bool checked = true;
item.setAgentName(agentName);
item.setDescription(description);
item.setInterfaceName(interface);
item.setFailed(failed);
item.setPath(path);
item.setChecked(checked);
QCOMPARE(item.agentName(), agentName);
QCOMPARE(item.description(), description);
QCOMPARE(item.path(), path);
QCOMPARE(item.interfaceName(), interface);
QCOMPARE(item.failed(), failed);
QCOMPARE(item.checked(), checked);
}
void ConfigureAgentItemTest::shouldBeEqual()
{
ConfigureAgentItem item;
QString agentName = QLatin1String("foo");
QString description = QLatin1String("bla");
QString interface = QLatin1String("interface");
QString path = QLatin1String("path");
bool failed = true;
bool checked = true;
item.setAgentName(agentName);
item.setDescription(description);
item.setInterfaceName(interface);
item.setFailed(failed);
item.setPath(path);
item.setChecked(checked);
ConfigureAgentItem copyItem;
copyItem = item;
QVERIFY(copyItem == item);
}
QTEST_KDEMAIN(ConfigureAgentItemTest, NoGUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CONFIGUREAGENTITEMTEST_H
#define CONFIGUREAGENTITEMTEST_H
#include <QObject>
class ConfigureAgentItemTest : public QObject
{
Q_OBJECT
public:
explicit ConfigureAgentItemTest(QObject *parent = 0);
~ConfigureAgentItemTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignValue();
void shouldBeEqual();
};
#endif // CONFIGUREAGENTITEMTEST_H
......@@ -16,6 +16,7 @@
*/
#include "configureagentlistviewtest.h"
#include "../configuredialog/configureagents/configureagentlistview.h"
#include <qtest_kde.h>
ConfigureAgentListViewTest::ConfigureAgentListViewTest(QObject *parent)
......@@ -29,4 +30,10 @@ ConfigureAgentListViewTest::~ConfigureAgentListViewTest()
}
void ConfigureAgentListViewTest::shouldHaveDefaultValue()
{
ConfigureAgentListView view;
QCOMPARE(view.model()->rowCount(), 0);
}
QTEST_KDEMAIN(ConfigureAgentListViewTest, GUI)
......@@ -26,6 +26,8 @@ class ConfigureAgentListViewTest : public QObject
public:
explicit ConfigureAgentListViewTest(QObject *parent = 0);
~ConfigureAgentListViewTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // CONFIGUREAGENTLISTVIEWTEST_H
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