From 1cacd7cdfcaca3f909c9696f79bed58e25659926 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 17 Jan 2011 10:51:16 +0100 Subject: my-conn-proxy: add our own core feature --- tests/dbus/proxy-preparation.c | 23 ++++++++++++++++++++ tests/lib/my-conn-proxy.c | 48 ++++++++++++++++++++++++++++++++++++++++++ tests/lib/my-conn-proxy.h | 5 +++++ 3 files changed, 76 insertions(+) diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c index d9b92409..1ba7acdc 100644 --- a/tests/dbus/proxy-preparation.c +++ b/tests/dbus/proxy-preparation.c @@ -99,6 +99,27 @@ test_prepare_capabilities (Test *test, TP_CONNECTION_FEATURE_CAPABILITIES)); } +static void +test_prepare_core (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + /* Test than preparing the 'top' core feature prepare the other core + * features as well */ + GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_CORE, 0 }; + + tp_proxy_prepare_async (test->my_conn, features, prepare_cb, test); + + g_main_loop_run (test->mainloop); + g_assert_no_error (test->error); + + g_assert (tp_proxy_is_prepared (test->my_conn, + TP_TESTS_MY_CONN_PROXY_FEATURE_CORE)); + g_assert (tp_proxy_is_prepared (test->my_conn, TP_CONNECTION_FEATURE_CORE)); + + g_assert (!tp_proxy_is_prepared (test->my_conn, + TP_CONNECTION_FEATURE_CAPABILITIES)); +} + int main (int argc, char **argv) @@ -112,6 +133,8 @@ main (int argc, g_test_add ("/proxy-preparation/prepare-capabilities", Test, NULL, setup, test_prepare_capabilities, teardown); + g_test_add ("/proxy-preparation/prepare-core", Test, NULL, setup, + test_prepare_core, teardown); return g_test_run (); } diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c index f76ce95d..7cc0bda4 100644 --- a/tests/lib/my-conn-proxy.c +++ b/tests/lib/my-conn-proxy.c @@ -8,8 +8,11 @@ * notice and this notice are preserved. */ + #include "my-conn-proxy.h" +#include + G_DEFINE_TYPE (TpTestsMyConnProxy, tp_tests_my_conn_proxy, TP_TYPE_CONNECTION) @@ -18,7 +21,52 @@ tp_tests_my_conn_proxy_init (TpTestsMyConnProxy *self) { } +enum { + FEAT_CORE, + N_FEAT +}; + +static void +prepare_core_async (TpProxy *proxy, + const TpProxyFeature *feature, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + + result = g_simple_async_result_new ((GObject *) proxy, callback, user_data, + prepare_core_async); + + g_simple_async_result_complete_in_idle (result); + g_object_unref (result); +} + + +static const TpProxyFeature * +list_features (TpProxyClass *cls G_GNUC_UNUSED) +{ + static TpProxyFeature features[N_FEAT + 1] = { { 0 } }; + + if (G_LIKELY (features[0].name != 0)) + return features; + + features[FEAT_CORE].name = TP_TESTS_MY_CONN_PROXY_FEATURE_CORE; + features[FEAT_CORE].core = TRUE; + features[FEAT_CORE].prepare_async = prepare_core_async; + + return features; +} + static void tp_tests_my_conn_proxy_class_init (TpTestsMyConnProxyClass *klass) { + TpProxyClass *proxy_class = (TpProxyClass *) klass; + + proxy_class->list_features = list_features; +} + +GQuark +tp_tests_my_conn_proxy_get_feature_quark_core (void) +{ + return g_quark_from_static_string ("tp-my-conn-proxy-feature-core"); } diff --git a/tests/lib/my-conn-proxy.h b/tests/lib/my-conn-proxy.h index 86f27123..37f19a7b 100644 --- a/tests/lib/my-conn-proxy.h +++ b/tests/lib/my-conn-proxy.h @@ -48,6 +48,11 @@ GType tp_tests_my_conn_proxy_get_type (void); (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_MY_CONN_PROXY, \ TpTestsMyConnProxyClass)) +/* Core feature */ +#define TP_TESTS_MY_CONN_PROXY_FEATURE_CORE \ + (tp_tests_my_conn_proxy_get_feature_quark_core ()) +GQuark tp_tests_my_conn_proxy_get_feature_quark_core (void) G_GNUC_CONST; + G_END_DECLS #endif /* #ifndef __TP_TESTS_MY_CONN_PROXY_H__ */ -- cgit v1.2.3