diff options
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
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: | |||
670 | QTRY_COMPARE(model->rowCount(), 0); | 670 | QTRY_COMPARE(model->rowCount(), 0); |
671 | } | 671 | } |
672 | 672 | ||
673 | void testDontUpdateNonLiveQuery() | ||
674 | { | ||
675 | // Setup | ||
676 | auto folder1 = Folder::createEntity<Folder>("sink.dummy.instance1"); | ||
677 | VERIFYEXEC(Sink::Store::create<Folder>(folder1)); | ||
678 | |||
679 | auto mail1 = Mail::createEntity<Mail>("sink.dummy.instance1"); | ||
680 | mail1.setExtractedMessageId("mail1"); | ||
681 | mail1.setFolder(folder1); | ||
682 | mail1.setUnread(false); | ||
683 | VERIFYEXEC(Sink::Store::create(mail1)); | ||
684 | |||
685 | // Ensure all local data is processed | ||
686 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | ||
687 | |||
688 | Query query; | ||
689 | //Not a live query | ||
690 | query.setFlags(Query::Flags{}); | ||
691 | query.setId("testNoLiveQuery"); | ||
692 | query.filter<Mail::Folder>(folder1); | ||
693 | query.reduce<Mail::ThreadId>(Query::Reduce::Selector::max<Mail::Date>()).count("count").collect<Mail::Sender>("senders"); | ||
694 | query.sort<Mail::Date>(); | ||
695 | query.request<Mail::Unread>(); | ||
696 | QVERIFY(!query.liveQuery()); | ||
697 | |||
698 | auto model = Sink::Store::loadModel<Mail>(query); | ||
699 | QTRY_COMPARE(model->rowCount(), 1); | ||
700 | |||
701 | //After the modifcation the mail should have vanished. | ||
702 | { | ||
703 | mail1.setUnread(true); | ||
704 | VERIFYEXEC(Sink::Store::modify(mail1)); | ||
705 | } | ||
706 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | ||
707 | QTRY_COMPARE(model->rowCount(), 1); | ||
708 | auto mail = model->data(model->index(0, 0, QModelIndex{}), Sink::Store::DomainObjectRole).value<Mail::Ptr>(); | ||
709 | QTest::qWait(100); | ||
710 | QCOMPARE(mail->getUnread(), false); | ||
711 | } | ||
712 | |||
673 | void testLivequeryModifcationUpdateInThread() | 713 | void testLivequeryModifcationUpdateInThread() |
674 | { | 714 | { |
675 | // Setup | 715 | // Setup |