From 2cbbdaca7c6e96e40b17b6af4672af2b6735bf8e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 12 Apr 2016 22:03:27 +0200 Subject: Generalized LocalStorageFacade --- tests/accountstest.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/accountstest.cpp') diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index dc74d15..8062bc3 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp @@ -1,11 +1,13 @@ #include #include #include +#include #include #include #include #include +#include class AccountsTest : public QObject { @@ -18,6 +20,12 @@ private slots: Sink::Log::setDebugOutputLevel(Sink::Log::Trace); } + void init() + { + ConfigStore("accounts").clear(); + ConfigStore("resources").clear(); + } + void testLoad() { using namespace Sink; @@ -64,6 +72,32 @@ private slots: }) .exec().waitForFinished(); } + + void testLiveQuery() + { + using namespace Sink; + using namespace Sink::ApplicationDomain; + + auto account = ApplicationDomainType::createEntity(); + account.setProperty("type", "maildir"); + account.setProperty("name", "name"); + Store::create(account).exec().waitForFinished(); + + Query query; + query.liveQuery = true; + auto model = Store::loadModel(query); + QSignalSpy spy(model.data(), &QAbstractItemModel::rowsInserted); + QTRY_COMPARE(spy.count(), 1); + Store::create(account).exec().waitForFinished(); + QTRY_COMPARE(spy.count(), 2); + + //Ensure the notifier only affects one type + auto resource = ApplicationDomainType::createEntity(); + resource.setProperty("type", "org.kde.mailtransport"); + Store::create(resource).exec().waitForFinished(); + QTRY_COMPARE(spy.count(), 2); + } + }; QTEST_GUILESS_MAIN(AccountsTest) -- cgit v1.2.3