summaryrefslogtreecommitdiffstats
path: root/tests/accountstest.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-13 12:42:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-09-13 12:42:31 +0200
commitc12a9a09da59b9e418316dba02e6215cb55e47ee (patch)
tree05498d9a42e399bcca787f40c1fc473fb09e680e /tests/accountstest.cpp
parent55fe06979ceebe67553135b43aa47e70d931304b (diff)
parentebdb89b8bb482bbb5ecd544c3d38bef35fc7d820 (diff)
downloadsink-c12a9a09da59b9e418316dba02e6215cb55e47ee.tar.gz
sink-c12a9a09da59b9e418316dba02e6215cb55e47ee.zip
Merge commit 'ebdb89b8bb482bbb5ecd544c3d38bef35fc7d820'v0.4.0
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r--tests/accountstest.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp
index 0ab18ef..2eee9f9 100644
--- a/tests/accountstest.cpp
+++ b/tests/accountstest.cpp
@@ -139,7 +139,7 @@ private slots:
139 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query); 139 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query);
140 QTRY_COMPARE(model->rowCount(QModelIndex()), 1); 140 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
141 auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>(); 141 auto account = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>();
142 QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::OfflineStatus)); 142 QCOMPARE(account->getStatus(), static_cast<int>(Sink::ApplicationDomain::NoStatus));
143 143
144 //Synchronize to connect 144 //Synchronize to connect
145 VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier()))); 145 VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier())));
@@ -148,6 +148,40 @@ private slots:
148 } 148 }
149 } 149 }
150 150
151 void testLoadAccountStatusLive()
152 {
153 using namespace Sink;
154 using namespace Sink::ApplicationDomain;
155
156 {
157 //Create a live query for all accounts
158 Sink::Query query;
159 query.setFlags(Query::LiveQuery);
160 query.request<Sink::ApplicationDomain::SinkAccount::Status>();
161
162 auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query);
163
164 //Create the account
165 auto account = ApplicationDomainType::createEntity<SinkAccount>();
166 account.setAccountType("dummy");
167 account.setName("name");
168 VERIFYEXEC(Store::create(account));
169
170 auto res = Sink::ApplicationDomain::DummyResource::create(account.identifier());
171 VERIFYEXEC(Sink::Store::create(res));
172
173 //Ensure the account was created
174 QTRY_COMPARE(model->rowCount(QModelIndex()), 1);
175 auto retrievedAccount = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>();
176 QCOMPARE(retrievedAccount->getStatus(), static_cast<int>(Sink::ApplicationDomain::NoStatus));
177
178 //Synchronize to connect and ensure we receive the update
179 VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier())));
180
181 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);
182 }
183 }
184
151}; 185};
152 186
153QTEST_GUILESS_MAIN(AccountsTest) 187QTEST_GUILESS_MAIN(AccountsTest)