From c1537e04e922bd8cb1d9a62670698d712ead657f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 3 Jan 2017 00:06:51 +0100 Subject: React to removals in reduced live-query. --- tests/querytest.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 574e68d..46181a6 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -632,6 +632,41 @@ private slots: auto folders = Sink::Store::read(query); QCOMPARE(folders.size(), 1); } + void testLivequeryUnmatchInThread() + { + // Setup + auto folder1 = Folder::createEntity("sink.dummy.instance1"); + VERIFYEXEC(Sink::Store::create(folder1)); + + auto folder2 = Folder::createEntity("sink.dummy.instance1"); + VERIFYEXEC(Sink::Store::create(folder2)); + + auto mail1 = Mail::createEntity("sink.dummy.instance1"); + mail1.setUid("mail1"); + mail1.setFolder(folder1); + VERIFYEXEC(Sink::Store::create(mail1)); + // Ensure all local data is processed + VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); + + //Setup two folders with a mail each, ensure we only get the mail from the folder that matches the folder filter. + Query query; + query.setId("testLivequeryUnmatch"); + query.filter(folder1); + query.reduce(Query::Reduce::Selector::max()).count("count").collect("senders"); + query.sort(); + query.setFlags(Query::LiveQuery); + auto model = Sink::Store::loadModel(query); + QTRY_COMPARE(model->rowCount(), 1); + + //After the modifcation the mail should have vanished. + { + + mail1.setFolder(folder2); + VERIFYEXEC(Sink::Store::modify(mail1)); + } + VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); + QTRY_COMPARE(model->rowCount(), 0); + } }; QTEST_MAIN(QueryTest) -- cgit v1.2.3