From 6434a87199b3259e9002570332beaa8caf5d2213 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 24 May 2016 09:20:02 +0200 Subject: A generic mailtest that can be applied to all resources that support mails. --- examples/imapresource/tests/CMakeLists.txt | 2 ++ examples/imapresource/tests/imapmailtest.cpp | 45 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 examples/imapresource/tests/imapmailtest.cpp (limited to 'examples/imapresource/tests') diff --git a/examples/imapresource/tests/CMakeLists.txt b/examples/imapresource/tests/CMakeLists.txt index 8482720..b10adcd 100644 --- a/examples/imapresource/tests/CMakeLists.txt +++ b/examples/imapresource/tests/CMakeLists.txt @@ -16,8 +16,10 @@ endmacro(auto_tests) auto_tests ( imapresourcetest imapserverproxytest + imapmailtest ) target_link_libraries(imapresourcetest sink_resource_imap) target_link_libraries(imapserverproxytest sink_resource_imap) +target_link_libraries(imapmailtest sink_test sink_resource_imap) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resetmailbox.sh DESTINATION bin PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ) diff --git a/examples/imapresource/tests/imapmailtest.cpp b/examples/imapresource/tests/imapmailtest.cpp new file mode 100644 index 0000000..82324af --- /dev/null +++ b/examples/imapresource/tests/imapmailtest.cpp @@ -0,0 +1,45 @@ +#include + +#include +#include "../imapresource.h" + +#include "common/test.h" +#include "common/domain/applicationdomaintype.h" + +using namespace Sink; +using namespace Sink::ApplicationDomain; + +/** + * Test of complete system using the imap resource. + * + * This test requires the imap resource installed. + */ +class ImapMailTest : public Sink::MailTest +{ + Q_OBJECT + +protected: + void resetTestEnvironment() Q_DECL_OVERRIDE + { + system("resetmailbox.sh"); + } + + Sink::ApplicationDomain::SinkResource createResource() Q_DECL_OVERRIDE + { + auto resource = ApplicationDomain::ImapResource::create("account1"); + resource.setProperty("server", "localhost"); + resource.setProperty("port", 993); + resource.setProperty("user", "doe"); + resource.setProperty("password", "doe"); + return resource; + } + + void removeResourceFromDisk(const QByteArray &identifier) Q_DECL_OVERRIDE + { + ::ImapResource::removeFromDisk(identifier); + } +}; + +QTEST_MAIN(ImapMailTest) + +#include "imapmailtest.moc" -- cgit v1.2.3