linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/8] unit: Add gdbus/client_proxy_removed
@ 2013-09-09 14:49 Luiz Augusto von Dentz
  2013-09-09 14:49 ` [PATCH BlueZ 2/8] unit: Add gdbus/client_force_disconnect Luiz Augusto von Dentz
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2013-09-09 14:49 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This tests if watches created using g_dbus_proxy_set_removed_watch works
when the interface is removed.
---
 unit/test-gdbus-client.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index 488d4ec..30b0ce3 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -848,6 +848,61 @@ static void client_check_order(void)
 	destroy_context(context);
 }
 
+static void proxy_removed(GDBusProxy *proxy, void *user_data)
+{
+	struct context *context = user_data;
+
+	if (g_test_verbose())
+		g_print("proxy removed\n");
+
+	g_main_loop_quit(context->main_loop);
+}
+
+static void proxy_set_removed(GDBusProxy *proxy, void *user_data)
+{
+	struct context *context = user_data;
+
+	if (g_test_verbose())
+		g_print("proxy %s found\n",
+					g_dbus_proxy_get_interface(proxy));
+
+	g_assert(g_dbus_proxy_set_removed_watch(proxy, proxy_removed, context));
+
+	context->timeout_source = g_timeout_add_seconds(2, timeout_test,
+								context);
+
+	g_dbus_unregister_interface(context->dbus_conn, SERVICE_PATH,
+								SERVICE_NAME);
+}
+
+static void client_proxy_removed(void)
+{
+	struct context *context = create_context();
+	static const GDBusPropertyTable string_properties[] = {
+		{ "String", "s", get_string, set_string, string_exists },
+		{ },
+	};
+
+	if (context == NULL)
+		return;
+
+	g_dbus_register_interface(context->dbus_conn,
+				SERVICE_PATH, SERVICE_NAME,
+				methods, signals, string_properties,
+				context, NULL);
+
+	context->dbus_client = g_dbus_client_new(context->dbus_conn,
+						SERVICE_NAME, SERVICE_PATH);
+
+	g_dbus_client_set_proxy_handlers(context->dbus_client,
+						proxy_set_removed, NULL, NULL,
+						context);
+
+	g_main_loop_run(context->main_loop);
+
+	destroy_context(context);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -880,5 +935,7 @@ int main(int argc, char *argv[])
 
 	g_test_add_func("/gdbus/client_check_order", client_check_order);
 
+	g_test_add_func("/gdbus/client_proxy_removed", client_proxy_removed);
+
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-09-12 11:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-09 14:49 [PATCH BlueZ 1/8] unit: Add gdbus/client_proxy_removed Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 2/8] unit: Add gdbus/client_force_disconnect Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 3/8] gdbus/watch: Fix crash when g_dbus_remove_watch is called from connect callback Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 4/8] gdbus/watch: Fix aborting when removing D-Bus filter Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 5/8] gdbus/watch: Fix crash when disconnecting from D-Bus Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 6/8] gdbus/client: Use g_dbus_add_service_watch to track services Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 7/8] gdbus/client: Use g_dbus_add_signal_watch to track signals Luiz Augusto von Dentz
2013-09-09 14:49 ` [PATCH BlueZ 8/8] gdbus/client: Use g_dbus_add_properties_watch to track properties Luiz Augusto von Dentz
2013-09-12 11:01 ` [PATCH BlueZ 1/8] unit: Add gdbus/client_proxy_removed Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).