Back to index

bamf  0.2.120
test-bamf.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Canonical Ltd
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 3 as 
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00015  *
00016  * Authored by Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>
00017  *
00018  */
00019 
00020 #include <stdio.h>
00021 #include <gtk/gtk.h>
00022 #include <gdk/gdk.h>
00023 #include <glib.h>
00024 #include <gio/gio.h>
00025 #include <sys/types.h>
00026 #include <unistd.h>
00027 #include <glibtop.h>
00028 #include "bamf.h"
00029 
00030 void test_application_create_suite (GDBusConnection *connection);
00031 void test_matcher_create_suite (void);
00032 void test_view_create_suite (GDBusConnection *connection);
00033 void test_window_create_suite (void);
00034 
00035 static int result = 1;
00036 
00037 static void
00038 on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer data)
00039 {
00040   GMainLoop *loop = data;
00041 
00042   test_matcher_create_suite ();
00043   test_view_create_suite (connection);
00044   test_window_create_suite ();
00045   test_application_create_suite (connection);
00046   result = g_test_run ();
00047 
00048   g_main_loop_quit (loop);
00049 }
00050 
00051 static void
00052 on_name_lost (GDBusConnection *connection, const gchar *name, gpointer data)
00053 {
00054   GMainLoop *loop = data;
00055   g_main_loop_quit (loop);
00056 }
00057 
00058 gint
00059 main (gint argc, gchar *argv[])
00060 {
00061   GMainLoop *loop;
00062 
00063   gtk_init (&argc, &argv);
00064   g_test_init (&argc, &argv, NULL);
00065   glibtop_init ();
00066 
00067   loop = g_main_loop_new (NULL, FALSE);
00068 
00069   g_bus_own_name (G_BUS_TYPE_SESSION,
00070                   BAMF_DBUS_SERVICE".test",
00071                   G_BUS_NAME_OWNER_FLAGS_NONE,
00072                   on_bus_acquired,
00073                   NULL,
00074                   on_name_lost,
00075                   loop,
00076                   NULL);
00077 
00078   g_main_loop_run (loop);
00079 
00080   return result;
00081 }