From 9f5e4a488360c2c0232a12b65e9d1c8366c0bc8b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sun, 10 Apr 2016 22:33:57 +0200 Subject: accountstest and a way to create new entities --- tests/CMakeLists.txt | 1 + tests/accountstest.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/accountstest.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8045f59..b25e7bc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -54,6 +54,7 @@ auto_tests ( dummyresourcewritebenchmark modelinteractivitytest inspectiontest + accountstest ) target_link_libraries(dummyresourcetest sink_resource_dummy) target_link_libraries(dummyresourcebenchmark sink_resource_dummy) diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp new file mode 100644 index 0000000..0ae10ec --- /dev/null +++ b/tests/accountstest.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#include +#include + +class AccountsTest : public QObject +{ + Q_OBJECT +private slots: + + void initTestCase() + { + Sink::Test::initTest(); + } + + void testLoad() + { + using namespace Sink; + using namespace Sink::ApplicationDomain; + + QString accountName("name"); + QString accountIcon("icon"); + auto account = ApplicationDomainType::createEntity(); + account.setProperty("type", "maildir"); + account.setProperty("name", accountName); + account.setProperty("icon", accountIcon); + Store::create(account).exec().waitForFinished(); + + Store::fetchAll(Query()).then>([](const QList &accounts) { + QCOMPARE(accounts.size(), 1); + }) + .exec().waitForFinished(); + + QString smtpServer("smtpServer"); + QString smtpUsername("smtpUsername"); + QString smtpPassword("smtpPassword"); + auto resource = ApplicationDomainType::createEntity(); + resource.setProperty("type", "org.kde.mailtransport"); + resource.setProperty("account", account.identifier()); + resource.setProperty("server", smtpServer); + resource.setProperty("username", smtpUsername); + resource.setProperty("password", smtpPassword); + Store::create(resource).exec().waitForFinished(); + + + Store::fetchAll(Query()).then>([](const QList &resources) { + QCOMPARE(resources.size(), 1); + }) + .exec().waitForFinished(); + + Store::remove(resource).exec().waitForFinished(); + + Store::fetchAll(Query()).then>([](const QList &resources) { + QCOMPARE(resources.size(), 0); + }) + .exec().waitForFinished(); + } +}; + +QTEST_GUILESS_MAIN(AccountsTest) +#include "accountstest.moc" -- cgit v1.2.3