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

Add autotest

parent b593adf9
......@@ -102,6 +102,8 @@ if (KDEPIM_BUILD_DESKTOP)
configuredialog/configurestorageservicewidget.cpp
configuredialog/configureagents/configureagentlistmodel.cpp
configuredialog/configureagents/configureagentlistdelegate.cpp
configuredialog/configureagents/configureagentlistview.cpp
configuredialog/configureagents/configureagentitem.cpp
)
set(kmailprivate_searchdialog_LIB_SRCS
......
/*
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 "configureagentitem.h"
ConfigureAgentItem::ConfigureAgentItem()
: mChecked(false),
mFailed(false)
{
}
ConfigureAgentItem::~ConfigureAgentItem()
{
}
QString ConfigureAgentItem::agentName() const
{
return mAgentName;
}
void ConfigureAgentItem::setAgentName(const QString &agentName)
{
mAgentName = agentName;
}
QString ConfigureAgentItem::description() const
{
return mDescription;
}
void ConfigureAgentItem::setDescription(const QString &description)
{
mDescription = description;
}
QString ConfigureAgentItem::path() const
{
return mPath;
}
void ConfigureAgentItem::setPath(const QString &path)
{
mPath = path;
}
QString ConfigureAgentItem::interfaceName() const
{
return mInterfaceName;
}
void ConfigureAgentItem::setInterfaceName(const QString &interfaceName)
{
mInterfaceName = interfaceName;
}
bool ConfigureAgentItem::checked() const
{
return mChecked;
}
void ConfigureAgentItem::setChecked(bool checked)
{
mChecked = checked;
}
bool ConfigureAgentItem::failed() const
{
return mFailed;
}
void ConfigureAgentItem::setFailed(bool failed)
{
mFailed = failed;
}
/*
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 CONFIGUREAGENTITEM_H
#define CONFIGUREAGENTITEM_H
#include <QString>
class ConfigureAgentItem
{
public:
ConfigureAgentItem();
~ConfigureAgentItem();
QString agentName() const;
void setAgentName(const QString &agentName);
QString description() const;
void setDescription(const QString &description);
QString path() const;
void setPath(const QString &path);
QString interfaceName() const;
void setInterfaceName(const QString &interfaceName);
bool checked() const;
void setChecked(bool checked);
bool failed() const;
void setFailed(bool failed);
private:
QString mAgentName;
QString mDescription;
QString mPath;
QString mInterfaceName;
bool mChecked;
bool mFailed;
};
Q_DECLARE_TYPEINFO(ConfigureAgentItem, Q_MOVABLE_TYPE);
#endif // CONFIGUREAGENTITEM_H
......@@ -40,9 +40,7 @@ bool ConfigureAgentListModel::insertRows(int row, int count, const QModelIndex&
beginInsertRows(parent, row, row + count - 1);
for (int i = 0; i < count; ++i) {
AgentItem info;
info.checked = false;
info.failed = false;
ConfigureAgentItem info;
mAgentItems.insert(row, info);
}
endInsertRows();
......@@ -59,22 +57,22 @@ bool ConfigureAgentListModel::setData(const QModelIndex& index, const QVariant&
switch (role) {
case Qt::DisplayRole:
mAgentItems[row].agentName = value.toString();
mAgentItems[row].setAgentName(value.toString());
break;
case DescriptionRole:
mAgentItems[row].description = value.toString();
mAgentItems[row].setDescription(value.toString());
break;
case PathRole:
mAgentItems[row].path = value.toString();
mAgentItems[row].setPath(value.toString());
break;
case InterfaceNameRole:
mAgentItems[row].interfaceName = value.toString();
mAgentItems[row].setInterfaceName(value.toString());
break;
case FailedRole:
mAgentItems[row].failed = value.toBool();
mAgentItems[row].setFailed(value.toBool());
break;
case Qt::CheckStateRole:
mAgentItems[row].checked = value.toBool();
mAgentItems[row].setChecked(value.toBool());
break;
default:
return false;
......@@ -90,17 +88,17 @@ QVariant ConfigureAgentListModel::data(const QModelIndex& index, int role) const
if (row < rowCount()) {
switch (role) {
case Qt::DisplayRole:
return mAgentItems[row].agentName;
return mAgentItems[row].agentName();
case DescriptionRole:
return mAgentItems[row].description;
return mAgentItems[row].description();
case PathRole:
return mAgentItems[row].path;
return mAgentItems[row].path();
case InterfaceNameRole:
return mAgentItems[row].interfaceName;
return mAgentItems[row].interfaceName();
case FailedRole:
return mAgentItems[row].failed;
return mAgentItems[row].failed();
case Qt::CheckStateRole:
return mAgentItems[row].checked;
return mAgentItems[row].checked();
default:
break;
}
......
......@@ -20,7 +20,8 @@
#define CONFIGUREAGENTLISTMODEL_H
#include <QAbstractItemModel>
#include <QVector>
#include "configureagentitem.h"
class ConfigureAgentListModel: public QAbstractListModel
......@@ -45,23 +46,7 @@ public:
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
private:
struct AgentItem
{
AgentItem()
: checked(false),
failed(false)
{
}
QString agentName;
QString description;
QString path;
QString interfaceName;
bool checked;
bool failed;
};
QList<AgentItem> mAgentItems;
QVector<ConfigureAgentItem> mAgentItems;
};
#endif // CONFIGUREAGENTLISTMODEL_H
......@@ -16,11 +16,18 @@
*/
#include "configureagentlistview.h"
#include "configureagentlistdelegate.h"
#include "configureagentlistmodel.h"
ConfigureAgentListView::ConfigureAgentListView(QWidget *parent)
: QListView(parent)
{
ConfigureAgentListDelegate *configureListDelegate = new ConfigureAgentListDelegate(this, this);
ConfigureAgentListModel *configureAgentListModel = new ConfigureAgentListModel(this);
setModel(configureAgentListModel);
setItemDelegate(configureListDelegate);
}
ConfigureAgentListView::~ConfigureAgentListView()
......
......@@ -53,3 +53,10 @@ set(KDEPIMLIBS_RUN_SQLITE_ISOLATED_TESTS TRUE)
add_akonadi_isolated_test_advanced( followupreminderselectdatedialogtest.cpp "../followupreminder/followupreminderselectdatedialog.cpp" "${KDEPIMLIBS_AKONADI_CALENDAR_LIBS};${KDEPIMLIBS_KCALCORE_LIBS}")
set( kmail_configureagentlistviewtest_source configureagentlistviewtest.cpp ../configuredialog/configureagents/configureagentitem.cpp
../configuredialog/configureagents/configureagentlistmodel.cpp ../configuredialog/configureagents/configureagentlistview.cpp
../configuredialog/configureagents/configureagentlistdelegate.cpp)
kde4_add_unit_test( configureagentlistviewtest ${kmail_configureagentlistviewtest_source})
target_link_libraries( configureagentlistviewtest ${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 "configureagentlistviewtest.h"
#include <qtest_kde.h>
ConfigureAgentListViewTest::ConfigureAgentListViewTest(QObject *parent)
: QObject(parent)
{
}
ConfigureAgentListViewTest::~ConfigureAgentListViewTest()
{
}
QTEST_KDEMAIN(ConfigureAgentListViewTest, GUI)
/*
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 CONFIGUREAGENTLISTVIEWTEST_H
#define CONFIGUREAGENTLISTVIEWTEST_H
#include <QObject>
class ConfigureAgentListViewTest : public QObject
{
Q_OBJECT
public:
explicit ConfigureAgentListViewTest(QObject *parent = 0);
~ConfigureAgentListViewTest();
};
#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