diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 11:09:31 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 11:09:31 +0100 |
commit | d4b10a3de396eebc6c815093e9e1725ece270e9e (patch) | |
tree | baa77406ae79bedee9b74b836789c3370b1fa934 /tests/querytest.cpp | |
parent | ec902175d53d371b03d8e754d917e196cd15aafa (diff) | |
download | sink-d4b10a3de396eebc6c815093e9e1725ece270e9e.tar.gz sink-d4b10a3de396eebc6c815093e9e1725ece270e9e.zip |
Working folder tree query
Diffstat (limited to 'tests/querytest.cpp')
-rw-r--r-- | tests/querytest.cpp | 98 |
1 files changed, 66 insertions, 32 deletions
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index e4f1d0d..677dbac 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -90,38 +90,72 @@ private Q_SLOTS: | |||
90 | QTRY_COMPARE(model->rowCount(), 1); | 90 | QTRY_COMPARE(model->rowCount(), 1); |
91 | } | 91 | } |
92 | 92 | ||
93 | // void testTree() | 93 | void testFolder() |
94 | // { | 94 | { |
95 | // //Setup | 95 | //Setup |
96 | // { | 96 | { |
97 | // Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 97 | Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
98 | // Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 98 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
99 | // | 99 | } |
100 | // Akonadi2::Query query; | 100 | |
101 | // query.resources << "org.kde.dummy.instance1"; | 101 | //Test |
102 | // query.syncOnDemand = false; | 102 | Akonadi2::Query query; |
103 | // query.processAll = true; | 103 | query.resources << "org.kde.dummy.instance1"; |
104 | // | 104 | query.syncOnDemand = false; |
105 | // auto model = new ModelResult<Akonadi2::ApplicationDomain::Folder>(query, QList<QByteArray>() << "summary" << "uid"); | 105 | query.processAll = false; |
106 | // QTRY_COMPARE(model->rowCount(), 1); | 106 | query.liveQuery = true; |
107 | // | 107 | |
108 | // auto folderEntity = model->index(0, 0).data(ModelResult<Akonadi2::ApplicationDomain::Folder>::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder>(); | 108 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
109 | // | 109 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); |
110 | // Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); | 110 | model->fetchMore(QModelIndex()); |
111 | // subfolder.setProperty("parent", folderEntity.identifier()); | 111 | QTRY_COMPARE(model->rowCount(), 1); |
112 | // Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); | 112 | auto folderEntity = model->index(0, 0).data(ModelResult<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Folder::Ptr>::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); |
113 | // } | 113 | QVERIFY(!folderEntity->identifier().isEmpty()); |
114 | // | 114 | } |
115 | // //Test | 115 | |
116 | // Akonadi2::Query query; | 116 | void testFolderTree() |
117 | // query.resources << "org.kde.dummy.instance1"; | 117 | { |
118 | // query.syncOnDemand = false; | 118 | //Setup |
119 | // query.processAll = true; | 119 | { |
120 | // | 120 | Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
121 | // auto model = new ModelResult<Akonadi2::ApplicationDomain::Folder>(query, QList<QByteArray>() << "summary" << "uid"); | 121 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
122 | // QTRY_COMPARE(model->rowCount(), 1); | 122 | |
123 | // QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | 123 | Akonadi2::Query query; |
124 | // } | 124 | query.resources << "org.kde.dummy.instance1"; |
125 | query.syncOnDemand = false; | ||
126 | query.processAll = true; | ||
127 | |||
128 | //Ensure all local data is processed | ||
129 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
130 | |||
131 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | ||
132 | model->fetchMore(QModelIndex()); | ||
133 | QTRY_COMPARE(model->rowCount(), 1); | ||
134 | |||
135 | auto folderEntity = model->index(0, 0).data(ModelResult<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Folder::Ptr>::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | ||
136 | QVERIFY(!folderEntity->identifier().isEmpty()); | ||
137 | |||
138 | Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); | ||
139 | subfolder.setProperty("parent", folderEntity->identifier()); | ||
140 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); | ||
141 | } | ||
142 | |||
143 | //Test | ||
144 | Akonadi2::Query query; | ||
145 | query.resources << "org.kde.dummy.instance1"; | ||
146 | query.syncOnDemand = false; | ||
147 | query.processAll = true; | ||
148 | |||
149 | //Ensure all local data is processed | ||
150 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | ||
151 | |||
152 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | ||
153 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | ||
154 | model->fetchMore(QModelIndex()); | ||
155 | QTRY_COMPARE(model->rowCount(), 1); | ||
156 | model->fetchMore(model->index(0, 0)); | ||
157 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | ||
158 | } | ||
125 | }; | 159 | }; |
126 | 160 | ||
127 | QTEST_MAIN(QueryTest) | 161 | QTEST_MAIN(QueryTest) |