From: Simón Pena Date: Sun, 16 May 2010 23:48:17 +0000 (+0200) Subject: Movie Info Provider test: Command line parsing X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=04aba26ec7e56209e5daf396072b4e590feb850d;p=maevies Movie Info Provider test: Command line parsing Command line parsing support is added to be able to modify the query issued to the service. --- diff --git a/test/mvs-minfo-provider-test.c b/test/mvs-minfo-provider-test.c index 343d0a0..968f82b 100644 --- a/test/mvs-minfo-provider-test.c +++ b/test/mvs-minfo-provider-test.c @@ -23,6 +23,12 @@ #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);