Changeset View
Changeset View
Standalone View
Standalone View
autotests/ResultSetTest.cpp
Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 139 | ResultSet result(UsedResources | |||
---|---|---|---|---|---|
141 | | Agent::any() | 141 | | Agent::any() | ||
142 | | Activity::any() | 142 | | Activity::any() | ||
143 | ); | 143 | ); | ||
144 | 144 | | |||
145 | QCOMPARE(result.at(0).resource(), QStringLiteral("/path/high1_act1_gvim")); | 145 | QCOMPARE(result.at(0).resource(), QStringLiteral("/path/high1_act1_gvim")); | ||
146 | QCOMPARE(result.at(1).resource(), QStringLiteral("/path/high2_act2_kate")); | 146 | QCOMPARE(result.at(1).resource(), QStringLiteral("/path/high2_act2_kate")); | ||
147 | QCOMPARE(result.at(2).resource(), QStringLiteral("/path/high3_act1_kate")); | 147 | QCOMPARE(result.at(2).resource(), QStringLiteral("/path/high3_act1_kate")); | ||
148 | } | 148 | } | ||
149 | | ||||
150 | TEST_CHUNK(QStringLiteral("Getting the used resources filter by Date")) | ||||
151 | { | ||||
152 | ResultSet result(UsedResources | ||||
153 | | HighScoredFirst | ||||
154 | | Agent::any() | ||||
155 | | Activity::any() | ||||
156 | | Date::fromString(QStringLiteral("2015-01-15")) | ||||
157 | ); | ||||
158 | | ||||
159 | QCOMPARE(result.at(0).resource(), QStringLiteral("/path/high1_act1_gvim")); | ||||
160 | } | ||||
149 | } | 161 | } | ||
150 | 162 | | |||
151 | void ResultSetTest::initTestCase() | 163 | void ResultSetTest::initTestCase() | ||
152 | { | 164 | { | ||
153 | QTemporaryDir dir(QDir::tempPath() + QStringLiteral("/KActivitiesStatsTest_ResultSetTest_XXXXXX")); | 165 | QTemporaryDir dir(QDir::tempPath() + QStringLiteral("/KActivitiesStatsTest_ResultSetTest_XXXXXX")); | ||
154 | dir.setAutoRemove(false); | 166 | dir.setAutoRemove(false); | ||
155 | 167 | | |||
156 | if (!dir.isValid()) { | 168 | if (!dir.isValid()) { | ||
Show All 30 Lines | 183 | database->execQuery( | |||
187 | " , ('activity2' , 'gvim' , '/path/mid5_act2_gvim' , '0' , '79' , '-1' , '1421439118')" | 199 | " , ('activity2' , 'gvim' , '/path/mid5_act2_gvim' , '0' , '79' , '-1' , '1421439118')" | ||
188 | " , ('activity1' , ':global' , '/path/mid6_act1_glob' , '0' , '20' , '-1' , '1421439331')" | 200 | " , ('activity1' , ':global' , '/path/mid6_act1_glob' , '0' , '20' , '-1' , '1421439331')" | ||
189 | " , ('activity1' , ':global' , '/path/mid7_act1_glob' , '0' , '8' , '-1' , '0')" | 201 | " , ('activity1' , ':global' , '/path/mid7_act1_glob' , '0' , '8' , '-1' , '0')" | ||
190 | " , ('activity1' , ':global' , '/path/mid8_act1_glob' , '0' , '7' , '-1' , '1421432617')" | 202 | " , ('activity1' , ':global' , '/path/mid8_act1_glob' , '0' , '7' , '-1' , '1421432617')" | ||
191 | 203 | | |||
192 | " , ('activity1' , 'gvim' , '/path/low3_act1_gvim' , '0' , '6' , '-1' , '1421434704')" | 204 | " , ('activity1' , 'gvim' , '/path/low3_act1_gvim' , '0' , '6' , '-1' , '1421434704')" | ||
193 | " , ('activity1' , 'kate' , '/path/low2_act1_kate' , '0' , '3' , '-1' , '1421433266')" | 205 | " , ('activity1' , 'kate' , '/path/low2_act1_kate' , '0' , '3' , '-1' , '1421433266')" | ||
194 | " , ('activity1' , 'kate' , '/path/low1_act1_kate' , '0' , '2' , '-1' , '1421433254')") | 206 | " , ('activity1' , 'kate' , '/path/low1_act1_kate' , '0' , '2' , '-1' , '1421433254')") | ||
207 | ); | ||||
195 | 208 | | |||
209 | database->execQuery( | ||||
210 | QStringLiteral("INSERT INTO ResourceEvent (usedActivity, initiatingAgent, targettedResource, start, end ) VALUES" | ||||
211 | "('activity1' , 'gvim' , '/path/high1_act1_gvim' , '1421345799', '1421345799')") | ||||
212 | ); | ||||
213 | | ||||
214 | database->execQuery( | ||||
215 | QStringLiteral("INSERT INTO ResourceInfo (targettedResource, title, mimetype, autoTitle, autoMimetype) VALUES" | ||||
216 | "('/path/high1_act1_gvim', 'high1_act1_gvim', 'text/plain', 1, 1 )") | ||||
196 | ); | 217 | ); | ||
197 | 218 | | |||
198 | // Renaming the activity1 to the current acitivty | 219 | // Renaming the activity1 to the current acitivty | ||
199 | KActivities::Consumer kamd; | 220 | KActivities::Consumer kamd; | ||
200 | 221 | | |||
201 | while (kamd.serviceStatus() == KActivities::Consumer::Unknown) { | 222 | while (kamd.serviceStatus() == KActivities::Consumer::Unknown) { | ||
202 | QCoreApplication::processEvents(); | 223 | QCoreApplication::processEvents(); | ||
203 | } | 224 | } | ||
204 | 225 | | |||
205 | database->execQuery( | 226 | database->execQuery( | ||
206 | QStringLiteral("UPDATE ResourceScoreCache SET usedActivity = '") | 227 | QStringLiteral("UPDATE ResourceScoreCache SET usedActivity = '") | ||
207 | + kamd.currentActivity() | 228 | + kamd.currentActivity() | ||
208 | + QStringLiteral("' WHERE usedActivity = 'activity1'")); | 229 | + QStringLiteral("' WHERE usedActivity = 'activity1'")); | ||
209 | 230 | | |||
231 | database->execQuery( | ||||
232 | QStringLiteral("UPDATE ResourceEvent SET usedActivity = '") | ||||
233 | + kamd.currentActivity() | ||||
234 | + QStringLiteral("' WHERE usedActivity = 'activity1'")); | ||||
235 | | ||||
210 | 236 | | |||
211 | database->execQuery( | 237 | database->execQuery( | ||
212 | QStringLiteral("INSERT INTO ResourceLink (usedActivity, initiatingAgent, targettedResource) VALUES " | 238 | QStringLiteral("INSERT INTO ResourceLink (usedActivity, initiatingAgent, targettedResource) VALUES " | ||
213 | 239 | | |||
214 | "('activity1' , 'gvim' , '/path/mid1_a1')" | 240 | "('activity1' , 'gvim' , '/path/mid1_a1')" | ||
215 | ", ('activity1' , 'gvim' , '/path/mid2_a1')" | 241 | ", ('activity1' , 'gvim' , '/path/mid2_a1')" | ||
216 | ", ('activity2' , 'gvim' , '/path/mid3_a2')" | 242 | ", ('activity2' , 'gvim' , '/path/mid3_a2')" | ||
217 | ", ('activity2' , 'gvim' , '/path/mid4_a2')" | 243 | ", ('activity2' , 'gvim' , '/path/mid4_a2')" | ||
Show All 13 Lines |