diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-09 15:17:54 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-13 19:42:38 +0100 |
commit | a372d9cc6c950beb401aef9005f97faeaf95b804 (patch) | |
tree | b5ee62d5c554cf613c3bbb720bf2ee49b41d9026 | |
parent | 516d38bd7bca5562ebb7b21b96a5dd62152ee52e (diff) | |
download | sink-a372d9cc6c950beb401aef9005f97faeaf95b804.tar.gz sink-a372d9cc6c950beb401aef9005f97faeaf95b804.zip |
Fixed query flags.
-rw-r--r-- | common/query.h | 5 | ||||
-rw-r--r-- | tests/querytest.cpp | 40 |
2 files changed, 43 insertions, 2 deletions
diff --git a/common/query.h b/common/query.h index 50e93de..8e9050d 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -296,10 +296,11 @@ class SINK_EXPORT Query : public QueryBase | |||
296 | public: | 296 | public: |
297 | enum Flag | 297 | enum Flag |
298 | { | 298 | { |
299 | NoFlags = 0, | ||
299 | /** Leave the query running and continuously update the result set. */ | 300 | /** Leave the query running and continuously update the result set. */ |
300 | LiveQuery, | 301 | LiveQuery = 1, |
301 | /** Run the query synchronously. */ | 302 | /** Run the query synchronously. */ |
302 | SynchronousQuery | 303 | SynchronousQuery = 2 |
303 | }; | 304 | }; |
304 | Q_DECLARE_FLAGS(Flags, Flag) | 305 | Q_DECLARE_FLAGS(Flags, Flag) |
305 | 306 | ||
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 |