diff options
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r-- | tests/accountstest.cpp | 30 |
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 | ||
12 | class AccountsTest : public QObject | 13 | class 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 | ||
120 | QTEST_GUILESS_MAIN(AccountsTest) | 150 | QTEST_GUILESS_MAIN(AccountsTest) |