From d3cb4e649177443e8ecfd7f86d136fc0a319e2f3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 12 May 2017 14:00:54 +0200 Subject: Don't add resources that don't match the query during a livequery --- tests/querytest.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 72eca86..4ff1be8 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -625,6 +625,41 @@ private slots: // We fetch before the data is available and rely on the live query mechanism to deliver the actual data auto folders = Sink::Store::read(Sink::Query{}.resourceContainsFilter("cap1")); QCOMPARE(folders.size(), 1); + + //TODO this should be part of the regular cleanup between tests + VERIFYEXEC(Store::remove(resource1)); + VERIFYEXEC(Store::remove(resource2)); + } + + void testFilteredLiveResourceSubQuery() + { + using namespace Sink; + using namespace Sink::ApplicationDomain; + + //Setup + auto resource1 = ApplicationDomainType::createEntity(); + resource1.setResourceType("sink.dummy"); + resource1.setCapabilities(QByteArrayList() << "cap1"); + VERIFYEXEC(Store::create(resource1)); + VERIFYEXEC(Store::create(Folder{resource1.identifier()})); + VERIFYEXEC(ResourceControl::flushMessageQueue(resource1.identifier())); + + auto model = Sink::Store::loadModel(Query{Query::LiveQuery}.resourceContainsFilter("cap1")); + QTRY_COMPARE(model->rowCount(), 1); + + auto resource2 = ApplicationDomainType::createEntity(); + resource2.setCapabilities(QByteArrayList() << "cap2"); + resource2.setResourceType("sink.dummy"); + VERIFYEXEC(Store::create(resource2)); + VERIFYEXEC(Store::create(Folder{resource2.identifier()})); + VERIFYEXEC(ResourceControl::flushMessageQueue(resource2.identifier())); + + //The new resource should be filtered and thus not make it in here + QCOMPARE(model->rowCount(), 1); + + //TODO this should be part of the regular cleanup between tests + VERIFYEXEC(Store::remove(resource1)); + VERIFYEXEC(Store::remove(resource2)); } void testLivequeryUnmatchInThread() -- cgit v1.2.3