diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-01-17 11:35:39 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-05-12 12:30:41 +0200 |
commit | d2bf687c5de58224992e9443dcdd1f9bf8ca959e (patch) | |
tree | cbdc5461d089e8eae7efc05032a8ff8fd203ce13 | |
parent | 61b3847982a901b95593a07135285a81fd3f08b8 (diff) |
test preparing a feature requiring a not implemented iface
-rw-r--r-- | tests/dbus/proxy-preparation.c | 21 | ||||
-rw-r--r-- | tests/lib/my-conn-proxy.c | 23 | ||||
-rw-r--r-- | tests/lib/my-conn-proxy.h | 5 |
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c index 3063d942..863e3348 100644 --- a/tests/dbus/proxy-preparation.c +++ b/tests/dbus/proxy-preparation.c @@ -140,6 +140,25 @@ test_depends (Test *test, TP_TESTS_MY_CONN_PROXY_FEATURE_B)); } +static void +test_wrong_iface (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + /* Feature can't be prepared because proxy doesn't support the right + * interface */ + GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_WRONG_IFACE, 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_WRONG_IFACE)); +} + int main (int argc, char **argv) @@ -157,6 +176,8 @@ main (int argc, test_prepare_core, teardown); g_test_add ("/proxy-preparation/depends", Test, NULL, setup, test_depends, teardown); + g_test_add ("/proxy-preparation/wrong-iface", Test, NULL, setup, + test_wrong_iface, teardown); return g_test_run (); } diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c index 96ab00d3..157892fb 100644 --- a/tests/lib/my-conn-proxy.c +++ b/tests/lib/my-conn-proxy.c @@ -25,6 +25,7 @@ enum { FEAT_CORE, FEAT_A, FEAT_B, + FEAT_WRONG_IFACE, N_FEAT }; @@ -78,11 +79,21 @@ prepare_b_async (TpProxy *proxy, g_object_unref (result); } +static void +cannot_be_prepared_async (TpProxy *proxy, + const TpProxyFeature *feature, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_assert_not_reached (); +} + static const TpProxyFeature * list_features (TpProxyClass *cls G_GNUC_UNUSED) { static TpProxyFeature features[N_FEAT + 1] = { { 0 } }; static GQuark need_a[2] = {0, 0}; + static GQuark need_channel_core[2] = {0, 0}; if (G_LIKELY (features[0].name != 0)) return features; @@ -100,6 +111,12 @@ list_features (TpProxyClass *cls G_GNUC_UNUSED) need_a[0] = TP_TESTS_MY_CONN_PROXY_FEATURE_A; features[FEAT_B].depends_on = need_a; + features[FEAT_WRONG_IFACE].name = TP_TESTS_MY_CONN_PROXY_FEATURE_WRONG_IFACE; + features[FEAT_WRONG_IFACE].prepare_async = cannot_be_prepared_async; + if (G_UNLIKELY (need_channel_core[0] == 0)) + need_channel_core[0] = TP_CHANNEL_FEATURE_CORE; + features[FEAT_WRONG_IFACE].interfaces_needed = need_channel_core; + return features; } @@ -128,3 +145,9 @@ tp_tests_my_conn_proxy_get_feature_quark_b (void) { return g_quark_from_static_string ("tp-my-conn-proxy-feature-b"); } + +GQuark +tp_tests_my_conn_proxy_get_feature_quark_wrong_iface (void) +{ + return g_quark_from_static_string ("tp-my-conn-proxy-feature-wrong_iface"); +} diff --git a/tests/lib/my-conn-proxy.h b/tests/lib/my-conn-proxy.h index ce160e7d..71d8d90f 100644 --- a/tests/lib/my-conn-proxy.h +++ b/tests/lib/my-conn-proxy.h @@ -63,6 +63,11 @@ GQuark tp_tests_my_conn_proxy_get_feature_quark_a (void) G_GNUC_CONST; (tp_tests_my_conn_proxy_get_feature_quark_b ()) GQuark tp_tests_my_conn_proxy_get_feature_quark_b (void) G_GNUC_CONST; +/* Depends on an unimplemented iface */ +#define TP_TESTS_MY_CONN_PROXY_FEATURE_WRONG_IFACE \ + (tp_tests_my_conn_proxy_get_feature_quark_wrong_iface ()) +GQuark tp_tests_my_conn_proxy_get_feature_quark_wrong_iface (void) G_GNUC_CONST; + G_END_DECLS #endif /* #ifndef __TP_TESTS_MY_CONN_PROXY_H__ */ |