Fixed test to support signals carrying service
[maevies] / test / mvs-minfo-provider-test.c
index bf258f1..d4b398d 100644 (file)
@@ -36,8 +36,8 @@ static GOptionEntry entries[] = {
 };
 
 static void
-response_received_callback (MvsMInfoProvider *minfo_provider, GList *list,
-                            gpointer user_data)
+response_received_cb (MvsMInfoProvider *minfo_provider, guint service,
+                      GList *list, gpointer user_data)
 {
         GList *tmp = NULL;
 
@@ -52,6 +52,15 @@ response_received_callback (MvsMInfoProvider *minfo_provider, GList *list,
 
                         g_object_unref (tmdb_movie);
                 }
+                else if (MVS_IS_WATC_MOVIE (tmp->data)) {
+
+                        MvsWatcMovie *watc_movie = MVS_WATC_MOVIE (tmp->data);
+
+                        mvs_watc_movie_print (watc_movie);
+                        g_print ("\n");
+
+                        g_object_unref (watc_movie);
+                }
         }
 
         g_list_free (list);
@@ -63,18 +72,19 @@ main (int argc, char **argv)
 {
         MvsMInfoProvider *minfo_provider = NULL;
         GOptionContext *context = NULL;
-        GOptionGroup *gst_option_group = NULL;
         GError *error = NULL;
         MvsService service = MVS_SERVICE_TMDB;
 
         g_type_init ();
-
-        g_thread_init (NULL);
+        if (!g_thread_supported ())
+                g_thread_init (NULL);
 
         context = g_option_context_new (" - Tests data provider behavior");
         g_option_context_add_main_entries (context, entries, NULL);
         if (!g_option_context_parse (context, &argc, &argv, &error)) {
                 g_critical ("option parsing failed: %s", error->message);
+                g_error_free (error);
+                g_option_context_free (context);
                 return -1;
         }
 
@@ -85,7 +95,7 @@ main (int argc, char **argv)
 
         minfo_provider = mvs_minfo_provider_new ();
         g_signal_connect (minfo_provider, "response-received",
-                          G_CALLBACK (response_received_callback), NULL);
+                          G_CALLBACK (response_received_cb), NULL);
 
         loop = g_main_loop_new (NULL, FALSE);
 
@@ -93,8 +103,10 @@ main (int argc, char **argv)
                                   query);
 
         g_main_loop_run (loop);
+
         g_object_unref (minfo_provider);
         g_main_loop_unref (loop);
+        g_option_context_free (context);
 
         return 0;
 }