summaryrefslogtreecommitdiffstats
path: root/tests/accountstest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 14:30:37 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-08 14:30:37 +0200
commitdb8f328bde01d24bf9271638f8295fc70c68cdd4 (patch)
tree368dbc4895ae3f653d4ba42163780791888b5125 /tests/accountstest.cpp
parentd099ece17c6707af477b91dee9ced13b0f7e962a (diff)
downloadsink-db8f328bde01d24bf9271638f8295fc70c68cdd4.tar.gz
sink-db8f328bde01d24bf9271638f8295fc70c68cdd4.zip
Account status
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r--tests/accountstest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp
index 8d0f2e6..4be8bd6 100644
--- a/tests/accountstest.cpp
+++ b/tests/accountstest.cpp
@@ -8,6 +8,7 @@
8#include <store.h> 8#include <store.h>
9#include <log.h> 9#include <log.h>
10#include <configstore.h> 10#include <configstore.h>
11#include "testutils.h"
11 12
12class AccountsTest : public QObject 13class AccountsTest : public QObject
13{ 14{
@@ -115,6 +116,35 @@ private slots:
115 QTRY_COMPARE(model->rowCount(QModelIndex()), 2); 116 QTRY_COMPARE(model->rowCount(QModelIndex()), 2);
116 } 117 }
117 118
119 void testLoadAccountStatus()
120 {
121 using namespace Sink;
122 using namespace Sink::ApplicationDomain;
123
124 auto account = ApplicationDomainType::createEntity<SinkAccount>();
125 account.setAccountType("dummy");
126 account.setName("name");
127 VERIFYEXEC(Store::create(account));
128
129 auto res = Sink::ApplicationDomain::DummyResource::create(account.identifier());
130 VERIFYEXEC(Sink::Store::create(res));
131 {
132 Sink::Query query;
133 query.liveQuery = true;
134 query.request<Sink::ApplicationDomain::SinkAccount::Status>();
135
136 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query);
137 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
138 auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>();
139 QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus));
140
141 //Synchronize to connect
142 VERIFYEXEC(Sink::Store::synchronize(Query::ResourceFilter(res)));
143
144 QTRY_COMPARE_WITH_TIMEOUT(model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>()->getStatus(), static_cast<int>(Sink::ApplicationDomain::ConnectedStatus), 1000);
145 }
146 }
147
118}; 148};
119 149
120QTEST_GUILESS_MAIN(AccountsTest) 150QTEST_GUILESS_MAIN(AccountsTest)