diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-02 15:59:51 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-02 15:59:51 -0600 |
commit | f3eb97b9b4aabef41d8bc6514c74d85600e60d7f (patch) | |
tree | fe0caaf199c4856b22815f265a62316ae7d895e8 /tests/accountstest.cpp | |
parent | 6bfcc22e08aebbabeac3e2ccb61556439d9f4b56 (diff) | |
download | sink-f3eb97b9b4aabef41d8bc6514c74d85600e60d7f.tar.gz sink-f3eb97b9b4aabef41d8bc6514c74d85600e60d7f.zip |
Ensure we monitor resources for status changes that have been created
after the query.
This fixes status monitoring when creating a new account.
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r-- | tests/accountstest.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index cc67645..2eee9f9 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp | |||
@@ -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 | ||
153 | QTEST_GUILESS_MAIN(AccountsTest) | 187 | QTEST_GUILESS_MAIN(AccountsTest) |