# HG changeset patch # User melunko # Date 1169153289 0 # Node ID 99d209c4b53d6a379bf17337fd6f99128ff1aff5 # Parent 4a7fc19705f067f052d7348f129afa0a4cfcd929 [svn r275] added tests for epg and recorder diff -r 4a7fc19705f0 -r 99d209c4b53d gmyth/tests/compile_test_recorder --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/compile_test_recorder Thu Jan 18 20:48:09 2007 +0000 @@ -0,0 +1,1 @@ +gcc -o gmyth_test_recorder gmyth_test_recorder.c `pkg-config --cflags --libs gmyth-0.1` diff -r 4a7fc19705f0 -r 99d209c4b53d gmyth/tests/gmyth_test_epg.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth/tests/gmyth_test_epg.c Thu Jan 18 20:48:09 2007 +0000 @@ -0,0 +1,60 @@ + +#include "gmyth_backendinfo.h" +#include "gmyth_epg.h" + +static gboolean +test_epg_connection (GMythBackendInfo *backend_info) +{ + GMythEPG *epg = gmyth_epg_new (); + gboolean res = FALSE; + + res = gmyth_epg_connect (epg, backend_info); + + gmyth_epg_disconnect (epg); + g_object_unref (epg); + + return res; +} + + +static gboolean +test_epg_get_channels (GMythBackendInfo *backend_info) +{ + GMythEPG *epg = gmyth_epg_new (); + GList *clist; + gint i, length; + + if (!gmyth_epg_connect (epg, backend_info)) { + return FALSE; + } + + length = gmyth_epg_get_channel_list (epg, &clist); + g_print ("==== %d channels found in the EPG ====\n", length); + for (i=0; i + +#include "gmyth_backendinfo.h" +#include "gmyth_remote_util.h" +#include "gmyth_query.h" +#include "gmyth_epg.h" +#include "gmyth_common.h" + + +static gboolean +test_recorder_availability (GMythBackendInfo *backend_info) +{ + GMythRecorder* recorder; + GMythSocket *socket = gmyth_socket_new (); + + if (gmyth_socket_connect_with_timeout (socket, + gmyth_backend_info_get_hostname (backend_info), + gmyth_backend_info_get_port (backend_info), 4) == FALSE) { + g_debug ("Test recorder failed: Connection failed"); + return FALSE; + } + + recorder = remote_request_next_free_recorder (socket, -1); + if (recorder == NULL) { + g_debug ("Recorder not available\n"); + return FALSE; + } + + g_debug ("Recorder found (num): %d", recorder->recorder_num); + + return TRUE; +} + +static gboolean +test_recorder_setup (GMythBackendInfo *backend_info) +{ + GMythQuery *query = gmyth_query_new (); + + if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) { + g_debug ("Mysql connection success"); + return TRUE; + } else { + g_debug ("Mysql connection failed"); + return FALSE; + } + +} + +static gboolean +test_recorder_check_channels (GMythBackendInfo *backend_info) +{ + GMythRecorder* recorder; + GMythSocket *socket = gmyth_socket_new (); + GMythEPG *epg = gmyth_epg_new (); + GList *clist; + gint i, length; + + // Gets the free recorder + if (gmyth_socket_connect_with_timeout (socket, + gmyth_backend_info_get_hostname (backend_info), + gmyth_backend_info_get_port (backend_info), 4) == FALSE) { + g_debug ("Test recorder failed: Connection failed"); + return FALSE; + } + + recorder = remote_request_next_free_recorder (socket, -1); + if (recorder == NULL) { + g_debug ("[%s] Recorder not available", __FUNCTION__); + return FALSE; + } + + // Connects the recorder socket + gmyth_recorder_setup (recorder); + + // Gets the list of channels + if (!gmyth_epg_connect (epg, backend_info)) { + g_debug ("%s: Not connected\n", __FUNCTION__); + return FALSE; + } + + length = gmyth_epg_get_channel_list (epg, &clist); + gmyth_epg_disconnect (epg); + g_object_unref (epg); + + g_print ("==== Verifying the %d channels found in the EPG ====\n", length); + for (i=0; ichannel_ID); + g_debug ("Channel %d %s", channel_info->channel_ID, res ? "Found" : "Not found"); + } + + g_list_free (clist); + +} + + +int +main (int args, const char **argv) +{ + const char* uri = argv[1]; + + GMythBackendInfo *backend_info; + g_type_init (); + g_thread_init (NULL); + + backend_info = gmyth_backend_info_new_with_uri (argv[1]); + + test_recorder_availability (backend_info); + test_recorder_check_channels (backend_info); +} + + + + +