From e06e1dad4a4570e5c1181d05ab6ed7a5d74c6c91 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 3 May 2016 20:24:09 +0200 Subject: A save-as-draft action & action results This patch introduces tracking of actions, so they can be tested. It also provides a save-as-draft action, that looks for the draft folder, and stores the mail accordingly. --- framework/domain/actions/tests/sinkactiontest.cpp | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 framework/domain/actions/tests/sinkactiontest.cpp (limited to 'framework/domain/actions/tests/sinkactiontest.cpp') diff --git a/framework/domain/actions/tests/sinkactiontest.cpp b/framework/domain/actions/tests/sinkactiontest.cpp new file mode 100644 index 00000000..3e4567fd --- /dev/null +++ b/framework/domain/actions/tests/sinkactiontest.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace Sink; + +class SinkActionTest : public QObject +{ + Q_OBJECT +private slots: + + void initTestCase() + { + Sink::Test::initTest(); + Sink::Log::setDebugOutputLevel(Sink::Log::Trace); + } + + void testSaveAsDraftFail() + { + Kube::Context context; + auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); + + QTRY_VERIFY(future.isDone()); + //because of empty context + QVERIFY(future.error()); + } + + void testSaveAsDraftNew() + { + auto message = KMime::Message::Ptr::create(); + message->subject(true)->fromUnicodeString(QString::fromLatin1("Foobar"), "utf8"); + message->assemble(); + + auto &&account = Test::TestAccount::registerAccount(); + auto folder = account.createEntity(); + folder->setProperty("specialpurpose", QVariant::fromValue(QByteArrayList() << "drafts")); + + Kube::Context context; + context.setProperty("message", QVariant::fromValue(message)); + context.setProperty("accountId", QVariant::fromValue(account.identifier)); + auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); + + QTRY_VERIFY(future.isDone()); + QVERIFY(!future.error()); + auto mails = account.entities(); + QCOMPARE(mails.size(), 1); + auto mail = mails.first(); + QCOMPARE(mail->getProperty("folder").toByteArray(), folder->identifier()); + } +}; + +QTEST_GUILESS_MAIN(SinkActionTest) +#include "sinkactiontest.moc" -- cgit v1.2.3