diff options
Diffstat (limited to 'examples/imapresource/tests/imapmailsynctest.cpp')
-rw-r--r-- | examples/imapresource/tests/imapmailsynctest.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp new file mode 100644 index 0000000..c73c840 --- /dev/null +++ b/examples/imapresource/tests/imapmailsynctest.cpp | |||
@@ -0,0 +1,84 @@ | |||
1 | #include <QtTest> | ||
2 | |||
3 | #include <tests/mailsynctest.h> | ||
4 | #include "../imapresource.h" | ||
5 | #include "../imapserverproxy.h" | ||
6 | |||
7 | #include "common/test.h" | ||
8 | #include "common/domain/applicationdomaintype.h" | ||
9 | |||
10 | using namespace Sink; | ||
11 | using namespace Sink::ApplicationDomain; | ||
12 | |||
13 | /** | ||
14 | * Test of complete system using the imap resource. | ||
15 | * | ||
16 | * This test requires the imap resource installed. | ||
17 | */ | ||
18 | class ImapMailSyncTest : public Sink::MailSyncTest | ||
19 | { | ||
20 | Q_OBJECT | ||
21 | |||
22 | protected: | ||
23 | void resetTestEnvironment() Q_DECL_OVERRIDE | ||
24 | { | ||
25 | system("resetmailbox.sh"); | ||
26 | } | ||
27 | |||
28 | Sink::ApplicationDomain::SinkResource createResource() Q_DECL_OVERRIDE | ||
29 | { | ||
30 | auto resource = ApplicationDomain::ImapResource::create("account1"); | ||
31 | resource.setProperty("server", "localhost"); | ||
32 | resource.setProperty("port", 993); | ||
33 | resource.setProperty("user", "doe"); | ||
34 | resource.setProperty("password", "doe"); | ||
35 | return resource; | ||
36 | } | ||
37 | |||
38 | Sink::ApplicationDomain::SinkResource createFaultyResource() Q_DECL_OVERRIDE | ||
39 | { | ||
40 | auto resource = ApplicationDomain::ImapResource::create("account1"); | ||
41 | resource.setProperty("server", "foobar"); | ||
42 | resource.setProperty("port", 993); | ||
43 | resource.setProperty("user", "doe"); | ||
44 | resource.setProperty("password", "doe"); | ||
45 | return resource; | ||
46 | } | ||
47 | |||
48 | void removeResourceFromDisk(const QByteArray &identifier) Q_DECL_OVERRIDE | ||
49 | { | ||
50 | ::ImapResource::removeFromDisk(identifier); | ||
51 | } | ||
52 | |||
53 | void createFolder(const QStringList &folderPath) Q_DECL_OVERRIDE | ||
54 | { | ||
55 | Imap::ImapServerProxy imap("localhost", 993); | ||
56 | VERIFYEXEC(imap.login("doe", "doe")); | ||
57 | VERIFYEXEC(imap.create("INBOX." + folderPath.join('.'))); | ||
58 | } | ||
59 | |||
60 | void removeFolder(const QStringList &folderPath) Q_DECL_OVERRIDE | ||
61 | { | ||
62 | Imap::ImapServerProxy imap("localhost", 993); | ||
63 | VERIFYEXEC(imap.login("doe", "doe")); | ||
64 | VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.'))); | ||
65 | } | ||
66 | |||
67 | void createMessage(const QStringList &folderPath, const QByteArray &message) Q_DECL_OVERRIDE | ||
68 | { | ||
69 | Imap::ImapServerProxy imap("localhost", 993); | ||
70 | VERIFYEXEC(imap.login("doe", "doe")); | ||
71 | VERIFYEXEC(imap.append("INBOX." + folderPath.join('.'), message)); | ||
72 | } | ||
73 | |||
74 | void removeMessage(const QStringList &folderPath, const QByteArray &messages) Q_DECL_OVERRIDE | ||
75 | { | ||
76 | Imap::ImapServerProxy imap("localhost", 993); | ||
77 | VERIFYEXEC(imap.login("doe", "doe")); | ||
78 | VERIFYEXEC(imap.remove("INBOX." + folderPath.join('.'), "2:*")); | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | QTEST_MAIN(ImapMailSyncTest) | ||
83 | |||
84 | #include "imapmailsynctest.moc" | ||