From a372d9cc6c950beb401aef9005f97faeaf95b804 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 9 Feb 2017 15:17:54 +0100 Subject: Fixed query flags. --- tests/querytest.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 0d3ffc3..0641c0d 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp @@ -670,6 +670,46 @@ private slots: QTRY_COMPARE(model->rowCount(), 0); } + void testDontUpdateNonLiveQuery() + { + // Setup + auto folder1 = Folder::createEntity("sink.dummy.instance1"); + VERIFYEXEC(Sink::Store::create(folder1)); + + auto mail1 = Mail::createEntity("sink.dummy.instance1"); + mail1.setExtractedMessageId("mail1"); + mail1.setFolder(folder1); + mail1.setUnread(false); + VERIFYEXEC(Sink::Store::create(mail1)); + + // Ensure all local data is processed + VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); + + Query query; + //Not a live query + query.setFlags(Query::Flags{}); + query.setId("testNoLiveQuery"); + query.filter(folder1); + query.reduce(Query::Reduce::Selector::max()).count("count").collect("senders"); + query.sort(); + query.request(); + QVERIFY(!query.liveQuery()); + + auto model = Sink::Store::loadModel(query); + QTRY_COMPARE(model->rowCount(), 1); + + //After the modifcation the mail should have vanished. + { + mail1.setUnread(true); + VERIFYEXEC(Sink::Store::modify(mail1)); + } + VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); + QTRY_COMPARE(model->rowCount(), 1); + auto mail = model->data(model->index(0, 0, QModelIndex{}), Sink::Store::DomainObjectRole).value(); + QTest::qWait(100); + QCOMPARE(mail->getUnread(), false); + } + void testLivequeryModifcationUpdateInThread() { // Setup -- cgit v1.2.3