Merge lp:~rainct/zeitgeist/fts-current-uri into lp:~zeitgeist/zeitgeist/bluebird
- fts-current-uri
- Merge into bluebird
Proposed by
Siegfried Gevatter
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 431 |
Merged at revision: | 431 |
Proposed branch: | lp:~rainct/zeitgeist/fts-current-uri |
Merge into: | lp:~zeitgeist/zeitgeist/bluebird |
Diff against target: |
859 lines (+317/-244) 3 files modified
extensions/fts++/indexer.cpp (+16/-6) extensions/fts++/test/test-indexer.cpp (+300/-237) test/dbus/engine-test.py (+1/-1) |
To merge this branch: | bzr merge lp:~rainct/zeitgeist/fts-current-uri |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michal Hruby (community) | Approve | ||
Review via email: mp+97655@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Siegfried Gevatter (rainct) wrote : | # |
Revision history for this message
Michal Hruby (mhr3) wrote : | # |
The boolean terms we're adding to the document should also use current_uri. As for CompileEventFil
review:
Needs Fixing
- 429. By Siegfried Gevatter
-
FTS++: Change to current_uri in some more places. Add random test cases.
- 430. By Siegfried Gevatter
-
FTS++: some more test cases and add a couple utility functions
- 431. By Siegfried Gevatter
-
FTS++: more test stuff (add more asserts, extend {Most,Least}Recent tests,
introduce new helper function)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'extensions/fts++/indexer.cpp' | |||
2 | --- extensions/fts++/indexer.cpp 2012-03-14 12:31:51 +0000 | |||
3 | +++ extensions/fts++/indexer.cpp 2012-03-16 18:46:19 +0000 | |||
4 | @@ -262,7 +262,10 @@ | |||
5 | 262 | for (unsigned j = 0; j < subjects->len; j++) | 262 | for (unsigned j = 0; j < subjects->len; j++) |
6 | 263 | { | 263 | { |
7 | 264 | ZeitgeistSubject *subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, j); | 264 | ZeitgeistSubject *subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, j); |
8 | 265 | // For backwards compatibility, we still check URI | ||
9 | 265 | val = zeitgeist_subject_get_uri (subject); | 266 | val = zeitgeist_subject_get_uri (subject); |
10 | 267 | if (!val || val[0] == '\0') | ||
11 | 268 | val = zeitgeist_subject_get_current_uri (subject); | ||
12 | 266 | if (val && val[0] != '\0') | 269 | if (val && val[0] != '\0') |
13 | 267 | tmpl.push_back ("zgsu:" + StringUtils::MangleUri (val)); | 270 | tmpl.push_back ("zgsu:" + StringUtils::MangleUri (val)); |
14 | 268 | 271 | ||
15 | @@ -344,7 +347,7 @@ | |||
16 | 344 | for (unsigned j = 0; j < subjects->len; j++) | 347 | for (unsigned j = 0; j < subjects->len; j++) |
17 | 345 | { | 348 | { |
18 | 346 | ZeitgeistSubject *subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, j); | 349 | ZeitgeistSubject *subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, j); |
20 | 347 | val = zeitgeist_subject_get_uri (subject); | 350 | val = zeitgeist_subject_get_current_uri (subject); |
21 | 348 | if (val && val[0] != '\0') | 351 | if (val && val[0] != '\0') |
22 | 349 | doc.add_boolean_term (StringUtils::Truncate (FILTER_PREFIX_SUBJECT_URI + StringUtils::MangleUri (val))); | 352 | doc.add_boolean_term (StringUtils::Truncate (FILTER_PREFIX_SUBJECT_URI + StringUtils::MangleUri (val))); |
23 | 350 | 353 | ||
24 | @@ -928,12 +931,13 @@ | |||
25 | 928 | if (subjects == NULL) continue; | 931 | if (subjects == NULL) continue; |
26 | 929 | for (unsigned j = 0; j < subjects->len; j++) | 932 | for (unsigned j = 0; j < subjects->len; j++) |
27 | 930 | { | 933 | { |
29 | 931 | const gchar *subj_uri = zeitgeist_subject_get_uri ((ZeitgeistSubject*) subjects->pdata[j]); | 934 | const gchar *subj_uri = zeitgeist_subject_get_current_uri ( |
30 | 935 | (ZeitgeistSubject*) subjects->pdata[j]); | ||
31 | 932 | if (subj_uri == NULL) continue; | 936 | if (subj_uri == NULL) continue; |
32 | 933 | remapper[subj_uri] = event_id; | 937 | remapper[subj_uri] = event_id; |
33 | 934 | ZeitgeistEvent *event = zeitgeist_event_new (); | 938 | ZeitgeistEvent *event = zeitgeist_event_new (); |
34 | 935 | ZeitgeistSubject *subject = zeitgeist_subject_new (); | 939 | ZeitgeistSubject *subject = zeitgeist_subject_new (); |
36 | 936 | zeitgeist_subject_set_uri (subject, subj_uri); | 940 | zeitgeist_subject_set_current_uri (subject, subj_uri); |
37 | 937 | zeitgeist_event_add_subject (event, subject); // FIXME: leaks? | 941 | zeitgeist_event_add_subject (event, subject); // FIXME: leaks? |
38 | 938 | g_ptr_array_add (event_templates, event); | 942 | g_ptr_array_add (event_templates, event); |
39 | 939 | } | 943 | } |
40 | @@ -976,7 +980,8 @@ | |||
41 | 976 | if (subjects == NULL) continue; | 980 | if (subjects == NULL) continue; |
42 | 977 | for (unsigned j = 0; j < subjects->len; j++) | 981 | for (unsigned j = 0; j < subjects->len; j++) |
43 | 978 | { | 982 | { |
45 | 979 | const gchar *subj_uri = zeitgeist_subject_get_uri ((ZeitgeistSubject*) subjects->pdata[j]); | 983 | const gchar *subj_uri = zeitgeist_subject_get_current_uri ( |
46 | 984 | (ZeitgeistSubject*) subjects->pdata[j]); | ||
47 | 980 | if (subj_uri == NULL) continue; | 985 | if (subj_uri == NULL) continue; |
48 | 981 | relevancy_map[event_id] = relevancy_map[remapper[subj_uri]]; | 986 | relevancy_map[event_id] = relevancy_map[remapper[subj_uri]]; |
49 | 982 | } | 987 | } |
50 | @@ -1259,7 +1264,6 @@ | |||
51 | 1259 | { | 1264 | { |
52 | 1260 | try | 1265 | try |
53 | 1261 | { | 1266 | { |
54 | 1262 | // FIXME: we need to special case MOVE_EVENTs | ||
55 | 1263 | const gchar *val; | 1267 | const gchar *val; |
56 | 1264 | guint event_id = zeitgeist_event_get_id (event); | 1268 | guint event_id = zeitgeist_event_get_id (event); |
57 | 1265 | g_return_if_fail (event_id > 0); | 1269 | g_return_if_fail (event_id > 0); |
58 | @@ -1288,7 +1292,13 @@ | |||
59 | 1288 | ZeitgeistSubject *subject; | 1292 | ZeitgeistSubject *subject; |
60 | 1289 | subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, i); | 1293 | subject = (ZeitgeistSubject*) g_ptr_array_index (subjects, i); |
61 | 1290 | 1294 | ||
63 | 1291 | val = zeitgeist_subject_get_uri (subject); | 1295 | // We use current_uri (vs. uri) where since we care about real stuff, |
64 | 1296 | // not whatever happened some time ago. | ||
65 | 1297 | // | ||
66 | 1298 | // This will most likely still be the same as URI (unless something | ||
67 | 1299 | // triggers a reindexation of the DB), but at least MOVE_EVENTS | ||
68 | 1300 | // will have the updated URI. | ||
69 | 1301 | val = zeitgeist_subject_get_current_uri (subject); | ||
70 | 1292 | if (val == NULL || val[0] == '\0') continue; | 1302 | if (val == NULL || val[0] == '\0') continue; |
71 | 1293 | 1303 | ||
72 | 1294 | std::string uri(val); | 1304 | std::string uri(val); |
73 | 1295 | 1305 | ||
74 | === modified file 'extensions/fts++/test/test-indexer.cpp' | |||
75 | --- extensions/fts++/test/test-indexer.cpp 2012-03-14 15:47:20 +0000 | |||
76 | +++ extensions/fts++/test/test-indexer.cpp 2012-03-16 18:46:19 +0000 | |||
77 | @@ -62,6 +62,30 @@ | |||
78 | 62 | g_object_unref (fix->db); | 62 | g_object_unref (fix->db); |
79 | 63 | } | 63 | } |
80 | 64 | 64 | ||
81 | 65 | static void | ||
82 | 66 | assert_nth_result_has_id (GPtrArray* results, guint n, guint32 event_id) | ||
83 | 67 | { | ||
84 | 68 | g_assert_cmpuint (n, <, results->len); | ||
85 | 69 | ZeitgeistEvent *event = (ZeitgeistEvent*) results->pdata[n]; | ||
86 | 70 | g_assert (event); | ||
87 | 71 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
88 | 72 | } | ||
89 | 73 | |||
90 | 74 | // This function only supports events with a single subject, | ||
91 | 75 | // since that's enough for the tests in this file. | ||
92 | 76 | static void | ||
93 | 77 | assert_nth_result_has_text (GPtrArray* results, int n, const char *text) | ||
94 | 78 | { | ||
95 | 79 | g_assert_cmpuint (n, <, results->len); | ||
96 | 80 | ZeitgeistEvent *event = (ZeitgeistEvent*) results->pdata[n]; | ||
97 | 81 | g_assert (event); | ||
98 | 82 | g_assert_cmpint (zeitgeist_event_num_subjects (event), ==, 1); | ||
99 | 83 | ZeitgeistSubject *subject = (ZeitgeistSubject*) | ||
100 | 84 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
101 | 85 | g_assert (subject); | ||
102 | 86 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, text); | ||
103 | 87 | } | ||
104 | 88 | |||
105 | 65 | static ZeitgeistEvent* create_test_event1 (void) | 89 | static ZeitgeistEvent* create_test_event1 (void) |
106 | 66 | { | 90 | { |
107 | 67 | ZeitgeistEvent *event = zeitgeist_event_new (); | 91 | ZeitgeistEvent *event = zeitgeist_event_new (); |
108 | @@ -131,7 +155,7 @@ | |||
109 | 131 | zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION); | 155 | zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION); |
110 | 132 | zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT); | 156 | zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT); |
111 | 133 | zeitgeist_subject_set_uri (subject, "file:///home/username/Documents/my_fabulous_presentation.pdf"); | 157 | zeitgeist_subject_set_uri (subject, "file:///home/username/Documents/my_fabulous_presentation.pdf"); |
113 | 134 | zeitgeist_subject_set_text (subject, NULL); | 158 | zeitgeist_subject_set_text (subject, "test texts"); |
114 | 135 | zeitgeist_subject_set_mimetype (subject, "application/pdf"); | 159 | zeitgeist_subject_set_mimetype (subject, "application/pdf"); |
115 | 136 | 160 | ||
116 | 137 | zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MODIFY_EVENT); | 161 | zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MODIFY_EVENT); |
117 | @@ -191,7 +215,7 @@ | |||
118 | 191 | zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION); | 215 | zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION); |
119 | 192 | zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT); | 216 | zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT); |
120 | 193 | zeitgeist_subject_set_uri (subject, "file:///home/username/directory-with-dashes/and.dot/%C4%8C%20some-intl/CamelCasePresentation.pdf"); | 217 | zeitgeist_subject_set_uri (subject, "file:///home/username/directory-with-dashes/and.dot/%C4%8C%20some-intl/CamelCasePresentation.pdf"); |
122 | 194 | zeitgeist_subject_set_text (subject, NULL); | 218 | zeitgeist_subject_set_text (subject, "some more texts"); |
123 | 195 | zeitgeist_subject_set_mimetype (subject, "application/pdf"); | 219 | zeitgeist_subject_set_mimetype (subject, "application/pdf"); |
124 | 196 | 220 | ||
125 | 197 | zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MODIFY_EVENT); | 221 | zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MODIFY_EVENT); |
126 | @@ -203,6 +227,27 @@ | |||
127 | 203 | return event; | 227 | return event; |
128 | 204 | } | 228 | } |
129 | 205 | 229 | ||
130 | 230 | static ZeitgeistEvent* create_test_event8 (void) | ||
131 | 231 | { | ||
132 | 232 | ZeitgeistEvent *event = zeitgeist_event_new (); | ||
133 | 233 | ZeitgeistSubject *subject = zeitgeist_subject_new (); | ||
134 | 234 | |||
135 | 235 | zeitgeist_subject_set_interpretation (subject, ZEITGEIST_NFO_PRESENTATION); | ||
136 | 236 | zeitgeist_subject_set_manifestation (subject, ZEITGEIST_NFO_FILE_DATA_OBJECT); | ||
137 | 237 | zeitgeist_subject_set_uri (subject, "file:///home/username/Documents/my_fabulous_presentation.pdf"); | ||
138 | 238 | zeitgeist_subject_set_current_uri (subject, "file:///home/username/Awesome.pdf"); | ||
139 | 239 | zeitgeist_subject_set_text (subject, "some more textt about a presentation or something"); | ||
140 | 240 | zeitgeist_subject_set_mimetype (subject, "application/pdf"); | ||
141 | 241 | |||
142 | 242 | zeitgeist_event_set_interpretation (event, ZEITGEIST_ZG_MOVE_EVENT); | ||
143 | 243 | zeitgeist_event_set_manifestation (event, ZEITGEIST_ZG_USER_ACTIVITY); | ||
144 | 244 | zeitgeist_event_set_actor (event, "application://nautilus.desktop"); | ||
145 | 245 | zeitgeist_event_add_subject (event, subject); | ||
146 | 246 | |||
147 | 247 | g_object_unref (subject); | ||
148 | 248 | return event; | ||
149 | 249 | } | ||
150 | 250 | |||
151 | 206 | // Steals the event, ref it if you want to keep it | 251 | // Steals the event, ref it if you want to keep it |
152 | 207 | static guint | 252 | static guint |
153 | 208 | index_event (Fixture *fix, ZeitgeistEvent *event) | 253 | index_event (Fixture *fix, ZeitgeistEvent *event) |
154 | @@ -236,6 +281,42 @@ | |||
155 | 236 | return event_id; | 281 | return event_id; |
156 | 237 | } | 282 | } |
157 | 238 | 283 | ||
158 | 284 | static GPtrArray* | ||
159 | 285 | search_simple (Fixture *fix, const char *text, GPtrArray *templates, | ||
160 | 286 | ZeitgeistResultType result_type, guint *matches) | ||
161 | 287 | { | ||
162 | 288 | if (!templates) templates = g_ptr_array_new (); | ||
163 | 289 | return zeitgeist_indexer_search (fix->indexer, | ||
164 | 290 | text, | ||
165 | 291 | zeitgeist_time_range_new_anytime (), | ||
166 | 292 | templates, | ||
167 | 293 | 0, // offset | ||
168 | 294 | 10, // count | ||
169 | 295 | result_type, | ||
170 | 296 | matches, | ||
171 | 297 | NULL); | ||
172 | 298 | } | ||
173 | 299 | |||
174 | 300 | static GPtrArray* | ||
175 | 301 | search_with_relevancies_simple (Fixture *fix, const char *text, | ||
176 | 302 | GPtrArray *templates, ZeitgeistResultType result_type, | ||
177 | 303 | gdouble **relevancies, gint *relevancies_size, guint *matches) | ||
178 | 304 | { | ||
179 | 305 | if (!templates) templates = g_ptr_array_new (); | ||
180 | 306 | return zeitgeist_indexer_search_with_relevancies (fix->indexer, | ||
181 | 307 | text, | ||
182 | 308 | zeitgeist_time_range_new_anytime (), | ||
183 | 309 | templates, | ||
184 | 310 | ZEITGEIST_STORAGE_STATE_ANY, | ||
185 | 311 | 0, // offset | ||
186 | 312 | 10, // count | ||
187 | 313 | result_type, | ||
188 | 314 | relevancies, | ||
189 | 315 | relevancies_size, | ||
190 | 316 | matches, | ||
191 | 317 | NULL); | ||
192 | 318 | } | ||
193 | 319 | |||
194 | 239 | static void | 320 | static void |
195 | 240 | test_simple_query (Fixture *fix, gconstpointer data) | 321 | test_simple_query (Fixture *fix, gconstpointer data) |
196 | 241 | { | 322 | { |
197 | @@ -249,33 +330,44 @@ | |||
198 | 249 | index_event (fix, create_test_event3 ()); | 330 | index_event (fix, create_test_event3 ()); |
199 | 250 | index_event (fix, create_test_event4 ()); | 331 | index_event (fix, create_test_event4 ()); |
200 | 251 | 332 | ||
211 | 252 | GPtrArray *results = | 333 | GPtrArray *results = search_simple (fix, "text", NULL, |
212 | 253 | zeitgeist_indexer_search (fix->indexer, | 334 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
203 | 254 | "text", | ||
204 | 255 | zeitgeist_time_range_new_anytime (), | ||
205 | 256 | g_ptr_array_new (), | ||
206 | 257 | 0, | ||
207 | 258 | 10, | ||
208 | 259 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
209 | 260 | &matches, | ||
210 | 261 | NULL); | ||
213 | 262 | 335 | ||
214 | 263 | g_assert_cmpuint (matches, >, 0); | 336 | g_assert_cmpuint (matches, >, 0); |
215 | 264 | g_assert_cmpuint (results->len, ==, 1); | 337 | g_assert_cmpuint (results->len, ==, 1); |
223 | 265 | 338 | assert_nth_result_has_id (results, 0, event_id); | |
224 | 266 | event = (ZeitgeistEvent*) results->pdata[0]; | 339 | assert_nth_result_has_text (results, 0, "text"); |
225 | 267 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | 340 | } |
226 | 268 | 341 | ||
227 | 269 | ZeitgeistSubject *subject = (ZeitgeistSubject*) | 342 | static void |
228 | 270 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | 343 | test_simple_query_empty_database (Fixture *fix, gconstpointer data) |
229 | 271 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "text"); | 344 | { |
230 | 345 | guint matches; | ||
231 | 346 | |||
232 | 347 | GPtrArray *results = search_simple (fix, | ||
233 | 348 | "NothingWillEverMatchThisMwhahahaha", NULL, | ||
234 | 349 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); | ||
235 | 350 | |||
236 | 351 | g_assert_cmpuint (matches, ==, 0); | ||
237 | 352 | g_assert_cmpuint (results->len, ==, 0); | ||
238 | 353 | } | ||
239 | 354 | |||
240 | 355 | static void | ||
241 | 356 | test_simple_query_no_results (Fixture *fix, gconstpointer data) | ||
242 | 357 | { | ||
243 | 358 | // add test events to DBs | ||
244 | 359 | index_event (fix, create_test_event1 ()); | ||
245 | 360 | index_event (fix, create_test_event2 ()); | ||
246 | 361 | index_event (fix, create_test_event3 ()); | ||
247 | 362 | index_event (fix, create_test_event4 ()); | ||
248 | 363 | |||
249 | 364 | test_simple_query_empty_database (fix, data); | ||
250 | 272 | } | 365 | } |
251 | 273 | 366 | ||
252 | 274 | static void | 367 | static void |
253 | 275 | test_simple_with_filter (Fixture *fix, gconstpointer data) | 368 | test_simple_with_filter (Fixture *fix, gconstpointer data) |
254 | 276 | { | 369 | { |
255 | 277 | guint matches; | 370 | guint matches; |
256 | 278 | guint event_id; | ||
257 | 279 | ZeitgeistEvent* event; | 371 | ZeitgeistEvent* event; |
258 | 280 | 372 | ||
259 | 281 | // add test events to DBs | 373 | // add test events to DBs |
260 | @@ -287,16 +379,8 @@ | |||
261 | 287 | zeitgeist_event_set_interpretation (event, ZEITGEIST_NFO_DOCUMENT); | 379 | zeitgeist_event_set_interpretation (event, ZEITGEIST_NFO_DOCUMENT); |
262 | 288 | g_ptr_array_add (filters, event); // steals ref | 380 | g_ptr_array_add (filters, event); // steals ref |
263 | 289 | 381 | ||
274 | 290 | GPtrArray *results = | 382 | GPtrArray *results = search_simple (fix, "text", filters, |
275 | 291 | zeitgeist_indexer_search (fix->indexer, | 383 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
266 | 292 | "text", | ||
267 | 293 | zeitgeist_time_range_new_anytime (), | ||
268 | 294 | filters, | ||
269 | 295 | 0, | ||
270 | 296 | 10, | ||
271 | 297 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
272 | 298 | &matches, | ||
273 | 299 | NULL); | ||
276 | 300 | 384 | ||
277 | 301 | g_assert_cmpuint (results->len, ==, 0); | 385 | g_assert_cmpuint (results->len, ==, 0); |
278 | 302 | g_assert_cmpuint (matches, ==, 0); | 386 | g_assert_cmpuint (matches, ==, 0); |
279 | @@ -321,38 +405,24 @@ | |||
280 | 321 | zeitgeist_event_add_subject (event, subject); | 405 | zeitgeist_event_add_subject (event, subject); |
281 | 322 | g_ptr_array_add (filters, event); // steals ref | 406 | g_ptr_array_add (filters, event); // steals ref |
282 | 323 | 407 | ||
293 | 324 | GPtrArray *results = | 408 | GPtrArray *results = search_simple (fix, "text", filters, |
294 | 325 | zeitgeist_indexer_search (fix->indexer, | 409 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
285 | 326 | "text", | ||
286 | 327 | zeitgeist_time_range_new_anytime (), | ||
287 | 328 | filters, | ||
288 | 329 | 0, | ||
289 | 330 | 10, | ||
290 | 331 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
291 | 332 | &matches, | ||
292 | 333 | NULL); | ||
295 | 334 | 410 | ||
296 | 335 | g_assert_cmpuint (matches, >, 0); | 411 | g_assert_cmpuint (matches, >, 0); |
297 | 336 | g_assert_cmpuint (results->len, ==, 1); | 412 | g_assert_cmpuint (results->len, ==, 1); |
305 | 337 | 413 | assert_nth_result_has_id (results, 0, event_id); | |
306 | 338 | event = (ZeitgeistEvent*) results->pdata[0]; | 414 | assert_nth_result_has_text (results, 0, "text"); |
300 | 339 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
301 | 340 | |||
302 | 341 | subject = (ZeitgeistSubject*) | ||
303 | 342 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
304 | 343 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "text"); | ||
307 | 344 | } | 415 | } |
308 | 345 | 416 | ||
309 | 346 | static void | 417 | static void |
310 | 347 | test_simple_negation (Fixture *fix, gconstpointer data) | 418 | test_simple_negation (Fixture *fix, gconstpointer data) |
311 | 348 | { | 419 | { |
312 | 349 | guint matches; | 420 | guint matches; |
313 | 350 | guint event_id; | ||
314 | 351 | ZeitgeistEvent* event; | 421 | ZeitgeistEvent* event; |
315 | 352 | ZeitgeistSubject *subject; | 422 | ZeitgeistSubject *subject; |
316 | 353 | 423 | ||
317 | 354 | // add test events to DBs | 424 | // add test events to DBs |
319 | 355 | event_id = index_event (fix, create_test_event1 ()); | 425 | index_event (fix, create_test_event1 ()); |
320 | 356 | index_event (fix, create_test_event2 ()); | 426 | index_event (fix, create_test_event2 ()); |
321 | 357 | 427 | ||
322 | 358 | GPtrArray *filters = g_ptr_array_new_with_free_func (g_object_unref); | 428 | GPtrArray *filters = g_ptr_array_new_with_free_func (g_object_unref); |
323 | @@ -362,16 +432,8 @@ | |||
324 | 362 | zeitgeist_event_add_subject (event, subject); | 432 | zeitgeist_event_add_subject (event, subject); |
325 | 363 | g_ptr_array_add (filters, event); // steals ref | 433 | g_ptr_array_add (filters, event); // steals ref |
326 | 364 | 434 | ||
337 | 365 | GPtrArray *results = | 435 | GPtrArray *results = search_simple (fix, "text", filters, |
338 | 366 | zeitgeist_indexer_search (fix->indexer, | 436 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
329 | 367 | "text", | ||
330 | 368 | zeitgeist_time_range_new_anytime (), | ||
331 | 369 | filters, | ||
332 | 370 | 0, | ||
333 | 371 | 10, | ||
334 | 372 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
335 | 373 | &matches, | ||
336 | 374 | NULL); | ||
339 | 375 | 437 | ||
340 | 376 | g_assert_cmpuint (matches, ==, 0); | 438 | g_assert_cmpuint (matches, ==, 0); |
341 | 377 | g_assert_cmpuint (results->len, ==, 0); | 439 | g_assert_cmpuint (results->len, ==, 0); |
342 | @@ -381,12 +443,11 @@ | |||
343 | 381 | test_simple_noexpand (Fixture *fix, gconstpointer data) | 443 | test_simple_noexpand (Fixture *fix, gconstpointer data) |
344 | 382 | { | 444 | { |
345 | 383 | guint matches; | 445 | guint matches; |
346 | 384 | guint event_id; | ||
347 | 385 | ZeitgeistEvent* event; | 446 | ZeitgeistEvent* event; |
348 | 386 | ZeitgeistSubject *subject; | 447 | ZeitgeistSubject *subject; |
349 | 387 | 448 | ||
350 | 388 | // add test events to DBs | 449 | // add test events to DBs |
352 | 389 | event_id = index_event (fix, create_test_event1 ()); | 450 | index_event (fix, create_test_event1 ()); |
353 | 390 | index_event (fix, create_test_event2 ()); | 451 | index_event (fix, create_test_event2 ()); |
354 | 391 | 452 | ||
355 | 392 | GPtrArray *filters = g_ptr_array_new_with_free_func (g_object_unref); | 453 | GPtrArray *filters = g_ptr_array_new_with_free_func (g_object_unref); |
356 | @@ -396,16 +457,8 @@ | |||
357 | 396 | zeitgeist_event_add_subject (event, subject); | 457 | zeitgeist_event_add_subject (event, subject); |
358 | 397 | g_ptr_array_add (filters, event); // steals ref | 458 | g_ptr_array_add (filters, event); // steals ref |
359 | 398 | 459 | ||
370 | 399 | GPtrArray *results = | 460 | GPtrArray *results = search_simple (fix, "text", filters, |
371 | 400 | zeitgeist_indexer_search (fix->indexer, | 461 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
362 | 401 | "text", | ||
363 | 402 | zeitgeist_time_range_new_anytime (), | ||
364 | 403 | filters, | ||
365 | 404 | 0, | ||
366 | 405 | 10, | ||
367 | 406 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
368 | 407 | &matches, | ||
369 | 408 | NULL); | ||
372 | 409 | 462 | ||
373 | 410 | g_assert_cmpuint (matches, ==, 0); | 463 | g_assert_cmpuint (matches, ==, 0); |
374 | 411 | g_assert_cmpuint (results->len, ==, 0); | 464 | g_assert_cmpuint (results->len, ==, 0); |
375 | @@ -430,26 +483,13 @@ | |||
376 | 430 | zeitgeist_event_add_subject (event, subject); | 483 | zeitgeist_event_add_subject (event, subject); |
377 | 431 | g_ptr_array_add (filters, event); // steals ref | 484 | g_ptr_array_add (filters, event); // steals ref |
378 | 432 | 485 | ||
389 | 433 | GPtrArray *results = | 486 | GPtrArray *results = search_simple (fix, "text", filters, |
390 | 434 | zeitgeist_indexer_search (fix->indexer, | 487 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
381 | 435 | "text", | ||
382 | 436 | zeitgeist_time_range_new_anytime (), | ||
383 | 437 | filters, | ||
384 | 438 | 0, | ||
385 | 439 | 10, | ||
386 | 440 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
387 | 441 | &matches, | ||
388 | 442 | NULL); | ||
391 | 443 | 488 | ||
392 | 444 | g_assert_cmpuint (matches, >, 0); | 489 | g_assert_cmpuint (matches, >, 0); |
393 | 445 | g_assert_cmpuint (results->len, ==, 1); | 490 | g_assert_cmpuint (results->len, ==, 1); |
401 | 446 | 491 | assert_nth_result_has_id (results, 0, event_id); | |
402 | 447 | event = (ZeitgeistEvent*) results->pdata[0]; | 492 | assert_nth_result_has_text (results, 0, "text"); |
396 | 448 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
397 | 449 | |||
398 | 450 | subject = (ZeitgeistSubject*) | ||
399 | 451 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
400 | 452 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "text"); | ||
403 | 453 | } | 493 | } |
404 | 454 | 494 | ||
405 | 455 | static void | 495 | static void |
406 | @@ -471,26 +511,14 @@ | |||
407 | 471 | zeitgeist_event_add_subject (event, subject); | 511 | zeitgeist_event_add_subject (event, subject); |
408 | 472 | g_ptr_array_add (filters, event); // steals ref | 512 | g_ptr_array_add (filters, event); // steals ref |
409 | 473 | 513 | ||
420 | 474 | GPtrArray *results = | 514 | GPtrArray *results = search_simple (fix, "love", filters, |
421 | 475 | zeitgeist_indexer_search (fix->indexer, | 515 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
412 | 476 | "love", | ||
413 | 477 | zeitgeist_time_range_new_anytime (), | ||
414 | 478 | filters, | ||
415 | 479 | 0, | ||
416 | 480 | 10, | ||
417 | 481 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
418 | 482 | &matches, | ||
419 | 483 | NULL); | ||
422 | 484 | 516 | ||
423 | 485 | g_assert_cmpuint (matches, >, 0); | 517 | g_assert_cmpuint (matches, >, 0); |
424 | 486 | g_assert_cmpuint (results->len, ==, 1); | 518 | g_assert_cmpuint (results->len, ==, 1); |
432 | 487 | 519 | assert_nth_result_has_id (results, 0, event_id); | |
433 | 488 | event = (ZeitgeistEvent*) results->pdata[0]; | 520 | assert_nth_result_has_text (results, 0, |
434 | 489 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | 521 | "Example.com Wiki Page. Kanji is awesome 漢字"); |
428 | 490 | |||
429 | 491 | subject = (ZeitgeistSubject*) | ||
430 | 492 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
431 | 493 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "Example.com Wiki Page. Kanji is awesome 漢字"); | ||
435 | 494 | } | 522 | } |
436 | 495 | 523 | ||
437 | 496 | static void | 524 | static void |
438 | @@ -507,22 +535,12 @@ | |||
439 | 507 | index_event (fix, create_test_event3 ()); | 535 | index_event (fix, create_test_event3 ()); |
440 | 508 | event_id = index_event (fix, create_test_event4 ()); | 536 | event_id = index_event (fix, create_test_event4 ()); |
441 | 509 | 537 | ||
452 | 510 | GPtrArray *results = | 538 | GPtrArray *results = search_simple (fix, "fabulo*", NULL, |
453 | 511 | zeitgeist_indexer_search (fix->indexer, | 539 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
444 | 512 | "fabulo*", | ||
445 | 513 | zeitgeist_time_range_new_anytime (), | ||
446 | 514 | g_ptr_array_new (), | ||
447 | 515 | 0, | ||
448 | 516 | 10, | ||
449 | 517 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
450 | 518 | &matches, | ||
451 | 519 | NULL); | ||
454 | 520 | 540 | ||
455 | 521 | g_assert_cmpuint (matches, >, 0); | 541 | g_assert_cmpuint (matches, >, 0); |
456 | 522 | g_assert_cmpuint (results->len, ==, 1); | 542 | g_assert_cmpuint (results->len, ==, 1); |
460 | 523 | 543 | assert_nth_result_has_id (results, 0, event_id); | |
458 | 524 | event = (ZeitgeistEvent*) results->pdata[0]; | ||
459 | 525 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
461 | 526 | } | 544 | } |
462 | 527 | 545 | ||
463 | 528 | static void | 546 | static void |
464 | @@ -540,22 +558,12 @@ | |||
465 | 540 | index_event (fix, create_test_event4 ()); | 558 | index_event (fix, create_test_event4 ()); |
466 | 541 | event_id = index_event (fix, create_test_event5 ()); | 559 | event_id = index_event (fix, create_test_event5 ()); |
467 | 542 | 560 | ||
478 | 543 | GPtrArray *results = | 561 | GPtrArray *results = search_simple (fix, "signal", NULL, |
479 | 544 | zeitgeist_indexer_search (fix->indexer, | 562 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
470 | 545 | "signal", | ||
471 | 546 | zeitgeist_time_range_new_anytime (), | ||
472 | 547 | g_ptr_array_new (), | ||
473 | 548 | 0, | ||
474 | 549 | 10, | ||
475 | 550 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
476 | 551 | &matches, | ||
477 | 552 | NULL); | ||
480 | 553 | 563 | ||
481 | 554 | g_assert_cmpuint (matches, >, 0); | 564 | g_assert_cmpuint (matches, >, 0); |
482 | 555 | g_assert_cmpuint (results->len, ==, 1); | 565 | g_assert_cmpuint (results->len, ==, 1); |
486 | 556 | 566 | assert_nth_result_has_id (results, 0, event_id); | |
484 | 557 | event = (ZeitgeistEvent*) results->pdata[0]; | ||
485 | 558 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
487 | 559 | } | 567 | } |
488 | 560 | 568 | ||
489 | 561 | static void | 569 | static void |
490 | @@ -583,22 +591,12 @@ | |||
491 | 583 | zeitgeist_event_add_subject (event, subject); | 591 | zeitgeist_event_add_subject (event, subject); |
492 | 584 | g_ptr_array_add (event_template, event); | 592 | g_ptr_array_add (event_template, event); |
493 | 585 | 593 | ||
504 | 586 | GPtrArray *results = | 594 | GPtrArray *results = search_simple (fix, "pdf", event_template, |
505 | 587 | zeitgeist_indexer_search (fix->indexer, | 595 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
496 | 588 | "pdf", | ||
497 | 589 | zeitgeist_time_range_new_anytime (), | ||
498 | 590 | event_template, | ||
499 | 591 | 0, | ||
500 | 592 | 10, | ||
501 | 593 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
502 | 594 | &matches, | ||
503 | 595 | NULL); | ||
506 | 596 | 596 | ||
507 | 597 | g_assert_cmpuint (matches, >, 0); | 597 | g_assert_cmpuint (matches, >, 0); |
508 | 598 | g_assert_cmpuint (results->len, ==, 1); | 598 | g_assert_cmpuint (results->len, ==, 1); |
512 | 599 | 599 | assert_nth_result_has_id (results, 0, event_id); | |
510 | 600 | event = (ZeitgeistEvent*) results->pdata[0]; | ||
511 | 601 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
513 | 602 | } | 600 | } |
514 | 603 | 601 | ||
515 | 604 | static void | 602 | static void |
516 | @@ -626,22 +624,12 @@ | |||
517 | 626 | zeitgeist_event_add_subject (event, subject); | 624 | zeitgeist_event_add_subject (event, subject); |
518 | 627 | g_ptr_array_add (event_template, event); | 625 | g_ptr_array_add (event_template, event); |
519 | 628 | 626 | ||
530 | 629 | GPtrArray *results = | 627 | GPtrArray *results = search_simple (fix, "pdf", event_template, |
531 | 630 | zeitgeist_indexer_search (fix->indexer, | 628 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
522 | 631 | "pdf", | ||
523 | 632 | zeitgeist_time_range_new_anytime (), | ||
524 | 633 | event_template, | ||
525 | 634 | 0, | ||
526 | 635 | 10, | ||
527 | 636 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
528 | 637 | &matches, | ||
529 | 638 | NULL); | ||
532 | 639 | 629 | ||
533 | 640 | g_assert_cmpuint (matches, >, 0); | 630 | g_assert_cmpuint (matches, >, 0); |
534 | 641 | g_assert_cmpuint (results->len, ==, 1); | 631 | g_assert_cmpuint (results->len, ==, 1); |
538 | 642 | 632 | assert_nth_result_has_id (results, 0, event_id); | |
536 | 643 | event = (ZeitgeistEvent*) results->pdata[0]; | ||
537 | 644 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
539 | 645 | } | 633 | } |
540 | 646 | 634 | ||
541 | 647 | static void | 635 | static void |
542 | @@ -669,22 +657,12 @@ | |||
543 | 669 | zeitgeist_event_add_subject (event, subject); | 657 | zeitgeist_event_add_subject (event, subject); |
544 | 670 | g_ptr_array_add (event_template, event); | 658 | g_ptr_array_add (event_template, event); |
545 | 671 | 659 | ||
556 | 672 | GPtrArray *results = | 660 | GPtrArray *results = search_simple (fix, "pdf", event_template, |
557 | 673 | zeitgeist_indexer_search (fix->indexer, | 661 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
548 | 674 | "pdf", | ||
549 | 675 | zeitgeist_time_range_new_anytime (), | ||
550 | 676 | event_template, | ||
551 | 677 | 0, | ||
552 | 678 | 10, | ||
553 | 679 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
554 | 680 | &matches, | ||
555 | 681 | NULL); | ||
558 | 682 | 662 | ||
559 | 683 | g_assert_cmpuint (matches, >, 0); | 663 | g_assert_cmpuint (matches, >, 0); |
560 | 684 | g_assert_cmpuint (results->len, ==, 1); | 664 | g_assert_cmpuint (results->len, ==, 1); |
564 | 685 | 665 | assert_nth_result_has_id (results, 0, event_id); | |
562 | 686 | event = (ZeitgeistEvent*) results->pdata[0]; | ||
563 | 687 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
565 | 688 | } | 666 | } |
566 | 689 | 667 | ||
567 | 690 | static void | 668 | static void |
568 | @@ -699,26 +677,14 @@ | |||
569 | 699 | index_event (fix, create_test_event1 ()); | 677 | index_event (fix, create_test_event1 ()); |
570 | 700 | event_id = index_event (fix, create_test_event2 ()); | 678 | event_id = index_event (fix, create_test_event2 ()); |
571 | 701 | 679 | ||
582 | 702 | GPtrArray *results = | 680 | GPtrArray *results = search_simple (fix, "漢*", NULL, |
583 | 703 | zeitgeist_indexer_search (fix->indexer, | 681 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
574 | 704 | "漢*", | ||
575 | 705 | zeitgeist_time_range_new_anytime (), | ||
576 | 706 | g_ptr_array_new (), | ||
577 | 707 | 0, | ||
578 | 708 | 10, | ||
579 | 709 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
580 | 710 | &matches, | ||
581 | 711 | NULL); | ||
584 | 712 | 682 | ||
585 | 713 | g_assert_cmpuint (matches, >, 0); | 683 | g_assert_cmpuint (matches, >, 0); |
586 | 714 | g_assert_cmpuint (results->len, ==, 1); | 684 | g_assert_cmpuint (results->len, ==, 1); |
594 | 715 | 685 | assert_nth_result_has_id (results, 0, event_id); | |
595 | 716 | event = (ZeitgeistEvent*) results->pdata[0]; | 686 | assert_nth_result_has_text (results, 0, |
596 | 717 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | 687 | "Example.com Wiki Page. Kanji is awesome 漢字"); |
590 | 718 | |||
591 | 719 | subject = (ZeitgeistSubject*) | ||
592 | 720 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
593 | 721 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "Example.com Wiki Page. Kanji is awesome 漢字"); | ||
597 | 722 | } | 688 | } |
598 | 723 | 689 | ||
599 | 724 | static void | 690 | static void |
600 | @@ -734,26 +700,13 @@ | |||
601 | 734 | index_event (fix, create_test_event2 ()); | 700 | index_event (fix, create_test_event2 ()); |
602 | 735 | event_id = index_event (fix, create_test_event3 ()); | 701 | event_id = index_event (fix, create_test_event3 ()); |
603 | 736 | 702 | ||
614 | 737 | GPtrArray *results = | 703 | GPtrArray *results = search_simple (fix, "παράδειγμα", NULL, |
615 | 738 | zeitgeist_indexer_search (fix->indexer, | 704 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); |
606 | 739 | "παράδειγμα", | ||
607 | 740 | zeitgeist_time_range_new_anytime (), | ||
608 | 741 | g_ptr_array_new (), | ||
609 | 742 | 0, | ||
610 | 743 | 10, | ||
611 | 744 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
612 | 745 | &matches, | ||
613 | 746 | NULL); | ||
616 | 747 | 705 | ||
617 | 748 | g_assert_cmpuint (matches, >, 0); | 706 | g_assert_cmpuint (matches, >, 0); |
618 | 749 | g_assert_cmpuint (results->len, ==, 1); | 707 | g_assert_cmpuint (results->len, ==, 1); |
626 | 750 | 708 | assert_nth_result_has_id (results, 0, event_id); | |
627 | 751 | event = (ZeitgeistEvent*) results->pdata[0]; | 709 | assert_nth_result_has_text (results, 0, "IDNwiki"); |
621 | 752 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
622 | 753 | |||
623 | 754 | subject = (ZeitgeistSubject*) | ||
624 | 755 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
625 | 756 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "IDNwiki"); | ||
628 | 757 | } | 710 | } |
629 | 758 | 711 | ||
630 | 759 | static void | 712 | static void |
631 | @@ -771,30 +724,16 @@ | |||
632 | 771 | index_event (fix, create_test_event3 ()); | 724 | index_event (fix, create_test_event3 ()); |
633 | 772 | index_event (fix, create_test_event4 ()); | 725 | index_event (fix, create_test_event4 ()); |
634 | 773 | 726 | ||
647 | 774 | GPtrArray *results = | 727 | GPtrArray *results = search_with_relevancies_simple (fix, "text", NULL, |
648 | 775 | zeitgeist_indexer_search_with_relevancies (fix->indexer, | 728 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_SUBJECTS, |
649 | 776 | "text", | 729 | &relevancies, &relevancies_size, &matches); |
638 | 777 | zeitgeist_time_range_new_anytime (), | ||
639 | 778 | g_ptr_array_new (), | ||
640 | 779 | ZEITGEIST_STORAGE_STATE_ANY, | ||
641 | 780 | 0, | ||
642 | 781 | 10, | ||
643 | 782 | (ZeitgeistResultType) 100, | ||
644 | 783 | &relevancies, &relevancies_size, | ||
645 | 784 | &matches, | ||
646 | 785 | NULL); | ||
650 | 786 | 730 | ||
651 | 787 | g_assert_cmpuint (matches, >, 0); | 731 | g_assert_cmpuint (matches, >, 0); |
652 | 788 | g_assert_cmpuint (results->len, ==, 1); | 732 | g_assert_cmpuint (results->len, ==, 1); |
653 | 789 | g_assert_cmpint (relevancies_size, ==, 1); | 733 | g_assert_cmpint (relevancies_size, ==, 1); |
654 | 790 | g_assert_cmpfloat (relevancies[0], >=, 1.0); | 734 | g_assert_cmpfloat (relevancies[0], >=, 1.0); |
662 | 791 | 735 | assert_nth_result_has_id (results, 0, event_id); | |
663 | 792 | event = (ZeitgeistEvent*) results->pdata[0]; | 736 | assert_nth_result_has_text (results, 0, "text"); |
657 | 793 | g_assert_cmpuint (zeitgeist_event_get_id (event), ==, event_id); | ||
658 | 794 | |||
659 | 795 | ZeitgeistSubject *subject = (ZeitgeistSubject*) | ||
660 | 796 | g_ptr_array_index (zeitgeist_event_get_subjects (event), 0); | ||
661 | 797 | g_assert_cmpstr (zeitgeist_subject_get_text (subject), ==, "text"); | ||
664 | 798 | } | 737 | } |
665 | 799 | 738 | ||
666 | 800 | static void | 739 | static void |
667 | @@ -815,18 +754,9 @@ | |||
668 | 815 | usleep (50000); | 754 | usleep (50000); |
669 | 816 | event_id6 = index_event (fix, create_test_event6 ()); | 755 | event_id6 = index_event (fix, create_test_event6 ()); |
670 | 817 | 756 | ||
683 | 818 | GPtrArray *results = | 757 | GPtrArray *results = search_with_relevancies_simple (fix, "user*", NULL, |
684 | 819 | zeitgeist_indexer_search_with_relevancies (fix->indexer, | 758 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_SUBJECTS, |
685 | 820 | "user*", | 759 | &relevancies, &relevancies_size, &matches); |
674 | 821 | zeitgeist_time_range_new_anytime (), | ||
675 | 822 | g_ptr_array_new (), | ||
676 | 823 | ZEITGEIST_STORAGE_STATE_ANY, | ||
677 | 824 | 0, | ||
678 | 825 | 10, | ||
679 | 826 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_SUBJECTS, | ||
680 | 827 | &relevancies, &relevancies_size, | ||
681 | 828 | &matches, | ||
682 | 829 | NULL); | ||
686 | 830 | 760 | ||
687 | 831 | g_assert_cmpuint (matches, >, 0); | 761 | g_assert_cmpuint (matches, >, 0); |
688 | 832 | g_assert_cmpuint (results->len, ==, 3); | 762 | g_assert_cmpuint (results->len, ==, 3); |
689 | @@ -834,8 +764,131 @@ | |||
690 | 834 | 764 | ||
691 | 835 | // we're creating event 6 after 5 and 4, so it has to be more recent (but it seems | 765 | // we're creating event 6 after 5 and 4, so it has to be more recent (but it seems |
692 | 836 | // that number of terms indexed matters as well, so careful with the relevancies) | 766 | // that number of terms indexed matters as well, so careful with the relevancies) |
695 | 837 | g_assert_cmpuint (event_id6, ==, | 767 | assert_nth_result_has_id (results, 0, event_id6); |
696 | 838 | zeitgeist_event_get_id ((ZeitgeistEvent*) results->pdata[0])); | 768 | } |
697 | 769 | |||
698 | 770 | static void | ||
699 | 771 | test_simple_move_event (Fixture *fix, gconstpointer data) | ||
700 | 772 | { | ||
701 | 773 | guint matches; | ||
702 | 774 | guint event_id; | ||
703 | 775 | ZeitgeistEvent* event; | ||
704 | 776 | |||
705 | 777 | // add test events to DBs | ||
706 | 778 | index_event (fix, create_test_event1 ()); | ||
707 | 779 | index_event (fix, create_test_event4 ()); | ||
708 | 780 | event_id = index_event (fix, create_test_event8 ()); | ||
709 | 781 | |||
710 | 782 | GPtrArray *results = search_simple (fix, "awesome", NULL, | ||
711 | 783 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); | ||
712 | 784 | |||
713 | 785 | g_assert_cmpuint (matches, >, 0); | ||
714 | 786 | g_assert_cmpuint (results->len, ==, 1); | ||
715 | 787 | assert_nth_result_has_id (results, 0, event_id); | ||
716 | 788 | } | ||
717 | 789 | |||
718 | 790 | static void | ||
719 | 791 | test_simple_most_recent (Fixture *fix, gconstpointer data) | ||
720 | 792 | { | ||
721 | 793 | guint matches; | ||
722 | 794 | guint event_id1, event_id2, event_id3, event_id4; | ||
723 | 795 | ZeitgeistEvent* event; | ||
724 | 796 | GPtrArray* results; | ||
725 | 797 | gdouble *relevancies; | ||
726 | 798 | gint relevancies_size; | ||
727 | 799 | |||
728 | 800 | // add test events to DBs | ||
729 | 801 | event_id1 = index_event (fix, create_test_event1 ()); | ||
730 | 802 | event_id2 = index_event (fix, create_test_event2 ()); | ||
731 | 803 | event_id3 = index_event (fix, create_test_event3 ()); | ||
732 | 804 | event_id4 = index_event (fix, create_test_event4 ()); | ||
733 | 805 | |||
734 | 806 | for (int i = 0; i < 4; ++i) | ||
735 | 807 | { | ||
736 | 808 | if (i == 0) | ||
737 | 809 | { | ||
738 | 810 | // Search for MostRecentEvents | ||
739 | 811 | results = search_simple (fix, "*text*", NULL, | ||
740 | 812 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, &matches); | ||
741 | 813 | } | ||
742 | 814 | else if (i == 1) | ||
743 | 815 | { | ||
744 | 816 | // Search for MostRecentSubjects | ||
745 | 817 | results = search_simple (fix, "*text*", NULL, | ||
746 | 818 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_SUBJECTS, &matches); | ||
747 | 819 | } | ||
748 | 820 | else if (i == 2) | ||
749 | 821 | { | ||
750 | 822 | // SearchWithRelevancies for MostRecentEvents | ||
751 | 823 | GPtrArray *results = search_with_relevancies_simple (fix, "*text*", NULL, | ||
752 | 824 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_EVENTS, | ||
753 | 825 | &relevancies, &relevancies_size, &matches); | ||
754 | 826 | } | ||
755 | 827 | else | ||
756 | 828 | { | ||
757 | 829 | // SearchWithRelevancies for MostRecentSubjects | ||
758 | 830 | GPtrArray *results = search_with_relevancies_simple (fix, "*text*", NULL, | ||
759 | 831 | ZEITGEIST_RESULT_TYPE_MOST_RECENT_SUBJECTS, | ||
760 | 832 | &relevancies, &relevancies_size, &matches); | ||
761 | 833 | } | ||
762 | 834 | |||
763 | 835 | g_assert_cmpuint (matches, >, 0); | ||
764 | 836 | g_assert_cmpuint (results->len, ==, 2); | ||
765 | 837 | assert_nth_result_has_id (results, 0, event_id4); | ||
766 | 838 | assert_nth_result_has_id (results, 1, event_id1); | ||
767 | 839 | } | ||
768 | 840 | } | ||
769 | 841 | |||
770 | 842 | static void | ||
771 | 843 | test_simple_least_recent (Fixture *fix, gconstpointer data) | ||
772 | 844 | { | ||
773 | 845 | guint matches; | ||
774 | 846 | guint event_id1, event_id2, event_id3, event_id4; | ||
775 | 847 | ZeitgeistEvent* event; | ||
776 | 848 | GPtrArray* results; | ||
777 | 849 | gdouble *relevancies; | ||
778 | 850 | gint relevancies_size; | ||
779 | 851 | |||
780 | 852 | // add test events to DBs | ||
781 | 853 | event_id1 = index_event (fix, create_test_event1 ()); | ||
782 | 854 | event_id2 = index_event (fix, create_test_event2 ()); | ||
783 | 855 | event_id3 = index_event (fix, create_test_event3 ()); | ||
784 | 856 | event_id4 = index_event (fix, create_test_event4 ()); | ||
785 | 857 | |||
786 | 858 | for (int i = 0; i < 4; ++i) | ||
787 | 859 | { | ||
788 | 860 | if (i == 0) | ||
789 | 861 | { | ||
790 | 862 | // Search for LeastRecentEvents | ||
791 | 863 | results = search_simple (fix, "*text*", NULL, | ||
792 | 864 | ZEITGEIST_RESULT_TYPE_LEAST_RECENT_EVENTS, &matches); | ||
793 | 865 | } | ||
794 | 866 | else if (i == 1) | ||
795 | 867 | { | ||
796 | 868 | // Search for LeastRecentSubjects | ||
797 | 869 | results = search_simple (fix, "*text*", NULL, | ||
798 | 870 | ZEITGEIST_RESULT_TYPE_LEAST_RECENT_SUBJECTS, &matches); | ||
799 | 871 | } | ||
800 | 872 | else if (i == 2) | ||
801 | 873 | { | ||
802 | 874 | // SearchWithRelevancies for LeastRecentEvents | ||
803 | 875 | GPtrArray *results = search_with_relevancies_simple (fix, "*text*", NULL, | ||
804 | 876 | ZEITGEIST_RESULT_TYPE_LEAST_RECENT_EVENTS, | ||
805 | 877 | &relevancies, &relevancies_size, &matches); | ||
806 | 878 | } | ||
807 | 879 | else | ||
808 | 880 | { | ||
809 | 881 | // SearchWithRelevancies for LeastRecentSubjects | ||
810 | 882 | GPtrArray *results = search_with_relevancies_simple (fix, "*text*", NULL, | ||
811 | 883 | ZEITGEIST_RESULT_TYPE_LEAST_RECENT_SUBJECTS, | ||
812 | 884 | &relevancies, &relevancies_size, &matches); | ||
813 | 885 | } | ||
814 | 886 | |||
815 | 887 | g_assert_cmpuint (matches, >, 0); | ||
816 | 888 | g_assert_cmpuint (results->len, ==, 2); | ||
817 | 889 | assert_nth_result_has_id (results, 0, event_id1); | ||
818 | 890 | assert_nth_result_has_id (results, 1, event_id4); | ||
819 | 891 | } | ||
820 | 839 | } | 892 | } |
821 | 840 | 893 | ||
822 | 841 | G_BEGIN_DECLS | 894 | G_BEGIN_DECLS |
823 | @@ -851,6 +904,10 @@ | |||
824 | 851 | { | 904 | { |
825 | 852 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleQuery", Fixture, 0, | 905 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleQuery", Fixture, 0, |
826 | 853 | setup, test_simple_query, teardown); | 906 | setup, test_simple_query, teardown); |
827 | 907 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleQueryEmptyDatabase", Fixture, 0, | ||
828 | 908 | setup, test_simple_query_empty_database, teardown); | ||
829 | 909 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleQueryNoResults", Fixture, 0, | ||
830 | 910 | setup, test_simple_query_no_results, teardown); | ||
831 | 854 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleWithFilter", Fixture, 0, | 911 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleWithFilter", Fixture, 0, |
832 | 855 | setup, test_simple_with_filter, teardown); | 912 | setup, test_simple_with_filter, teardown); |
833 | 856 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleWithValidFilter", Fixture, 0, | 913 | g_test_add ("/Zeitgeist/FTS/Indexer/SimpleWithValidFilter", Fixture, 0, |
834 | @@ -881,6 +938,12 @@ | |||
835 | 881 | setup, test_simple_relevancies_query, teardown); | 938 | setup, test_simple_relevancies_query, teardown); |
836 | 882 | g_test_add ("/Zeitgeist/FTS/Indexer/RelevanciesSubject", Fixture, 0, | 939 | g_test_add ("/Zeitgeist/FTS/Indexer/RelevanciesSubject", Fixture, 0, |
837 | 883 | setup, test_simple_relevancies_subject_query, teardown); | 940 | setup, test_simple_relevancies_subject_query, teardown); |
838 | 941 | g_test_add ("/Zeitgeist/FTS/Indexer/MoveEvent", Fixture, 0, | ||
839 | 942 | setup, test_simple_move_event, teardown); | ||
840 | 943 | g_test_add ("/Zeitgeist/FTS/Indexer/MostRecent", Fixture, 0, | ||
841 | 944 | setup, test_simple_most_recent, teardown); | ||
842 | 945 | g_test_add ("/Zeitgeist/FTS/Indexer/LeastRecent", Fixture, 0, | ||
843 | 946 | setup, test_simple_least_recent, teardown); | ||
844 | 884 | 947 | ||
845 | 885 | // get rid of the "rebuilding index..." messages | 948 | // get rid of the "rebuilding index..." messages |
846 | 886 | g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL); | 949 | g_log_set_handler (NULL, G_LOG_LEVEL_MESSAGE, discard_message, NULL); |
847 | 887 | 950 | ||
848 | === modified file 'test/dbus/engine-test.py' | |||
849 | --- test/dbus/engine-test.py 2012-01-02 07:42:53 +0000 | |||
850 | +++ test/dbus/engine-test.py 2012-03-16 18:46:19 +0000 | |||
851 | @@ -134,7 +134,7 @@ | |||
852 | 134 | 134 | ||
853 | 135 | def testIllegalPredefinedEventId(self): | 135 | def testIllegalPredefinedEventId(self): |
854 | 136 | event = Event() | 136 | event = Event() |
856 | 137 | event[0][0] = str(23) # This is illegal, we assert the erro later | 137 | event[0][0] = str(23) # This is illegal, we assert the error later |
857 | 138 | event.timestamp = 0 | 138 | event.timestamp = 0 |
858 | 139 | event.interpretation = Manifestation.USER_ACTIVITY | 139 | event.interpretation = Manifestation.USER_ACTIVITY |
859 | 140 | event.manifestation = Interpretation.CREATE_EVENT | 140 | event.manifestation = Interpretation.CREATE_EVENT |
Outstanding issue: Should CompileEventFil terQuery also be changed to use current_uri instead (or in addition to?) uri?