Back to index

libindicator  12.10.0
service-manager-no-connect.c
Go to the documentation of this file.
00001 /*
00002 Test for libindicator
00003 
00004 Copyright 2009 Canonical Ltd.
00005 
00006 Authors:
00007     Ted Gould <ted@canonical.com>
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 version 3.0 as published by the Free Software Foundation.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License version 3.0 for more details.
00017 
00018 You should have received a copy of the GNU General Public
00019 License along with this library. If not, see
00020 <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 
00024 #include <glib.h>
00025 #include "libindicator/indicator-service-manager.h"
00026 
00027 static GMainLoop * mainloop = NULL;
00028 static gboolean passed = FALSE;
00029 
00030 gboolean
00031 timeout (gpointer data)
00032 {
00033        passed = TRUE;
00034        g_debug("Timeout with no connection.");
00035        g_main_loop_quit(mainloop);
00036        return FALSE;
00037 }
00038 
00039 void
00040 connection (void)
00041 {
00042        g_debug("Connection");
00043        passed = FALSE;
00044        g_main_loop_quit(mainloop);
00045        return;
00046 }
00047 
00048 int
00049 main (int argc, char ** argv)
00050 {
00051        g_type_init();
00052        g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
00053 
00054        IndicatorServiceManager * is = indicator_service_manager_new("my.test.name");
00055        g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, connection, NULL);
00056 
00057        g_timeout_add_seconds(1, timeout, NULL);
00058 
00059        mainloop = g_main_loop_new(NULL, FALSE);
00060        g_main_loop_run(mainloop);
00061 
00062        g_debug("Quiting");
00063        if (passed) {
00064               g_debug("Passed");
00065               return 0;
00066        }
00067        g_debug("Failed");
00068        return 1;
00069 }