• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GLib testing framework examples and tests
2  *
3  * Copyright (C) 2008-2010 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: David Zeuthen <davidz@redhat.com>
19  */
20 
21 #include <gio/gio.h>
22 #include <unistd.h>
23 #include <string.h>
24 
25 #include "gdbus-tests.h"
26 
27 static GDBusConnection *the_connection = NULL;
28 
29 #define MY_TYPE_OBJECT   (my_object_get_type ())
30 #define MY_OBJECT(o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), MY_TYPE_OBJECT, MyObject))
31 #define MY_IS_OBJECT(o)  (G_TYPE_CHECK_INSTANCE_TYPE ((o), MY_TYPE_OBJECT))
32 
33 typedef struct {
34   GObject parent_instance;
35 } MyObject;
36 
37 typedef struct {
38   GObjectClass parent_class;
39 } MyObjectClass;
40 
41 GType my_object_get_type (void) G_GNUC_CONST;
42 
G_DEFINE_TYPE(MyObject,my_object,G_TYPE_OBJECT)43 G_DEFINE_TYPE (MyObject, my_object, G_TYPE_OBJECT)
44 
45 static void
46 my_object_init (MyObject *object)
47 {
48 }
49 
50 static void
my_object_class_init(MyObjectClass * klass)51 my_object_class_init (MyObjectClass *klass)
52 {
53   GError *error;
54   error = NULL;
55   the_connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
56                                    NULL, /* GCancellable* */
57                                    &error);
58   g_assert_no_error (error);
59   g_assert (G_IS_DBUS_CONNECTION (the_connection));
60 }
61 
62 static void
test_bz627724(void)63 test_bz627724 (void)
64 {
65   MyObject *object;
66 
67   session_bus_up ();
68   g_assert (the_connection == NULL);
69   object = g_object_new (MY_TYPE_OBJECT, NULL);
70   g_assert (the_connection != NULL);
71   g_object_unref (the_connection);
72   g_object_unref (object);
73   session_bus_down ();
74 }
75 
76 
77 int
main(int argc,char * argv[])78 main (int   argc,
79       char *argv[])
80 {
81   g_test_init (&argc, &argv, NULL);
82 
83   g_test_dbus_unset ();
84 
85   g_test_add_func ("/gdbus/bz627724", test_bz627724);
86   return g_test_run();
87 }
88