summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/dbus/proxy-preparation.c22
-rw-r--r--tests/lib/my-conn-proxy.c58
-rw-r--r--tests/lib/my-conn-proxy.h10
3 files changed, 90 insertions, 0 deletions
diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c
index 1ba7acdc..3063d942 100644
--- a/tests/dbus/proxy-preparation.c
+++ b/tests/dbus/proxy-preparation.c
@@ -120,6 +120,26 @@ test_prepare_core (Test *test,
TP_CONNECTION_FEATURE_CAPABILITIES));
}
+static void
+test_depends (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ /* Test if A is automatically prepared when preparing B */
+ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_B, 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_TESTS_MY_CONN_PROXY_FEATURE_A));
+ g_assert (tp_proxy_is_prepared (test->my_conn,
+ TP_TESTS_MY_CONN_PROXY_FEATURE_B));
+}
+
int
main (int argc,
char **argv)
@@ -135,6 +155,8 @@ main (int argc,
test_prepare_capabilities, teardown);
g_test_add ("/proxy-preparation/prepare-core", Test, NULL, setup,
test_prepare_core, teardown);
+ g_test_add ("/proxy-preparation/depends", Test, NULL, setup,
+ test_depends, teardown);
return g_test_run ();
}
diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c
index 7cc0bda4..96ab00d3 100644
--- a/tests/lib/my-conn-proxy.c
+++ b/tests/lib/my-conn-proxy.c
@@ -23,6 +23,8 @@ tp_tests_my_conn_proxy_init (TpTestsMyConnProxy *self)
enum {
FEAT_CORE,
+ FEAT_A,
+ FEAT_B,
N_FEAT
};
@@ -41,11 +43,46 @@ prepare_core_async (TpProxy *proxy,
g_object_unref (result);
}
+static void
+prepare_a_async (TpProxy *proxy,
+ const TpProxyFeature *feature,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ g_assert (tp_proxy_is_prepared (proxy, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE));
+
+ result = g_simple_async_result_new ((GObject *) proxy, callback, user_data,
+ prepare_a_async);
+
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+}
+
+static void
+prepare_b_async (TpProxy *proxy,
+ const TpProxyFeature *feature,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ g_assert (tp_proxy_is_prepared (proxy, TP_TESTS_MY_CONN_PROXY_FEATURE_CORE));
+ g_assert (tp_proxy_is_prepared (proxy, TP_TESTS_MY_CONN_PROXY_FEATURE_A));
+
+ result = g_simple_async_result_new ((GObject *) proxy, callback, user_data,
+ prepare_b_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 } };
+ static GQuark need_a[2] = {0, 0};
if (G_LIKELY (features[0].name != 0))
return features;
@@ -54,6 +91,15 @@ list_features (TpProxyClass *cls G_GNUC_UNUSED)
features[FEAT_CORE].core = TRUE;
features[FEAT_CORE].prepare_async = prepare_core_async;
+ features[FEAT_A].name = TP_TESTS_MY_CONN_PROXY_FEATURE_A;
+ features[FEAT_A].prepare_async = prepare_a_async;
+
+ features[FEAT_B].name = TP_TESTS_MY_CONN_PROXY_FEATURE_B;
+ features[FEAT_B].prepare_async = prepare_b_async;
+ if (G_UNLIKELY (need_a[0] == 0))
+ need_a[0] = TP_TESTS_MY_CONN_PROXY_FEATURE_A;
+ features[FEAT_B].depends_on = need_a;
+
return features;
}
@@ -70,3 +116,15 @@ tp_tests_my_conn_proxy_get_feature_quark_core (void)
{
return g_quark_from_static_string ("tp-my-conn-proxy-feature-core");
}
+
+GQuark
+tp_tests_my_conn_proxy_get_feature_quark_a (void)
+{
+ return g_quark_from_static_string ("tp-my-conn-proxy-feature-a");
+}
+
+GQuark
+tp_tests_my_conn_proxy_get_feature_quark_b (void)
+{
+ return g_quark_from_static_string ("tp-my-conn-proxy-feature-b");
+}
diff --git a/tests/lib/my-conn-proxy.h b/tests/lib/my-conn-proxy.h
index 37f19a7b..ce160e7d 100644
--- a/tests/lib/my-conn-proxy.h
+++ b/tests/lib/my-conn-proxy.h
@@ -53,6 +53,16 @@ GType tp_tests_my_conn_proxy_get_type (void);
(tp_tests_my_conn_proxy_get_feature_quark_core ())
GQuark tp_tests_my_conn_proxy_get_feature_quark_core (void) G_GNUC_CONST;
+/* No depends */
+#define TP_TESTS_MY_CONN_PROXY_FEATURE_A \
+ (tp_tests_my_conn_proxy_get_feature_quark_a ())
+GQuark tp_tests_my_conn_proxy_get_feature_quark_a (void) G_GNUC_CONST;
+
+/* Depends on A */
+#define TP_TESTS_MY_CONN_PROXY_FEATURE_B \
+ (tp_tests_my_conn_proxy_get_feature_quark_b ())
+GQuark tp_tests_my_conn_proxy_get_feature_quark_b (void) G_GNUC_CONST;
+
G_END_DECLS
#endif /* #ifndef __TP_TESTS_MY_CONN_PROXY_H__ */