tests: add testcase for {Only,Not}ShowIn
[platform/upstream/glib.git] / gio / tests / gdbus-tests.c
index b8ac849..8b64e85 100644 (file)
@@ -1,6 +1,6 @@
 /* GLib testing framework examples and tests
  *
- * Copyright (C) 2008-2009 Red Hat, Inc.
+ * Copyright (C) 2008-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  *
  * Author: David Zeuthen <davidz@redhat.com>
  */
@@ -60,7 +58,7 @@ _g_assert_property_notify_run (gpointer     object,
   guint timeout_id;
   PropertyNotifyData data;
 
-  data.loop = g_main_loop_new (NULL, FALSE);
+  data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
   data.timed_out = FALSE;
   s = g_strdup_printf ("notify::%s", property_name);
   handler_id = g_signal_connect (object,
@@ -68,9 +66,9 @@ _g_assert_property_notify_run (gpointer     object,
                                  G_CALLBACK (on_property_notify),
                                  &data);
   g_free (s);
-  timeout_id = g_timeout_add (5 * 1000,
-                              on_property_notify_timeout,
-                              &data);
+  timeout_id = g_timeout_add_seconds (30,
+                                      on_property_notify_timeout,
+                                      &data);
   g_main_loop_run (data.loop);
   g_signal_handler_disconnect (object, handler_id);
   g_source_remove (timeout_id);
@@ -111,15 +109,15 @@ _g_assert_signal_received_run (gpointer     object,
   guint timeout_id;
   SignalReceivedData data;
 
-  data.loop = g_main_loop_new (NULL, FALSE);
+  data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
   data.timed_out = FALSE;
   handler_id = g_signal_connect_swapped (object,
                                          signal_name,
                                          G_CALLBACK (on_signal_received),
                                          &data);
-  timeout_id = g_timeout_add (5 * 1000,
-                              on_signal_received_timeout,
-                              &data);
+  timeout_id = g_timeout_add_seconds (30,
+                                      on_signal_received_timeout,
+                                      &data);
   g_main_loop_run (data.loop);
   g_signal_handler_disconnect (object, handler_id);
   g_source_remove (timeout_id);
@@ -147,6 +145,7 @@ _g_bus_get_priv (GBusType            bus_type,
   ret = g_dbus_connection_new_for_address_sync (address,
                                                 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
                                                 G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+                                                NULL, /* GDBusAuthObserver */
                                                 cancellable,
                                                 error);
   g_free (address);
@@ -156,63 +155,3 @@ _g_bus_get_priv (GBusType            bus_type,
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
-
-typedef struct
-{
-  GMainLoop *loop;
-  gboolean   timed_out;
-} WaitSingleRefData;
-
-static gboolean
-on_wait_single_ref_timeout (gpointer user_data)
-{
-  WaitSingleRefData *data = user_data;
-  data->timed_out = TRUE;
-  g_main_loop_quit (data->loop);
-  return TRUE;
-}
-
-static void
-on_wait_for_single_ref_toggled (gpointer   user_data,
-                                GObject   *object,
-                                gboolean   is_last_ref)
-{
-  WaitSingleRefData *data = user_data;
-  g_main_loop_quit (data->loop);
-}
-
-gboolean
-_g_object_wait_for_single_ref_do (gpointer object)
-{
-  WaitSingleRefData data;
-  guint timeout_id;
-
-  data.timed_out = FALSE;
-
-  if (G_OBJECT (object)->ref_count == 1)
-    goto out;
-
-  data.loop = g_main_loop_new (NULL, FALSE);
-  timeout_id = g_timeout_add (5 * 1000,
-                              on_wait_single_ref_timeout,
-                              &data);
-
-  g_object_add_toggle_ref (G_OBJECT (object),
-                           on_wait_for_single_ref_toggled,
-                           &data);
-  g_object_unref (object);
-
-  g_main_loop_run (data.loop);
-
-  g_object_ref (object);
-  g_object_remove_toggle_ref (object,
-                              on_wait_for_single_ref_toggled,
-                              &data);
-
-  g_source_remove (timeout_id);
-  g_main_loop_unref (data.loop);
- out:
-  return data.timed_out;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */