Back to index

libindicate  12.10.0
test-max-indicators-client.c
Go to the documentation of this file.
00001 
00002 #include <glib.h>
00003 #include "libindicate/indicator.h"
00004 #include "libindicate/server.h"
00005 #include "libindicate/interests.h"
00006 #include "test-max-indicators-list.h"
00007 
00008 static gboolean passed = TRUE;
00009 static GMainLoop * mainloop = NULL;
00010 static int count = 0;
00011 
00012 
00013 static void
00014 max_changed (IndicateServer * server, gint max, gpointer userdata)
00015 {
00016        g_debug("Oh, max changed: %d", max);
00017 
00018        if (max != max_indicator_list[count]) {
00019               passed = FALSE;
00020               g_debug("\tBut that's not right!  We wanted: %d", max_indicator_list[count]);
00021        }
00022        count++;
00023 
00024        if (count == MAX_INDICATOR_COUNT) {
00025               g_main_loop_quit(mainloop);
00026        }
00027 
00028        return;
00029 }
00030 
00031 static gboolean
00032 done_timeout_cb (gpointer data)
00033 {
00034        g_debug("All maxes not set");
00035        passed = FALSE;
00036        g_main_loop_quit(mainloop);
00037        return FALSE;
00038 }
00039 
00040 int
00041 main (int argc, char * argv)
00042 {
00043        g_type_init();
00044 
00045        IndicateIndicator * indicator = indicate_indicator_new();
00046        indicate_indicator_show(indicator);
00047 
00048        IndicateServer * server = indicate_server_ref_default();
00049        g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, G_CALLBACK(max_changed), NULL);
00050 
00051        g_timeout_add(MAX_INDICATOR_COUNT * 10 * 100, done_timeout_cb, indicator);
00052 
00053        mainloop = g_main_loop_new(NULL, FALSE);
00054        g_main_loop_run(mainloop);
00055 
00056        return !passed;
00057 }