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