Back to index

libindicate  12.10.0
test-indicator-display-half-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 
00007 #define MAX_INDICATOR_COUNT 100
00008 
00009 static gboolean passed = TRUE;
00010 static GMainLoop * mainloop = NULL;
00011 static int count = 0;
00012 
00013 
00014 static void
00015 indicator_displayed (IndicateIndicator * indicator, gboolean displayed, gpointer user_data)
00016 {
00017        g_debug("Indicator displayed: %s", displayed ? "true" : "false");
00018        if (displayed) {
00019               count++;
00020        }
00021 
00022        return;
00023 }
00024 
00025 static gboolean
00026 done_timeout_cb (gpointer data)
00027 {
00028        g_debug("%d of %d indicators displayed", count, MAX_INDICATOR_COUNT / 2);
00029        if (count != MAX_INDICATOR_COUNT / 2) {
00030               passed = FALSE;
00031        }
00032        g_main_loop_quit(mainloop);
00033        return FALSE;
00034 }
00035 
00036 static guint indicators = 0;
00037 static gboolean
00038 idle_func (gpointer data)
00039 {
00040        if (indicators == MAX_INDICATOR_COUNT) {
00041               return FALSE;
00042        }
00043 
00044        indicators++;
00045        IndicateIndicator * indicator = indicate_indicator_new();
00046        g_signal_connect(G_OBJECT(indicator), INDICATE_INDICATOR_SIGNAL_DISPLAYED, G_CALLBACK(indicator_displayed), NULL);
00047        indicate_indicator_show(indicator);
00048 
00049        return TRUE;
00050 }
00051 
00052 int
00053 main (int argc, char * argv)
00054 {
00055        g_type_init();
00056 
00057        g_idle_add(idle_func, NULL);
00058        g_timeout_add(MAX_INDICATOR_COUNT * 10, done_timeout_cb, NULL);
00059 
00060        mainloop = g_main_loop_new(NULL, FALSE);
00061        g_main_loop_run(mainloop);
00062 
00063        return !passed;
00064 }