tracker-0.16.2/tests/libtracker-miner/tracker-thumbnailer-test.c

No issues found

  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 "thumbnailer-mock.h"
 24 
 25 #if 0
 26 /* port thumbnailer-mock.c to gdbus first */
 27 
 28 static void
 29 test_thumbnailer_init ()
 30 {
 31         g_assert (tracker_thumbnailer_init ());
 32 
 33         tracker_thumbnailer_shutdown ();
 34 }
 35 
 36 static void
 37 test_thumbnailer_send_empty () 
 38 {
 39         GList *dbus_calls = NULL;
 40 
 41         dbus_mock_call_log_reset ();
 42 
 43         tracker_thumbnailer_init ();
 44         tracker_thumbnailer_send ();
 45 
 46         dbus_calls = dbus_mock_call_log_get ();
 47         g_assert (dbus_calls == NULL);
 48 
 49         tracker_thumbnailer_shutdown ();
 50 }
 51 
 52 static void
 53 test_thumbnailer_send_moves ()
 54 {
 55         GList *dbus_calls = NULL;
 56         
 57         dbus_mock_call_log_reset ();
 58 
 59         tracker_thumbnailer_init ();
 60         /* Returns TRUE, but there is no dbus call */
 61         g_assert (tracker_thumbnailer_move_add ("file://a.jpeg", "mock/one", "file://b.jpeg"));
 62         g_assert (dbus_mock_call_log_get () == NULL);
 63 
 64         /* Returns FALSE, unsupported mime */
 65         g_assert (!tracker_thumbnailer_move_add ("file://a.jpeg", "unsupported", "file://b.jpeg"));
 66         g_assert (dbus_mock_call_log_get () == NULL);
 67 
 68         tracker_thumbnailer_send ();
 69 
 70         /* One call to "move" method */
 71         dbus_calls = dbus_mock_call_log_get ();
 72         g_assert_cmpint (g_list_length (dbus_calls), ==, 1);
 73         g_assert_cmpstr (dbus_calls->data, ==, "Move");
 74 
 75         tracker_thumbnailer_shutdown ();
 76         dbus_mock_call_log_reset ();
 77 }
 78 
 79 static void
 80 test_thumbnailer_send_removes ()
 81 {
 82         GList *dbus_calls = NULL;
 83         
 84         dbus_mock_call_log_reset ();
 85 
 86 
 87         tracker_thumbnailer_init ();
 88 
 89         /* Returns TRUE, but there is no dbus call */
 90         g_assert (tracker_thumbnailer_remove_add ("file://a.jpeg", "mock/one"));
 91         g_assert (dbus_mock_call_log_get () == NULL);
 92 
 93         /* Returns FALSE, unsupported mime */
 94         g_assert (!tracker_thumbnailer_remove_add ("file://a.jpeg", "unsupported"));
 95         g_assert (dbus_mock_call_log_get () == NULL);
 96 
 97         tracker_thumbnailer_send ();
 98 
 99         /* One call to "Delete" method */
100         dbus_calls = dbus_mock_call_log_get ();
101         g_assert_cmpint (g_list_length (dbus_calls), ==, 1);
102         g_assert_cmpstr (dbus_calls->data, ==, "Delete");
103 
104         tracker_thumbnailer_shutdown ();
105         dbus_mock_call_log_reset ();
106 }
107 
108 static void
109 test_thumbnailer_send_cleanup ()
110 {
111         GList *dbus_calls = NULL;
112         
113         dbus_mock_call_log_reset ();
114 
115         tracker_thumbnailer_init ();
116 
117         /* Returns TRUE, and there is a dbus call */
118         g_assert (tracker_thumbnailer_cleanup ("file://tri/lu/ri"));
119 
120         /* One call to "Clean" method */
121         dbus_calls = dbus_mock_call_log_get ();
122         g_assert_cmpint (g_list_length (dbus_calls), ==, 1);
123         g_assert_cmpstr (dbus_calls->data, ==, "Cleanup");
124 
125         tracker_thumbnailer_shutdown ();
126         dbus_mock_call_log_reset ();
127 }
128 
129 #endif
130 
131 int
132 main (int    argc,
133       char **argv)
134 {
135 	g_test_init (&argc, &argv, NULL);
136 
137 	g_test_message ("Testing thumbnailer");
138 
139 #if 0
140 /* port thumbnailer-mock.c to gdbus first */
141 
142 	g_test_add_func ("/libtracker-miner/tracker-thumbnailer/init",
143 	                 test_thumbnailer_init);
144 	g_test_add_func ("/libtracker-miner/tracker-thumbnailer/send_empty",
145 	                 test_thumbnailer_send_empty);
146         g_test_add_func ("/libtracker-minter/tracker-thumbnailer/send_moves",
147                          test_thumbnailer_send_moves);
148         g_test_add_func ("/libtracker-minter/tracker-thumbnailer/send_removes",
149                          test_thumbnailer_send_removes);
150         g_test_add_func ("/libtracker-minter/tracker-thumbnailer/send_cleanup",
151                          test_thumbnailer_send_cleanup);
152 
153 #endif
154 
155 	return g_test_run ();
156 }