Blame gio/tests/gdbus-bz627724.c

Packit ae235b
/* GLib testing framework examples and tests
Packit ae235b
 *
Packit ae235b
 * Copyright (C) 2008-2010 Red Hat, Inc.
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General
Packit ae235b
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Author: David Zeuthen <davidz@redhat.com>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include <gio/gio.h>
Packit ae235b
#include <unistd.h>
Packit ae235b
#include <string.h>
Packit ae235b
Packit ae235b
#include "gdbus-tests.h"
Packit ae235b
Packit ae235b
static GDBusConnection *the_connection = NULL;
Packit ae235b
Packit ae235b
#define MY_TYPE_OBJECT   (my_object_get_type ())
Packit ae235b
#define MY_OBJECT(o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), MY_TYPE_OBJECT, MyObject))
Packit ae235b
#define MY_IS_OBJECT(o)  (G_TYPE_CHECK_INSTANCE_TYPE ((o), MY_TYPE_OBJECT))
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  GObject parent_instance;
Packit ae235b
} MyObject;
Packit ae235b
Packit ae235b
typedef struct {
Packit ae235b
  GObjectClass parent_class;
Packit ae235b
} MyObjectClass;
Packit ae235b
Packit ae235b
GType my_object_get_type (void) G_GNUC_CONST;
Packit ae235b
Packit ae235b
G_DEFINE_TYPE (MyObject, my_object, G_TYPE_OBJECT)
Packit ae235b
Packit ae235b
static void
Packit ae235b
my_object_init (MyObject *object)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
my_object_class_init (MyObjectClass *klass)
Packit ae235b
{
Packit ae235b
  GError *error;
Packit ae235b
  error = NULL;
Packit ae235b
  the_connection = g_bus_get_sync (G_BUS_TYPE_SESSION,
Packit ae235b
                                   NULL, /* GCancellable* */
Packit ae235b
                                   &error);
Packit ae235b
  g_assert_no_error (error);
Packit ae235b
  g_assert (G_IS_DBUS_CONNECTION (the_connection));
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
test_bz627724 (void)
Packit ae235b
{
Packit ae235b
  MyObject *object;
Packit ae235b
Packit ae235b
  session_bus_up ();
Packit ae235b
  g_assert (the_connection == NULL);
Packit ae235b
  object = g_object_new (MY_TYPE_OBJECT, NULL);
Packit ae235b
  g_assert (the_connection != NULL);
Packit ae235b
  g_object_unref (the_connection);
Packit ae235b
  g_object_unref (object);
Packit ae235b
  session_bus_down ();
Packit ae235b
}
Packit ae235b
Packit ae235b
Packit ae235b
int
Packit ae235b
main (int   argc,
Packit ae235b
      char *argv[])
Packit ae235b
{
Packit ae235b
  g_test_init (&argc, &argv, NULL);
Packit ae235b
Packit ae235b
  g_test_dbus_unset ();
Packit ae235b
Packit ae235b
  g_test_add_func ("/gdbus/bz627724", test_bz627724);
Packit ae235b
  return g_test_run();
Packit ae235b
}