From f3eb97b9b4aabef41d8bc6514c74d85600e60d7f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 2 Sep 2017 15:59:51 -0600 Subject: Ensure we monitor resources for status changes that have been created after the query. This fixes status monitoring when creating a new account. --- tests/accountstest.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') 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: } } + void testLoadAccountStatusLive() + { + using namespace Sink; + using namespace Sink::ApplicationDomain; + + { + //Create a live query for all accounts + Sink::Query query; + query.setFlags(Query::LiveQuery); + query.request(); + + auto model = Sink::Store::loadModel(query); + + //Create the account + auto account = ApplicationDomainType::createEntity(); + account.setAccountType("dummy"); + account.setName("name"); + VERIFYEXEC(Store::create(account)); + + auto res = Sink::ApplicationDomain::DummyResource::create(account.identifier()); + VERIFYEXEC(Sink::Store::create(res)); + + //Ensure the account was created + QTRY_COMPARE(model->rowCount(QModelIndex()), 1); + auto retrievedAccount = model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value(); + QCOMPARE(retrievedAccount->getStatus(), static_cast(Sink::ApplicationDomain::NoStatus)); + + //Synchronize to connect and ensure we receive the update + VERIFYEXEC(Sink::Store::synchronize(Query().resourceFilter(res.identifier()))); + + QTRY_COMPARE_WITH_TIMEOUT(model->data(model->index(0, 0, QModelIndex()), Sink::Store::DomainObjectRole).value()->getStatus(), static_cast(Sink::ApplicationDomain::ConnectedStatus), 1000); + } + } + }; QTEST_GUILESS_MAIN(AccountsTest) -- cgit v1.2.3