tracker-0.16.2/tests/libtracker-miner/tracker-indexing-tree-test.c

No issues found

  1 /*
  2  * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU General Public License
  6  * as published by the Free Software Foundation; either version 2
  7  * of the License, or (at your option) any later version.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  * GNU General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU General Public License
 15  * along with this program; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 17  * 02110-1301, USA.
 18  */
 19 
 20 #include <string.h>
 21 #include <unistd.h>
 22 
 23 #include <glib.h>
 24 #include <glib/gstdio.h>
 25 
 26 #include <libtracker-miner/tracker-indexing-tree.h>
 27 
 28 /*
 29  * Test directory structure:
 30  *  - Directory A
 31  *     -- Directory AA
 32  *         --- Directory AAA
 33  *              ---- Directory AAAA
 34  *              ---- Directory AAAB
 35  *         --- Directory AAB
 36  *     -- Directory AB
 37  *         --- Directory ABA
 38  *         --- Directory ABB
 39  */
 40 typedef enum {
 41 	TEST_DIRECTORY_A = 0,
 42 	TEST_DIRECTORY_AA,
 43 	TEST_DIRECTORY_AAA,
 44 	TEST_DIRECTORY_AAAA,
 45 	TEST_DIRECTORY_AAAB,
 46 	TEST_DIRECTORY_AAB,
 47 	TEST_DIRECTORY_AB,
 48 	TEST_DIRECTORY_ABA,
 49 	TEST_DIRECTORY_ABB,
 50 	TEST_DIRECTORY_LAST
 51 } TestDirectory;
 52 
 53 /* Fixture struct */
 54 typedef struct {
 55 	/* Array with all existing test directories */
 56 	GFile *test_dir[TEST_DIRECTORY_LAST];
 57 	/* The tree to test */
 58 	TrackerIndexingTree *tree;
 59 } TestCommonContext;
 60 
 61 #define ASSERT_INDEXABLE(fixture, id)	  \
 62 	g_assert (tracker_indexing_tree_file_is_indexable (fixture->tree, \
 63 	                                                   fixture->test_dir[id], \
 64 	                                                   G_FILE_TYPE_DIRECTORY) == TRUE)
 65 #define ASSERT_NOT_INDEXABLE(fixture, id)	  \
 66 	g_assert (tracker_indexing_tree_file_is_indexable (fixture->tree, \
 67 	                                                   fixture->test_dir[id], \
 68 	                                                   G_FILE_TYPE_DIRECTORY) == FALSE)
 69 
 70 #define test_add(path,fun)	  \
 71 	g_test_add (path, \
 72 	            TestCommonContext, \
 73 	            NULL, \
 74 	            test_common_context_setup, \
 75 	            fun, \
 76 	            test_common_context_teardown)
 77 
 78 static void
 79 test_common_context_setup (TestCommonContext *fixture,
 80                            gconstpointer      data)
 81 {
 82 	guint i;
 83 	static const gchar *test_directories_subpaths [TEST_DIRECTORY_LAST] = {
 84 		"/A",
 85 		"/A/A",
 86 		"/A/A/A",
 87 		"/A/A/A/A",
 88 		"/A/A/A/B",
 89 		"/A/A/B",
 90 		"/A/B/",
 91 		"/A/B/A",
 92 		"/A/B/B"
 93 	};
 94 
 95 	/* Initialize aux directories */
 96 	for (i = 0; i < TEST_DIRECTORY_LAST; i++)
 97 		fixture->test_dir[i] = g_file_new_for_path (test_directories_subpaths[i]);
 98 
 99 	fixture->tree = tracker_indexing_tree_new ();
100 }
101 
102 static void
103 test_common_context_teardown (TestCommonContext *fixture,
104                               gconstpointer      data)
105 {
106 	gint i;
107 
108 	/* Deinit aux directories, from last to first */
109 	for (i = TEST_DIRECTORY_LAST-1; i >= 0; i--) {
110 		if (fixture->test_dir[i])
111 			g_object_unref (fixture->test_dir[i]);
112 	}
113 
114 	if (fixture->tree)
115 		g_object_unref (fixture->tree);
116 }
117 
118 /* If A is ignored,
119  *  -A, AA, AB, AAA, AAB, ABA and ABB are not indexable
120  */
121 static void
122 test_indexing_tree_001 (TestCommonContext *fixture,
123                         gconstpointer      data)
124 {
125 	tracker_indexing_tree_add (fixture->tree,
126 	                           fixture->test_dir[TEST_DIRECTORY_A],
127 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
128 
129 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
130 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
131 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
132 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
133 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
134 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
135 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
136 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
137 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
138 }
139 
140 /* If A is monitored (NOT recursively):
141  *  -A, AA, AB are indexable
142  *  -AAA, AAB, ABA and ABB are not indexable
143  */
144 static void
145 test_indexing_tree_002 (TestCommonContext *fixture,
146                         gconstpointer      data)
147 {
148 	tracker_indexing_tree_add (fixture->tree,
149 	                           fixture->test_dir[TEST_DIRECTORY_A],
150 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
151 
152 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
153 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
154 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
155 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
156 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
157 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
158 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
159 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
160 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
161 }
162 
163 /* If A is monitored (recursively):
164  *  -A, AA, AB, AAA, AAB, ABA and ABB are indexable
165  */
166 static void
167 test_indexing_tree_003 (TestCommonContext *fixture,
168                         gconstpointer      data)
169 {
170 	tracker_indexing_tree_add (fixture->tree,
171 	                           fixture->test_dir[TEST_DIRECTORY_A],
172 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
173 
174 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
175 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
176 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
177 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
178 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
179 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
180 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
181 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
182 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
183 }
184 
185 /* If A is ignored and AA is ignored:
186  *  -A, AA, AB, AAA, AAB, ABA and ABB are not indexable
187  */
188 static void
189 test_indexing_tree_004 (TestCommonContext *fixture,
190                         gconstpointer      data)
191 {
192 	tracker_indexing_tree_add (fixture->tree,
193 	                           fixture->test_dir[TEST_DIRECTORY_A],
194 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
195 	tracker_indexing_tree_add (fixture->tree,
196 	                           fixture->test_dir[TEST_DIRECTORY_AA],
197 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
198 
199 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
200 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
201 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
202 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
203 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
204 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
205 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
206 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
207 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
208 }
209 
210 /* If A is ignored and AA is monitored (not recursively):
211  *  -AA, AAA, AAB are indexable
212  *  -A, AAAA, AAAB, AB, ABA, ABB are not indexable
213  */
214 static void
215 test_indexing_tree_005 (TestCommonContext *fixture,
216                         gconstpointer      data)
217 {
218 	tracker_indexing_tree_add (fixture->tree,
219 	                           fixture->test_dir[TEST_DIRECTORY_A],
220 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
221 	tracker_indexing_tree_add (fixture->tree,
222 	                           fixture->test_dir[TEST_DIRECTORY_AA],
223 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
224 
225 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
226 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
227 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
228 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
229 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
230 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
231 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
232 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
233 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
234 }
235 
236 /* If A is ignored and AA is monitored (recursively):
237  *  -AA, AAA, AAAA, AAAB, AAB are indexable
238  *  -A, AB, ABA, ABB are not indexable
239  */
240 static void
241 test_indexing_tree_006 (TestCommonContext *fixture,
242                         gconstpointer      data)
243 {
244 	tracker_indexing_tree_add (fixture->tree,
245 	                           fixture->test_dir[TEST_DIRECTORY_A],
246 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
247 	tracker_indexing_tree_add (fixture->tree,
248 	                           fixture->test_dir[TEST_DIRECTORY_AA],
249 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
250 
251 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
252 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
253 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
254 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
255 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
256 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
257 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
258 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
259 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
260 }
261 
262 /* If A is monitored (not recursively) and AA is ignored:
263  *  -A and AB are indexable
264  *  -AA, AAA, AAAA, AAAB, AAB, ABA, ABB are not indexable
265  */
266 static void
267 test_indexing_tree_007 (TestCommonContext *fixture,
268                         gconstpointer      data)
269 {
270 	tracker_indexing_tree_add (fixture->tree,
271 	                           fixture->test_dir[TEST_DIRECTORY_A],
272 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
273 	tracker_indexing_tree_add (fixture->tree,
274 	                           fixture->test_dir[TEST_DIRECTORY_AA],
275 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
276 
277 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
278 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
279 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
280 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
281 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
282 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
283 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
284 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
285 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
286 }
287 
288 /* If A is monitored (not recursively) and AA is monitored (not recursively):
289  *  -A, AA, AAA, AAB, AB are indexable
290  *  -AAAA, AAAB, ABA, ABB are not indexable
291  */
292 static void
293 test_indexing_tree_008 (TestCommonContext *fixture,
294                         gconstpointer      data)
295 {
296 	tracker_indexing_tree_add (fixture->tree,
297 	                           fixture->test_dir[TEST_DIRECTORY_A],
298 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
299 	tracker_indexing_tree_add (fixture->tree,
300 	                           fixture->test_dir[TEST_DIRECTORY_AA],
301 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
302 
303 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
304 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
305 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
306 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
307 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
308 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
309 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
310 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
311 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
312 }
313 
314 /* If A is monitored (not recursively) and AA is monitored (recursively):
315  *  -A, AA, AAA, AAAA, AAAB, AAB, AB are indexable
316  *  -ABA, ABB are not indexable
317  */
318 static void
319 test_indexing_tree_009 (TestCommonContext *fixture,
320                         gconstpointer      data)
321 {
322 	tracker_indexing_tree_add (fixture->tree,
323 	                           fixture->test_dir[TEST_DIRECTORY_A],
324 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
325 	tracker_indexing_tree_add (fixture->tree,
326 	                           fixture->test_dir[TEST_DIRECTORY_AA],
327 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
328 
329 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
330 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
331 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
332 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
333 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
334 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
335 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
336 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
337 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
338 }
339 
340 /* If A is monitored (recursively) and AA is ignored:
341  *  -A, AB, ABA, ABB are indexable
342  *  -AA, AAA, AAAA, AAAB, AAB are not indexable
343  */
344 static void
345 test_indexing_tree_010 (TestCommonContext *fixture,
346                         gconstpointer      data)
347 {
348 	tracker_indexing_tree_add (fixture->tree,
349 	                           fixture->test_dir[TEST_DIRECTORY_A],
350 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
351 	tracker_indexing_tree_add (fixture->tree,
352 	                           fixture->test_dir[TEST_DIRECTORY_AA],
353 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
354 
355 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
356 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
357 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
358 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
359 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
360 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
361 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
362 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
363 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
364 }
365 
366 /* If A is monitored (recursively) and AA is monitored (not recursively):
367  *  -A, AA, AAA, AAB, AB, ABA, ABB are indexable
368  *  -AAAA, AAAB are not indexable
369  */
370 static void
371 test_indexing_tree_011 (TestCommonContext *fixture,
372                         gconstpointer      data)
373 {
374 	tracker_indexing_tree_add (fixture->tree,
375 	                           fixture->test_dir[TEST_DIRECTORY_A],
376 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
377 	tracker_indexing_tree_add (fixture->tree,
378 	                           fixture->test_dir[TEST_DIRECTORY_AA],
379 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
380 
381 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
382 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
383 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
384 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
385 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
386 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
387 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
388 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
389 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
390 }
391 
392 /* If A is monitored (recursively) and AA is monitored (recursively):
393  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA, ABB are indexable
394  */
395 static void
396 test_indexing_tree_012 (TestCommonContext *fixture,
397                         gconstpointer      data)
398 {
399 	tracker_indexing_tree_add (fixture->tree,
400 	                           fixture->test_dir[TEST_DIRECTORY_A],
401 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
402 	tracker_indexing_tree_add (fixture->tree,
403 	                           fixture->test_dir[TEST_DIRECTORY_AA],
404 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
405 
406 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
407 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
408 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
409 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
410 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
411 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
412 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
413 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
414 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
415 }
416 
417 /* If A is ignored and AA is ignored, then A is removed from tree
418  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
419  */
420 static void
421 test_indexing_tree_013 (TestCommonContext *fixture,
422                         gconstpointer      data)
423 {
424 	tracker_indexing_tree_add (fixture->tree,
425 	                           fixture->test_dir[TEST_DIRECTORY_A],
426 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
427 	tracker_indexing_tree_add (fixture->tree,
428 	                           fixture->test_dir[TEST_DIRECTORY_AA],
429 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
430 
431 	tracker_indexing_tree_remove (fixture->tree,
432 	                              fixture->test_dir[TEST_DIRECTORY_A]);
433 
434 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
435 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
436 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
437 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
438 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
439 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
440 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
441 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
442 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
443 }
444 
445 /* If A is ignored and AA is ignored, then AA is removed from tree
446  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
447  */
448 static void
449 test_indexing_tree_014 (TestCommonContext *fixture,
450                         gconstpointer      data)
451 {
452 	tracker_indexing_tree_add (fixture->tree,
453 	                           fixture->test_dir[TEST_DIRECTORY_A],
454 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
455 	tracker_indexing_tree_add (fixture->tree,
456 	                           fixture->test_dir[TEST_DIRECTORY_AA],
457 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
458 
459 	tracker_indexing_tree_remove (fixture->tree,
460 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
461 
462 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
463 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
464 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
465 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
466 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
467 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
468 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
469 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
470 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
471 }
472 
473 /* If A is ignored and AA is monitored (not recursively), then A is removed
474  * from tree.
475  *  -AA, AAA, AAB are indexable
476  *  -A, AAAA, AAAB, AB, ABA and ABB are not indexable
477  */
478 static void
479 test_indexing_tree_015 (TestCommonContext *fixture,
480                         gconstpointer      data)
481 {
482 	tracker_indexing_tree_add (fixture->tree,
483 	                           fixture->test_dir[TEST_DIRECTORY_A],
484 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
485 	tracker_indexing_tree_add (fixture->tree,
486 	                           fixture->test_dir[TEST_DIRECTORY_AA],
487 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
488 
489 	tracker_indexing_tree_remove (fixture->tree,
490 	                              fixture->test_dir[TEST_DIRECTORY_A]);
491 
492 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
493 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
494 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
495 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
496 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
497 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
498 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
499 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
500 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
501 }
502 
503 /* If A is ignored and AA is monitored (not recursively), then AA is removed
504  * from tree.
505  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
506  */
507 static void
508 test_indexing_tree_016 (TestCommonContext *fixture,
509                         gconstpointer      data)
510 {
511 	tracker_indexing_tree_add (fixture->tree,
512 	                           fixture->test_dir[TEST_DIRECTORY_A],
513 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
514 	tracker_indexing_tree_add (fixture->tree,
515 	                           fixture->test_dir[TEST_DIRECTORY_AA],
516 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
517 
518 	tracker_indexing_tree_remove (fixture->tree,
519 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
520 
521 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
522 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
523 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
524 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
525 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
526 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
527 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
528 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
529 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
530 }
531 
532 /* If A is ignored and AA is monitored (recursively), then A is removed from
533  * tree.
534  *  -AA, AAA, AAAA, AAAB, AAB are indexable
535  *  -A, AB, ABA and ABB are not indexable
536  */
537 static void
538 test_indexing_tree_017 (TestCommonContext *fixture,
539                         gconstpointer      data)
540 {
541 	tracker_indexing_tree_add (fixture->tree,
542 	                           fixture->test_dir[TEST_DIRECTORY_A],
543 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
544 	tracker_indexing_tree_add (fixture->tree,
545 	                           fixture->test_dir[TEST_DIRECTORY_AA],
546 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
547 
548 	tracker_indexing_tree_remove (fixture->tree,
549 	                              fixture->test_dir[TEST_DIRECTORY_A]);
550 
551 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
552 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
553 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
554 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
555 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
556 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
557 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
558 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
559 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
560 }
561 
562 /* If A is ignored and AA is monitored (recursively), then AA is removed
563  * from tree.
564  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
565  */
566 static void
567 test_indexing_tree_018 (TestCommonContext *fixture,
568                         gconstpointer      data)
569 {
570 	tracker_indexing_tree_add (fixture->tree,
571 	                           fixture->test_dir[TEST_DIRECTORY_A],
572 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
573 	tracker_indexing_tree_add (fixture->tree,
574 	                           fixture->test_dir[TEST_DIRECTORY_AA],
575 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
576 
577 	tracker_indexing_tree_remove (fixture->tree,
578 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
579 
580 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
581 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
582 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
583 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
584 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
585 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
586 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
587 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
588 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
589 }
590 
591 /* If A is monitored (not recursively) and AA is ignored, then A is removed
592  * from tree.
593  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
594  */
595 static void
596 test_indexing_tree_019 (TestCommonContext *fixture,
597                         gconstpointer      data)
598 {
599 	tracker_indexing_tree_add (fixture->tree,
600 	                           fixture->test_dir[TEST_DIRECTORY_A],
601 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
602 	tracker_indexing_tree_add (fixture->tree,
603 	                           fixture->test_dir[TEST_DIRECTORY_AA],
604 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
605 
606 	tracker_indexing_tree_remove (fixture->tree,
607 	                              fixture->test_dir[TEST_DIRECTORY_A]);
608 
609 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
610 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
611 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
612 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
613 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
614 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
615 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
616 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
617 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
618 }
619 
620 /* If A is monitored (not recursively) and AA is ignored, then AA is removed
621  * from tree.
622  *  -A, AA, AB are indexable.
623  *  -AAA, AAAA, AAAB, AAB, ABA and ABB are not indexable
624  */
625 static void
626 test_indexing_tree_020 (TestCommonContext *fixture,
627                         gconstpointer      data)
628 {
629 	tracker_indexing_tree_add (fixture->tree,
630 	                           fixture->test_dir[TEST_DIRECTORY_A],
631 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
632 	tracker_indexing_tree_add (fixture->tree,
633 	                           fixture->test_dir[TEST_DIRECTORY_AA],
634 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
635 
636 	tracker_indexing_tree_remove (fixture->tree,
637 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
638 
639 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
640 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
641 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
642 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
643 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
644 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
645 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
646 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
647 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
648 }
649 
650 /* If A is monitored (not recursively) and AA is monitored (not recursively),
651  *  then A is removed from tree.
652  *  -AA, AAA, AAB are indexable.
653  *  -A, AAAA, AAAB, AB, ABA and ABB are not indexable
654  */
655 static void
656 test_indexing_tree_021 (TestCommonContext *fixture,
657                         gconstpointer      data)
658 {
659 	tracker_indexing_tree_add (fixture->tree,
660 	                           fixture->test_dir[TEST_DIRECTORY_A],
661 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
662 	tracker_indexing_tree_add (fixture->tree,
663 	                           fixture->test_dir[TEST_DIRECTORY_AA],
664 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
665 
666 	tracker_indexing_tree_remove (fixture->tree,
667 	                              fixture->test_dir[TEST_DIRECTORY_A]);
668 
669 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
670 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
671 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
672 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
673 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
674 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
675 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
676 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
677 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
678 }
679 
680 /* If A is monitored (not recursively) and AA is monitored (not recursively),
681  *  then AA is removed from tree.
682  *  -A, AA, AB are indexable.
683  *  -AAA, AAAA, AAAB, AAB, ABA and ABB are not indexable
684  */
685 static void
686 test_indexing_tree_022 (TestCommonContext *fixture,
687                         gconstpointer      data)
688 {
689 	tracker_indexing_tree_add (fixture->tree,
690 	                           fixture->test_dir[TEST_DIRECTORY_A],
691 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
692 	tracker_indexing_tree_add (fixture->tree,
693 	                           fixture->test_dir[TEST_DIRECTORY_AA],
694 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
695 
696 	tracker_indexing_tree_remove (fixture->tree,
697 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
698 
699 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
700 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
701 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
702 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
703 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
704 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
705 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
706 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
707 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
708 }
709 
710 /* If A is monitored (not recursively) and AA is monitored (recursively),
711  *  then A is removed from tree.
712  *  -AA, AAA, AAAA, AAAB, AAB are indexable.
713  *  -A, AB, ABA and ABB are not indexable
714  */
715 static void
716 test_indexing_tree_023 (TestCommonContext *fixture,
717                         gconstpointer      data)
718 {
719 	tracker_indexing_tree_add (fixture->tree,
720 	                           fixture->test_dir[TEST_DIRECTORY_A],
721 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
722 	tracker_indexing_tree_add (fixture->tree,
723 	                           fixture->test_dir[TEST_DIRECTORY_AA],
724 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
725 
726 	tracker_indexing_tree_remove (fixture->tree,
727 	                              fixture->test_dir[TEST_DIRECTORY_A]);
728 
729 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
730 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
731 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
732 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
733 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
734 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
735 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
736 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
737 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
738 }
739 
740 /* If A is monitored (not recursively) and AA is monitored (recursively),
741  *  then AA is removed from tree.
742  *  -A, AA, AB are indexable.
743  *  -AAA, AAAA, AAAB, AAB, ABA and ABB are not indexable
744  */
745 static void
746 test_indexing_tree_024 (TestCommonContext *fixture,
747                         gconstpointer      data)
748 {
749 	tracker_indexing_tree_add (fixture->tree,
750 	                           fixture->test_dir[TEST_DIRECTORY_A],
751 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
752 	tracker_indexing_tree_add (fixture->tree,
753 	                           fixture->test_dir[TEST_DIRECTORY_AA],
754 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
755 
756 	tracker_indexing_tree_remove (fixture->tree,
757 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
758 
759 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
760 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
761 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
762 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
763 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
764 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
765 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
766 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
767 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
768 }
769 
770 /* If A is monitored (recursively) and AA is ignored, then A is removed
771  * from tree.
772  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are not indexable
773  */
774 static void
775 test_indexing_tree_025 (TestCommonContext *fixture,
776                         gconstpointer      data)
777 {
778 	tracker_indexing_tree_add (fixture->tree,
779 	                           fixture->test_dir[TEST_DIRECTORY_A],
780 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
781 	tracker_indexing_tree_add (fixture->tree,
782 	                           fixture->test_dir[TEST_DIRECTORY_AA],
783 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
784 
785 	tracker_indexing_tree_remove (fixture->tree,
786 	                              fixture->test_dir[TEST_DIRECTORY_A]);
787 
788 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
789 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
790 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
791 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
792 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
793 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
794 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
795 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
796 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
797 }
798 
799 /* If A is monitored (recursively) and AA is ignored, then AA is removed
800  * from tree.
801  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are indexable
802  */
803 static void
804 test_indexing_tree_026 (TestCommonContext *fixture,
805                         gconstpointer      data)
806 {
807 	tracker_indexing_tree_add (fixture->tree,
808 	                           fixture->test_dir[TEST_DIRECTORY_A],
809 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
810 	tracker_indexing_tree_add (fixture->tree,
811 	                           fixture->test_dir[TEST_DIRECTORY_AA],
812 	                           TRACKER_DIRECTORY_FLAG_IGNORE);
813 
814 	tracker_indexing_tree_remove (fixture->tree,
815 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
816 
817 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
818 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
819 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
820 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
821 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
822 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
823 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
824 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
825 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
826 }
827 
828 /* If A is monitored (recursively) and AA is monitored (not recursively), then
829  *  A is removed from tree.
830  *  -AA, AAA, AAB are indexable
831  *  -A, AAAA, AAAB, AB, ABA and ABB are not indexable
832  */
833 static void
834 test_indexing_tree_027 (TestCommonContext *fixture,
835                         gconstpointer      data)
836 {
837 	tracker_indexing_tree_add (fixture->tree,
838 	                           fixture->test_dir[TEST_DIRECTORY_A],
839 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
840 	tracker_indexing_tree_add (fixture->tree,
841 	                           fixture->test_dir[TEST_DIRECTORY_AA],
842 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
843 
844 	tracker_indexing_tree_remove (fixture->tree,
845 	                              fixture->test_dir[TEST_DIRECTORY_A]);
846 
847 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
848 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
849 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
850 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
851 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
852 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
853 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
854 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
855 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
856 }
857 
858 /* If A is monitored (recursively) and AA is monitored (not recursively), then
859  *  AA is removed from tree.
860  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are indexable
861  */
862 static void
863 test_indexing_tree_028 (TestCommonContext *fixture,
864                         gconstpointer      data)
865 {
866 	tracker_indexing_tree_add (fixture->tree,
867 	                           fixture->test_dir[TEST_DIRECTORY_A],
868 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
869 	tracker_indexing_tree_add (fixture->tree,
870 	                           fixture->test_dir[TEST_DIRECTORY_AA],
871 	                           TRACKER_DIRECTORY_FLAG_MONITOR);
872 
873 	tracker_indexing_tree_remove (fixture->tree,
874 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
875 
876 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
877 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
878 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
879 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
880 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
881 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
882 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
883 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
884 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
885 }
886 
887 /* If A is monitored (recursively) and AA is monitored (recursively),
888  * then A is removed from tree.
889  *  -AA, AAA, AAAA, AAAB, AAB are indexable
890  *  -A, AB, ABA and ABB are not indexable
891  */
892 static void
893 test_indexing_tree_029 (TestCommonContext *fixture,
894                         gconstpointer      data)
895 {
896 	tracker_indexing_tree_add (fixture->tree,
897 	                           fixture->test_dir[TEST_DIRECTORY_A],
898 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
899 	tracker_indexing_tree_add (fixture->tree,
900 	                           fixture->test_dir[TEST_DIRECTORY_AA],
901 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
902 
903 	tracker_indexing_tree_remove (fixture->tree,
904 	                              fixture->test_dir[TEST_DIRECTORY_A]);
905 
906 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_A);
907 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
908 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
909 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
910 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
911 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
912 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
913 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
914 	ASSERT_NOT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
915 }
916 
917 /* If A is monitored (recursively) and AA is monitored (recursively),
918  * then AA is removed from tree.
919  *  -A, AA, AAA, AAAA, AAAB, AAB, AB, ABA and ABB are indexable
920  */
921 static void
922 test_indexing_tree_030 (TestCommonContext *fixture,
923                         gconstpointer      data)
924 {
925 	tracker_indexing_tree_add (fixture->tree,
926 	                           fixture->test_dir[TEST_DIRECTORY_A],
927 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
928 	tracker_indexing_tree_add (fixture->tree,
929 	                           fixture->test_dir[TEST_DIRECTORY_AA],
930 	                           TRACKER_DIRECTORY_FLAG_MONITOR | TRACKER_DIRECTORY_FLAG_RECURSE);
931 
932 	tracker_indexing_tree_remove (fixture->tree,
933 	                              fixture->test_dir[TEST_DIRECTORY_AA]);
934 
935 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_A);
936 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AA);
937 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAA);
938 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAA);
939 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAAB);
940 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AAB);
941 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_AB);
942 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
943 	ASSERT_INDEXABLE (fixture, TEST_DIRECTORY_ABA);
944 }
945 
946 gint
947 main (gint    argc,
948       gchar **argv)
949 {
950 	g_test_init (&argc, &argv, NULL);
951 
952 	g_test_message ("Testing indexing tree");
953 
954 	test_add ("/libtracker-miner/indexing-tree/001", test_indexing_tree_001);
955 	test_add ("/libtracker-miner/indexing-tree/002", test_indexing_tree_002);
956 	test_add ("/libtracker-miner/indexing-tree/003", test_indexing_tree_003);
957 	test_add ("/libtracker-miner/indexing-tree/004", test_indexing_tree_004);
958 	test_add ("/libtracker-miner/indexing-tree/005", test_indexing_tree_005);
959 	test_add ("/libtracker-miner/indexing-tree/006", test_indexing_tree_006);
960 	test_add ("/libtracker-miner/indexing-tree/007", test_indexing_tree_007);
961 	test_add ("/libtracker-miner/indexing-tree/008", test_indexing_tree_008);
962 	test_add ("/libtracker-miner/indexing-tree/009", test_indexing_tree_009);
963 	test_add ("/libtracker-miner/indexing-tree/010", test_indexing_tree_010);
964 	test_add ("/libtracker-miner/indexing-tree/011", test_indexing_tree_011);
965 	test_add ("/libtracker-miner/indexing-tree/012", test_indexing_tree_012);
966 	test_add ("/libtracker-miner/indexing-tree/013", test_indexing_tree_013);
967 	test_add ("/libtracker-miner/indexing-tree/014", test_indexing_tree_014);
968 	test_add ("/libtracker-miner/indexing-tree/015", test_indexing_tree_015);
969 	test_add ("/libtracker-miner/indexing-tree/016", test_indexing_tree_016);
970 	test_add ("/libtracker-miner/indexing-tree/017", test_indexing_tree_017);
971 	test_add ("/libtracker-miner/indexing-tree/018", test_indexing_tree_018);
972 	test_add ("/libtracker-miner/indexing-tree/019", test_indexing_tree_019);
973 	test_add ("/libtracker-miner/indexing-tree/020", test_indexing_tree_020);
974 	test_add ("/libtracker-miner/indexing-tree/021", test_indexing_tree_021);
975 	test_add ("/libtracker-miner/indexing-tree/022", test_indexing_tree_022);
976 	test_add ("/libtracker-miner/indexing-tree/023", test_indexing_tree_023);
977 	test_add ("/libtracker-miner/indexing-tree/024", test_indexing_tree_024);
978 	test_add ("/libtracker-miner/indexing-tree/025", test_indexing_tree_025);
979 	test_add ("/libtracker-miner/indexing-tree/026", test_indexing_tree_026);
980 	test_add ("/libtracker-miner/indexing-tree/027", test_indexing_tree_027);
981 	test_add ("/libtracker-miner/indexing-tree/028", test_indexing_tree_028);
982 	test_add ("/libtracker-miner/indexing-tree/029", test_indexing_tree_029);
983 	test_add ("/libtracker-miner/indexing-tree/030", test_indexing_tree_030);
984 
985 	return g_test_run ();
986 }