diff options
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 1ba37f4..e09f7a4 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -106,6 +106,39 @@ private Q_SLOTS: | |||
106 | QCOMPARE(model->rowCount(), 1); | 106 | QCOMPARE(model->rowCount(), 1); |
107 | } | 107 | } |
108 | 108 | ||
109 | void testById() | ||
110 | { | ||
111 | QByteArray id; | ||
112 | //Setup | ||
113 | { | ||
114 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | ||
115 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | ||
116 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | ||
117 | |||
118 | Akonadi2::Query query; | ||
119 | query.resources << "org.kde.dummy.instance1"; | ||
120 | |||
121 | //Ensure all local data is processed | ||
122 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
123 | |||
124 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | ||
125 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
126 | model->fetchMore(QModelIndex()); | ||
127 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
128 | QVERIFY(model->rowCount() >= 1); | ||
129 | id = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>()->identifier(); | ||
130 | } | ||
131 | |||
132 | //Test | ||
133 | Akonadi2::Query query; | ||
134 | query.resources << "org.kde.dummy.instance1"; | ||
135 | query.ids << id; | ||
136 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
137 | model->fetchMore(QModelIndex()); | ||
138 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | ||
139 | QCOMPARE(model->rowCount(), 1); | ||
140 | } | ||
141 | |||
109 | void testFolder() | 142 | void testFolder() |
110 | { | 143 | { |
111 | //Setup | 144 | //Setup |