[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/KDE/4.14] kmail: add autotests. Fix isValid() too
From: Montel Laurent <montel () kde ! org>
Date: 2014-11-03 21:58:52
Message-ID: E1XlPeG-0001jL-41 () scm ! kde ! org
[Download RAW message or body]
Git commit 975664c4aee288a5c481adbe77b2ca1e9bd13bf4 by Montel Laurent.
Committed on 03/11/2014 at 21:57.
Pushed by mlaurent into branch 'KDE/4.14'.
add autotests. Fix isValid() too
M +1 -0 kmail/CMakeLists.txt
A +74 -0 kmail/folderarchive/autotests/folderarchiveaccountinfotest.cpp \
[License: GPL (v2)] A +40 -0 \
kmail/folderarchive/autotests/folderarchiveaccountinfotest.h [License: GPL (v2)] \
M +10 -1 kmail/folderarchive/folderarchiveaccountinfo.cpp M +2 -0 \
kmail/folderarchive/folderarchiveaccountinfo.h
http://commits.kde.org/kdepim/975664c4aee288a5c481adbe77b2ca1e9bd13bf4
diff --git a/kmail/CMakeLists.txt b/kmail/CMakeLists.txt
index 21f59f2..d60e025 100644
--- a/kmail/CMakeLists.txt
+++ b/kmail/CMakeLists.txt
@@ -347,6 +347,7 @@ if (KDEPIM_BUILD_DESKTOP)
add_subdirectory(mailmerge/tests/)
+ add_subdirectory(folderarchive/autotests/)
########### install files ###############
install(TARGETS kmailprivate ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY \
NAMELINK_SKIP)
diff --git a/kmail/folderarchive/autotests/folderarchiveaccountinfotest.cpp \
b/kmail/folderarchive/autotests/folderarchiveaccountinfotest.cpp new file mode 100644
index 0000000..d01cc17
--- /dev/null
+++ b/kmail/folderarchive/autotests/folderarchiveaccountinfotest.cpp
@@ -0,0 +1,74 @@
+/*
+ Copyright (c) 2014 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 "folderarchiveaccountinfotest.h"
+#include "../folderarchiveaccountinfo.h"
+#include <KGlobal>
+#include <Akonadi/Collection>
+#include <qtest_kde.h>
+
+
+FolderArchiveAccountInfoTest::FolderArchiveAccountInfoTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+FolderArchiveAccountInfoTest::~FolderArchiveAccountInfoTest()
+{
+
+}
+
+void FolderArchiveAccountInfoTest::shouldHaveDefaultValue()
+{
+ FolderArchiveAccountInfo info;
+ QVERIFY(info.instanceName().isEmpty());
+ QCOMPARE(info.archiveTopLevel(), Akonadi::Collection(-1).id());
+ QCOMPARE(info.folderArchiveType(), FolderArchiveAccountInfo::UniqueFolder);
+ QCOMPARE(info.enabled(), false);
+ QCOMPARE(info.keepExistingStructure(), false);
+ QCOMPARE(info.isValid(), false);
+
+}
+
+void FolderArchiveAccountInfoTest::shouldBeValid()
+{
+ FolderArchiveAccountInfo info;
+ QVERIFY(!info.isValid());
+ info.setArchiveTopLevel(Akonadi::Collection(42).id());
+ QVERIFY(!info.isValid());
+ info.setInstanceName(QLatin1String("FOO"));
+ QVERIFY(info.isValid());
+}
+
+void FolderArchiveAccountInfoTest::shouldRestoreFromSettings()
+{
+ FolderArchiveAccountInfo info;
+ info.setInstanceName(QLatin1String("FOO1"));
+ info.setArchiveTopLevel(Akonadi::Collection(42).id());
+ info.setFolderArchiveType(FolderArchiveAccountInfo::FolderByMonths);
+ info.setEnabled(true);
+ info.setKeepExistingStructure(true);
+
+ KConfigGroup grp(KGlobal::config(), "testsettings");
+ info.writeConfig(grp);
+
+ FolderArchiveAccountInfo restoreInfo(grp);
+ QCOMPARE(info, restoreInfo);
+}
+
+QTEST_KDEMAIN(FolderArchiveAccountInfoTest, NoGUI)
diff --git a/kmail/folderarchive/autotests/folderarchiveaccountinfotest.h \
b/kmail/folderarchive/autotests/folderarchiveaccountinfotest.h new file mode 100644
index 0000000..c0fa219
--- /dev/null
+++ b/kmail/folderarchive/autotests/folderarchiveaccountinfotest.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2014 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 FOLDERARCHIVEACCOUNTINFOTEST_H
+#define FOLDERARCHIVEACCOUNTINFOTEST_H
+
+#include <QObject>
+
+
+class FolderArchiveAccountInfoTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit FolderArchiveAccountInfoTest(QObject *parent = 0);
+ ~FolderArchiveAccountInfoTest();
+
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
+ void shouldBeValid();
+ void shouldRestoreFromSettings();
+};
+
+
+
+#endif // FOLDERARCHIVEACCOUNTINFOTEST_H
+
diff --git a/kmail/folderarchive/folderarchiveaccountinfo.cpp \
b/kmail/folderarchive/folderarchiveaccountinfo.cpp index 154f4e2..e02621a 100644
--- a/kmail/folderarchive/folderarchiveaccountinfo.cpp
+++ b/kmail/folderarchive/folderarchiveaccountinfo.cpp
@@ -42,7 +42,7 @@ FolderArchiveAccountInfo::~FolderArchiveAccountInfo()
bool FolderArchiveAccountInfo::isValid() const
{
- return (mArchiveTopLevelCollectionId > -1);
+ return (mArchiveTopLevelCollectionId > -1) && (!mInstanceName.isEmpty());
}
void FolderArchiveAccountInfo::setFolderArchiveType(FolderArchiveAccountInfo::FolderArchiveType \
type) @@ -116,3 +116,12 @@ void FolderArchiveAccountInfo::writeConfig(KConfigGroup \
&config ) config.writeEntry(QLatin1String("enabled"), mEnabled);
config.writeEntry("keepExistingStructure", mKeepExistingStructure);
}
+
+bool FolderArchiveAccountInfo::operator==( const FolderArchiveAccountInfo& other ) \
const +{
+ return (mInstanceName == other.instanceName())
+ && (mArchiveTopLevelCollectionId == other.archiveTopLevel())
+ && (mArchiveType == other.folderArchiveType())
+ && (mEnabled == other.enabled())
+ && (mKeepExistingStructure == other.keepExistingStructure());
+}
diff --git a/kmail/folderarchive/folderarchiveaccountinfo.h \
b/kmail/folderarchive/folderarchiveaccountinfo.h index c09019a..4d52da3 100644
--- a/kmail/folderarchive/folderarchiveaccountinfo.h
+++ b/kmail/folderarchive/folderarchiveaccountinfo.h
@@ -54,6 +54,8 @@ public:
void writeConfig(KConfigGroup &config );
void readConfig(const KConfigGroup &config);
+ bool operator==( const FolderArchiveAccountInfo& other ) const;
+
private:
FolderArchiveAccountInfo::FolderArchiveType mArchiveType;
Akonadi::Collection::Id mArchiveTopLevelCollectionId;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic