tracker-0.16.2/tests/libtracker-extract/tracker-extract-info-test.c

No issues found

 1 /*
 2  * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
 3  *
 4  * This library is free software; you can redistribute it and/or
 5  * modify it under the terms of the GNU Lesser General Public
 6  * License as published by the Free Software Foundation; either
 7  * version 2.1 of the License, or (at your option) any later version.
 8  *
 9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 
20 #include <glib.h>
21 
22 #include <libtracker-extract/tracker-extract.h>
23 
24 static void
25 test_extract_info_setters (void)
26 {
27         TrackerExtractInfo *info, *info_ref;
28         GFile *file;
29 
30         file = g_file_new_for_path ("./imaginary-file-2");
31 
32         info = tracker_extract_info_new (file, "imaginary/mime", "test-graph");
33         info_ref = tracker_extract_info_ref (info);
34 
35         g_assert (g_file_equal (file, tracker_extract_info_get_file (info)));
36 
37         g_assert_cmpstr (tracker_extract_info_get_mimetype (info), ==, "imaginary/mime");
38         g_assert_cmpstr (tracker_extract_info_get_graph (info), ==, "test-graph");
39         g_assert (tracker_extract_info_get_preupdate_builder (info));
40         g_assert (tracker_extract_info_get_postupdate_builder (info));
41         g_assert (tracker_extract_info_get_metadata_builder (info));
42 
43         g_assert (!tracker_extract_info_get_where_clause (info));
44         tracker_extract_info_set_where_clause (info, "where stuff");
45         g_assert_cmpstr (tracker_extract_info_get_where_clause (info), ==, "where stuff");
46 
47         tracker_extract_info_unref (info_ref);
48         tracker_extract_info_unref (info);
49 
50         g_object_unref (file);
51 }
52 
53 static void
54 test_extract_info_empty_objects (void)
55 {
56         TrackerExtractInfo *info, *info_ref;
57         GFile *file;
58 
59         file = g_file_new_for_path ("./imaginary-file");
60 
61         info = tracker_extract_info_new (file, "imaginary/mime", "test-graph");
62         info_ref = tracker_extract_info_ref (info);
63 
64         tracker_extract_info_unref (info_ref);
65         tracker_extract_info_unref (info);
66 
67         g_object_unref (file);
68 }
69 
70 int
71 main (int argc, char **argv)
72 {
73         g_test_init (&argc, &argv, NULL);
74 
75         g_test_add_func ("/libtracker-extract/extract-info/empty_objects",
76                          test_extract_info_empty_objects);
77         g_test_add_func ("/libtracker-extract/extract-info/setters",
78                          test_extract_info_setters);
79 
80         return g_test_run ();
81 }