Movie Info Provider test: Command line parsing
authorSimón Pena <spenap@gmail.com>
Sun, 16 May 2010 23:48:17 +0000 (01:48 +0200)
committerSimón Pena <spenap@gmail.com>
Mon, 17 May 2010 00:02:48 +0000 (02:02 +0200)
Command line parsing support is added to be able to modify the
query issued to the service.

test/mvs-minfo-provider-test.c

index 343d0a0..968f82b 100644 (file)
 #include "mvs-tmdb-movie.h"
 
 static GMainLoop *loop = NULL;
+static gchar *query = "Zombieland";
+
+static GOptionEntry entries[] = {
+        { "query", 'q', 0, G_OPTION_ARG_STRING, &query, "query", "query term" },
+        { NULL }
+};
 
 static void
 response_received_callback (MvsMInfoProvider *minfo_provider, GList *list,
@@ -37,6 +43,7 @@ response_received_callback (MvsMInfoProvider *minfo_provider, GList *list,
                 MvsTmdbMovie *movie_info = MVS_TMDB_MOVIE (tmp->data);
 
                 mvs_tmdb_movie_print (movie_info);
+                g_print ("\n");
 
                 g_object_unref (movie_info);
         }
@@ -50,11 +57,22 @@ main (int argc, char **argv)
 {
         MvsMInfoProvider *minfo_provider = NULL;
         MvsTmdbMovie *movie_info = NULL;
+        GOptionContext *context = NULL;
+        GOptionGroup *gst_option_group = NULL;
+        GError *error = NULL;
 
         g_type_init ();
 
         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);
+                return -1;
+        }
+
+
         minfo_provider = mvs_minfo_provider_new ();
         g_signal_connect (minfo_provider, "response-received",
                           G_CALLBACK (response_received_callback), NULL);
@@ -62,7 +80,7 @@ main (int argc, char **argv)
         movie_info = mvs_tmdb_movie_new ();
         loop = g_main_loop_new (NULL, FALSE);
 
-        mvs_minfo_provider_query (minfo_provider, "Zombieland");
+        mvs_minfo_provider_query (minfo_provider, query);
 
         g_main_loop_run (loop);