summaryrefslogtreecommitdiffstats
path: root/tests/mailtest.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-24 09:20:02 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-24 09:20:02 +0200
commit6434a87199b3259e9002570332beaa8caf5d2213 (patch)
tree87c5fe877e350b067b37961b9af2058693be8665 /tests/mailtest.h
parentf47270cea65545f946ff301014cb09bd5ff40261 (diff)
downloadsink-6434a87199b3259e9002570332beaa8caf5d2213.tar.gz
sink-6434a87199b3259e9002570332beaa8caf5d2213.zip
A generic mailtest that can be applied to all resources that support
mails.
Diffstat (limited to 'tests/mailtest.h')
-rw-r--r--tests/mailtest.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/mailtest.h b/tests/mailtest.h
new file mode 100644
index 0000000..0729a91
--- /dev/null
+++ b/tests/mailtest.h
@@ -0,0 +1,69 @@
1/*
2 * Copyright (C) 2016 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19#pragma once
20
21#include <QObject>
22#include <QByteArray>
23
24#include <applicationdomaintype.h>
25
26#define ASYNCCOMPARE(actual, expected) \
27do {\
28 if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
29 return KAsync::error<void>(1, "Comparison failed.");\
30} while (0)
31
32#define ASYNCVERIFY(statement) \
33do {\
34 if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
35 return KAsync::error<void>(1, "Verify failed.");\
36} while (0)
37
38#define VERIFYEXEC(statement) \
39do {\
40 auto result = statement.exec(); \
41 result.waitForFinished(); \
42 if (!QTest::qVerify(!result.errorCode(), #statement, "", __FILE__, __LINE__))\
43 return;\
44} while (0)
45
46namespace Sink {
47
48class MailTest : public QObject
49{
50 Q_OBJECT
51
52protected:
53 QByteArray mResourceInstanceIdentifier;
54
55 virtual void resetTestEnvironment() = 0;
56 virtual Sink::ApplicationDomain::SinkResource createResource() = 0;
57 virtual void removeResourceFromDisk(const QByteArray &mResourceInstanceIdentifier) = 0;
58
59private slots:
60 void initTestCase();
61 void init();
62 void cleanup();
63
64 void testCreateModifyDeleteFolder();
65 void testCreateModifyDeleteMail();
66};
67
68}
69