diff options
Diffstat (limited to 'examples/mailtransportresource/tests/mailtransporttest.cpp')
-rw-r--r-- | examples/mailtransportresource/tests/mailtransporttest.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/examples/mailtransportresource/tests/mailtransporttest.cpp b/examples/mailtransportresource/tests/mailtransporttest.cpp index 23a61b8..a30fc20 100644 --- a/examples/mailtransportresource/tests/mailtransporttest.cpp +++ b/examples/mailtransportresource/tests/mailtransporttest.cpp | |||
@@ -59,7 +59,7 @@ private slots: | |||
59 | { | 59 | { |
60 | auto message = KMime::Message::Ptr::create(); | 60 | auto message = KMime::Message::Ptr::create(); |
61 | message->messageID(true)->generate("foo.com"); | 61 | message->messageID(true)->generate("foo.com"); |
62 | message->subject(true)->fromUnicodeString(QString::fromLatin1("Foobar"), "utf8"); | 62 | message->subject(true)->fromUnicodeString(QString::fromLatin1("send: Foobar"), "utf8"); |
63 | message->assemble(); | 63 | message->assemble(); |
64 | 64 | ||
65 | auto mail = ApplicationDomain::Mail::create(mResourceInstanceIdentifier); | 65 | auto mail = ApplicationDomain::Mail::create(mResourceInstanceIdentifier); |
@@ -83,7 +83,37 @@ private slots: | |||
83 | QVERIFY(!mailInSentMailFolder.getSubject().isEmpty()); | 83 | QVERIFY(!mailInSentMailFolder.getSubject().isEmpty()); |
84 | } | 84 | } |
85 | 85 | ||
86 | //TODO test mail that fails to be sent. add a special header to the mail and have the resource fail sending. Ensure we can modify the mail to fix sending of the message. | 86 | void testSendFailure() |
87 | { | ||
88 | auto message = KMime::Message::Ptr::create(); | ||
89 | message->messageID(true)->generate("foo.com"); | ||
90 | message->subject(true)->fromUnicodeString(QString::fromLatin1("error: Foobar"), "utf8"); | ||
91 | message->assemble(); | ||
92 | |||
93 | auto mail = ApplicationDomain::Mail::create(mResourceInstanceIdentifier); | ||
94 | mail.setMimeMessage(message->encodedContent()); | ||
95 | |||
96 | VERIFYEXEC(Store::create(mail)); | ||
97 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | ||
98 | |||
99 | //Ensure the mail is queryable in the outbox | ||
100 | auto mailInOutbox = Store::readOne<ApplicationDomain::Mail>(Query().resourceFilter(mResourceInstanceIdentifier).filter<Mail::Sent>(false)); | ||
101 | QVERIFY(!mailInOutbox.identifier().isEmpty()); | ||
102 | |||
103 | //Modify back to drafts | ||
104 | auto modifiedMail = mailInOutbox; | ||
105 | modifiedMail.setDraft(true); | ||
106 | VERIFYEXEC(Store::modify(modifiedMail)); | ||
107 | VERIFYEXEC(ResourceControl::flushMessageQueue(QByteArrayList() << mResourceInstanceIdentifier)); | ||
108 | |||
109 | QTest::qWait(100); | ||
110 | // auto mailsInOutbox = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mResourceInstanceIdentifier)); | ||
111 | // QCOMPARE(mailsInOutbox.size(), 0); | ||
112 | |||
113 | auto mailsInDrafts = Store::read<ApplicationDomain::Mail>(Query().resourceFilter(mStorageResource)); | ||
114 | QCOMPARE(mailsInDrafts.size(), 1); | ||
115 | |||
116 | } | ||
87 | 117 | ||
88 | }; | 118 | }; |
89 | 119 | ||