Пример #1
0
int
main (int   argc,
      char *argv[])
{
  GError *error;
  gint ret;

  g_type_init ();
  g_test_init (&argc, &argv, NULL);

  /* all the tests rely on a shared main loop */
  loop = g_main_loop_new (NULL, FALSE);

  session_bus_up ();

  /* this is safe; testserver will exit once the bus goes away */
  g_assert (g_spawn_command_line_async (SRCDIR "/gdbus-testserver.py", NULL));

  /* wait for the service to come up */
  usleep (500 * 1000);

  /* Create the connection in the main thread */
  error = NULL;
  c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
  g_assert_no_error (error);
  g_assert (c != NULL);

  g_test_add_func ("/gdbus/connection-loss", test_connection_loss);

  ret = g_test_run();

  g_object_unref (c);

  return ret;
}
Пример #2
0
gint
session_bus_run (void)
{
  gint ret;

  session_bus_up ();
  ret = g_test_run ();
  session_bus_down ();

  return ret;
}
Пример #3
0
static void
test_bz627724 (void)
{
  MyObject *object;

  session_bus_up ();
  g_assert (the_connection == NULL);
  object = g_object_new (MY_TYPE_OBJECT, NULL);
  g_assert (the_connection != NULL);
  g_object_unref (the_connection);
  g_object_unref (object);
  session_bus_down ();
}
int
main (int   argc,
      char *argv[])
{
  GError *error;
  gint ret;

  g_type_init ();
  g_thread_init (NULL);
  g_test_init (&argc, &argv, NULL);

  /* all the tests rely on a shared main loop */
  loop = g_main_loop_new (NULL, FALSE);

  /* all the tests use a session bus with a well-known address that we can bring up and down
   * using session_bus_up() and session_bus_down().
   */
  g_unsetenv ("DISPLAY");
  g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE);

  session_bus_up ();

  /* TODO: wait a bit for the bus to come up.. ideally session_bus_up() won't return
   * until one can connect to the bus but that's not how things work right now
   */
  usleep (500 * 1000);

  /* this is safe; testserver will exit once the bus goes away */
  g_assert (g_spawn_command_line_async (SRCDIR "/gdbus-testserver.py", NULL));

  /* wait for the service to come up */
  usleep (500 * 1000);

  /* Create the connection in the main thread */
  error = NULL;
  c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
  g_assert_no_error (error);
  g_assert (c != NULL);

  g_test_add_func ("/gdbus/connection-loss", test_connection_loss);

  ret = g_test_run();

  g_object_unref (c);

  return ret;
}