/*
- * mvs-info-provider-test.c
+ * mvs-minfo-provider-test.c
*
* This file is part of maevies
* Copyright (C) 2010 Simón Pena <spenap@gmail.com>
#include <glib.h>
#include "mvs-minfo-provider.h"
-#include "mvs-movie-info.h"
+#include "mvs-tmdb-movie.h"
+#include "mvs-watc-movie.h"
static GMainLoop *loop = NULL;
+static gchar *query = "Zombieland";
+static gboolean watc = FALSE;
+static gboolean tmdb = FALSE;
+
+static GOptionEntry entries[] = {
+ { "watc", 'w', 0, G_OPTION_ARG_NONE, &watc, "Query WATC service", NULL },
+ { "tmdb", 't', 0, G_OPTION_ARG_NONE, &tmdb, "Query TMDB service (default)", NULL },
+ { "query", 'q', 0, G_OPTION_ARG_STRING, &query, "query", "query term" },
+ { NULL }
+};
static void
-response_received_callback (MvsMInfoProvider minfo_provider,
- gpointer user_data)
+response_received_cb (MvsMInfoProvider *minfo_provider, guint service,
+ GList *list, gpointer user_data)
{
+ GList *tmp = NULL;
+
+ for (tmp = list; tmp; tmp = tmp->next) {
+
+ if (MVS_IS_TMDB_MOVIE (tmp->data)) {
+
+ MvsTmdbMovie *tmdb_movie = MVS_TMDB_MOVIE (tmp->data);
+
+ mvs_tmdb_movie_print (tmdb_movie);
+ g_print ("\n");
+
+ 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);
g_main_loop_quit (loop);
}
main (int argc, char **argv)
{
MvsMInfoProvider *minfo_provider = NULL;
- MvsMovieInfo *movie_info = NULL;
+ GOptionContext *context = NULL;
+ GError *error = NULL;
+ MvsService service = MVS_SERVICE_TMDB;
g_type_init ();
+ 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;
+ }
- g_thread_init (NULL);
+ if (watc)
+ service = MVS_SERVICE_WATC;
+ else if (tmdb)
+ service = MVS_SERVICE_TMDB;
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);
- movie_info = mvs_movie_info_new ();
loop = g_main_loop_new (NULL, FALSE);
- mvs_minfo_provider_query (minfo_provider, "Zombieland");
+ mvs_minfo_provider_query (minfo_provider, service,
+ query);
g_main_loop_run (loop);
g_object_unref (minfo_provider);
- g_object_unref (movie_info);
g_main_loop_unref (loop);
+ g_option_context_free (context);
return 0;
}