From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 02/10 v3] unit: Add gdbus/client_check_order
Date: Tue, 3 Sep 2013 14:21:11 +0300 [thread overview]
Message-ID: <1378207279-14557-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
unit/test-gdbus-client.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index a594384..488d4ec 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -35,6 +35,7 @@ struct context {
GMainLoop *main_loop;
DBusConnection *dbus_conn;
GDBusClient *dbus_client;
+ GDBusProxy *proxy;
void *data;
guint timeout_source;
};
@@ -779,6 +780,74 @@ static void client_string_changed(void)
destroy_context(context);
}
+static void property_check_order(const DBusError *err, void *user_data)
+{
+ struct context *context = user_data;
+ GDBusProxy *proxy = context->proxy;
+ DBusMessageIter iter;
+ const char *string;
+
+ g_assert(!dbus_error_is_set(err));
+
+ g_assert(g_dbus_proxy_get_property(proxy, "String", &iter));
+
+ dbus_message_iter_get_basic(&iter, &string);
+ g_assert(g_strcmp0(string, "value1") == 0);
+
+ g_dbus_client_unref(context->dbus_client);
+}
+
+static void proxy_check_order(GDBusProxy *proxy, void *user_data)
+{
+ struct context *context = user_data;
+ const char *string;
+
+ if (g_test_verbose())
+ g_print("proxy %s found\n",
+ g_dbus_proxy_get_interface(proxy));
+
+ context->proxy = proxy;
+ string = "value1";
+ g_assert(g_dbus_proxy_set_property_basic(proxy, "String",
+ DBUS_TYPE_STRING, &string,
+ property_check_order, context,
+ NULL));
+}
+
+static void client_check_order(void)
+{
+ struct context *context = create_context();
+ static const GDBusPropertyTable string_properties[] = {
+ { "String", "s", get_string, set_string, string_exists },
+ { },
+ };
+
+ if (context == NULL)
+ return;
+
+ context->data = g_strdup("value");
+ 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_disconnect_watch(context->dbus_client,
+ disconnect_handler, context);
+ g_dbus_client_set_proxy_handlers(context->dbus_client,
+ proxy_check_order, NULL, NULL,
+ context);
+
+ g_main_loop_run(context->main_loop);
+
+ g_dbus_unregister_interface(context->dbus_conn,
+ SERVICE_PATH, SERVICE_NAME);
+
+ destroy_context(context);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -809,5 +878,7 @@ int main(int argc, char *argv[])
g_test_add_func("/gdbus/client_string_changed",
client_string_changed);
+ g_test_add_func("/gdbus/client_check_order", client_check_order);
+
return g_test_run();
}
--
1.8.3.1
next prev parent reply other threads:[~2013-09-03 11:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-03 11:21 [PATCH BlueZ 00/10 v3] Fix message order Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 01/10 v3] build: Fix not rebuilding bluetoothd if gdbus changes Luiz Augusto von Dentz
2013-09-03 11:21 ` Luiz Augusto von Dentz [this message]
2013-09-03 11:21 ` [PATCH BlueZ 03/10 v3] gdbus: Fix sending ObjectManager/Properties signals out of order Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 04/10 v3] gdbus: Add g_dbus_send_message_with_reply Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 05/10 v3] gdbus: Avoid calling dbus_connection_send* Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 06/10 v3] gdbus: Fix emitting PropertiesChanged twice Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 07/10 v3] core: Make use of g_dbus_send_message_with_reply Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 08/10 v3] neard: " Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 09/10 v3] audio/media: " Luiz Augusto von Dentz
2013-09-03 11:21 ` [PATCH BlueZ 10/10 v3] obexd: Make use of g_dbus_send_message* Luiz Augusto von Dentz
2013-09-09 14:40 ` [PATCH BlueZ 00/10 v3] Fix message order Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378207279-14557-3-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).