summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-17 10:51:16 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-12 12:30:40 +0200
commit1cacd7cdfcaca3f909c9696f79bed58e25659926 (patch)
tree95ee71750f9c5e2c63d27a5b8c3555a0ea579620
parent153598481949b6f5629ff1a21a56ac765e72d43f (diff)
my-conn-proxy: add our own core feature
-rw-r--r--tests/dbus/proxy-preparation.c23
-rw-r--r--tests/lib/my-conn-proxy.c48
-rw-r--r--tests/lib/my-conn-proxy.h5
3 files changed, 76 insertions, 0 deletions
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 <telepathy-glib/proxy-internal.h>
+
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__ */