No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | tracker-miner-manager-test.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * Copyright (C) 2010, 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 <glib.h>
21 #include <glib-object.h>
22 #include <libtracker-miner/tracker-miner.h>
23 #include "miners-mock.h"
24
25
26 /*
27 * miners-mock.c implements the DBus magic and has hardcoded
28 * some test data.
29 */
30
31
32 TrackerMinerManager *manager = NULL;
33
34 #if 0
35 /* Todo: port miners-mock.c first */
36
37 static void
38 test_miner_manager_get_running ()
39 {
40 GSList *running_miners;
41
42 running_miners = tracker_miner_manager_get_running (manager);
43
44 g_assert_cmpint (g_slist_length (running_miners), ==, 1);
45 g_assert_cmpstr (running_miners->data, ==, MOCK_MINER_1);
46 }
47
48 static void
49 test_miner_manager_get_available ()
50 {
51
52 GSList *available_miners;
53 GSList *item;
54
55 available_miners = tracker_miner_manager_get_available (manager);
56
57 g_assert_cmpint (g_slist_length (available_miners), ==, 2);
58
59 item = g_slist_find_custom (available_miners,
60 MOCK_MINER_1,
61 (GCompareFunc) g_strcmp0);
62 g_assert (item != NULL);
63
64 item = g_slist_find_custom (available_miners,
65 MOCK_MINER_2,
66 (GCompareFunc) g_strcmp0);
67 g_assert (item != NULL);
68 }
69
70 static void
71 test_miner_manager_is_active ()
72 {
73 g_assert (tracker_miner_manager_is_active (manager, MOCK_MINER_1));
74 g_assert (!tracker_miner_manager_is_active (manager, MOCK_MINER_2));
75 }
76
77 static void
78 test_miner_manager_pause_resume ()
79 {
80 GStrv *apps = NULL, *reasons = NULL;
81 guint32 cookie;
82
83 g_assert (tracker_miner_manager_is_active (manager, MOCK_MINER_1));
84 g_assert (!tracker_miner_manager_is_paused (manager, MOCK_MINER_1, apps, reasons));
85
86 tracker_miner_manager_pause (manager, MOCK_MINER_1, "Testing pause", &cookie);
87
88 g_assert (!tracker_miner_manager_is_active (manager, MOCK_MINER_1));
89 g_assert (tracker_miner_manager_is_paused (manager, MOCK_MINER_1, apps, reasons));
90
91 tracker_miner_manager_resume (manager, MOCK_MINER_1, cookie);
92
93 g_assert (tracker_miner_manager_is_active (manager, MOCK_MINER_1));
94 g_assert (!tracker_miner_manager_is_paused (manager, MOCK_MINER_1, apps, reasons));
95 }
96
97 static void
98 test_miner_manager_getters ()
99 {
100 const gchar *result;
101
102 result = tracker_miner_manager_get_display_name (manager, MOCK_MINER_1);
103 g_assert_cmpstr (result, ==, "Mock miner for testing");
104
105 result = tracker_miner_manager_get_description (manager, MOCK_MINER_1);
106 g_assert_cmpstr (result, ==, "Comment in the mock miner");
107
108 result = tracker_miner_manager_get_display_name (manager, MOCK_MINER_2);
109 g_assert_cmpstr (result, ==, "Yet another mock miner");
110
111 result = tracker_miner_manager_get_description (manager, MOCK_MINER_2);
112 g_assert_cmpstr (result, ==, "Stupid and tedious test for the comment");
113 }
114
115 static void
116 test_miner_manager_ignore_next_update ()
117 {
118 const gchar *urls[] = { "url1", "url2", "url3", NULL };
119
120 /* Lame, this doesn't test nothing... but improves coverage numbers */
121 g_assert (tracker_miner_manager_ignore_next_update (manager, MOCK_MINER_1, urls));
122 }
123
124 static void
125 test_miner_manager_get_status ()
126 {
127 gchar *status;
128 gdouble progress;
129 g_assert (tracker_miner_manager_get_status (manager, MOCK_MINER_1, &status, &progress));
130 }
131
132 #endif
133
134 int
135 main (int argc,
136 char **argv)
137 {
138 gint result;
139
140 g_test_init (&argc, &argv, NULL);
141
142 g_test_message ("Testing miner manager");
143
144 miners_mock_init ();
145 g_setenv ("TRACKER_MINERS_DIR", TEST_MINERS_DIR, TRUE);
146 manager = tracker_miner_manager_new ();
147 #if 0
148 /* Todo: port miners-mock.c first */
149 g_test_add_func ("/libtracker-miner/tracker-miner-manager/get_running",
150 test_miner_manager_get_running);
151
152 g_test_add_func ("/libtracker-miner/tracker-miner-manager/get_available",
153 test_miner_manager_get_available);
154
155 g_test_add_func ("/libtracker-miner/tracker-miner-manager/is_active",
156 test_miner_manager_is_active);
157
158 g_test_add_func ("/libtracker-miner/tracker-miner-manager/pause_resume",
159 test_miner_manager_pause_resume);
160
161 g_test_add_func ("/libtracker-miner/tracker-miner-manager/getters",
162 test_miner_manager_getters);
163
164 g_test_add_func ("/libtracker-miner/tracker-miner-manager/ignore_next_update",
165 test_miner_manager_ignore_next_update);
166
167 g_test_add_func ("/libtracker-miner/tracker-miner-manager/status",
168 test_miner_manager_get_status);
169 #endif
170
171 result = g_test_run ();
172
173 g_object_unref (manager);
174 g_unsetenv ("TRACKER_MINERS_DIR");
175
176 return result;
177 }