summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-01-17 11:53:11 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-12 12:30:41 +0200
commit66d91c25f2e0484ba1e2ab575adf702a388b3607 (patch)
tree367c67f06dcb06eb38e936d7d9b06724561a133c
parentd173d87dac5cd36fe3c2af9e4b16d30cf3ee1b7e (diff)
test preparing a feature which fail
-rw-r--r--tests/dbus/proxy-preparation.c20
-rw-r--r--tests/lib/my-conn-proxy.c28
-rw-r--r--tests/lib/my-conn-proxy.h5
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c
index 1e920802..e099d866 100644
--- a/tests/dbus/proxy-preparation.c
+++ b/tests/dbus/proxy-preparation.c
@@ -180,6 +180,24 @@ test_bad_dep (Test *test,
TP_TESTS_MY_CONN_PROXY_FEATURE_BAD_DEP));
}
+static void
+test_fail (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ /* Feature preparation fails */
+ GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_FAIL, 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_FAIL));
+}
+
int
main (int argc,
char **argv)
@@ -201,6 +219,8 @@ main (int argc,
test_wrong_iface, teardown);
g_test_add ("/proxy-preparation/bad-dep", Test, NULL, setup,
test_bad_dep, teardown);
+ g_test_add ("/proxy-preparation/fail", Test, NULL, setup,
+ test_fail, teardown);
return g_test_run ();
}
diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c
index 30618480..dd0f5676 100644
--- a/tests/lib/my-conn-proxy.c
+++ b/tests/lib/my-conn-proxy.c
@@ -27,6 +27,7 @@ enum {
FEAT_B,
FEAT_WRONG_IFACE,
FEAT_BAD_DEP,
+ FEAT_FAIL,
N_FEAT
};
@@ -89,6 +90,24 @@ cannot_be_prepared_async (TpProxy *proxy,
g_assert_not_reached ();
}
+static void
+prepare_fail_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_error ((GObject *) proxy, callback,
+ user_data, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "No feature for you!");
+
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+}
+
static const TpProxyFeature *
list_features (TpProxyClass *cls G_GNUC_UNUSED)
{
@@ -125,6 +144,9 @@ list_features (TpProxyClass *cls G_GNUC_UNUSED)
need_wrong_iface[0] = TP_TESTS_MY_CONN_PROXY_FEATURE_WRONG_IFACE;
features[FEAT_BAD_DEP].depends_on = need_wrong_iface;
+ features[FEAT_FAIL].name = TP_TESTS_MY_CONN_PROXY_FEATURE_FAIL;
+ features[FEAT_FAIL].prepare_async = prepare_fail_async;
+
return features;
}
@@ -165,3 +187,9 @@ tp_tests_my_conn_proxy_get_feature_quark_bad_dep (void)
{
return g_quark_from_static_string ("tp-my-conn-proxy-feature-bad-dep");
}
+
+GQuark
+tp_tests_my_conn_proxy_get_feature_quark_fail (void)
+{
+ return g_quark_from_static_string ("tp-my-conn-proxy-feature-fail");
+}
diff --git a/tests/lib/my-conn-proxy.h b/tests/lib/my-conn-proxy.h
index 7c8f6fa3..b8cd2ada 100644
--- a/tests/lib/my-conn-proxy.h
+++ b/tests/lib/my-conn-proxy.h
@@ -73,6 +73,11 @@ GQuark tp_tests_my_conn_proxy_get_feature_quark_wrong_iface (void) G_GNUC_CONST;
(tp_tests_my_conn_proxy_get_feature_quark_bad_dep ())
GQuark tp_tests_my_conn_proxy_get_feature_quark_bad_dep (void) G_GNUC_CONST;
+/* Fail during preparation */
+#define TP_TESTS_MY_CONN_PROXY_FEATURE_FAIL \
+ (tp_tests_my_conn_proxy_get_feature_quark_fail ())
+GQuark tp_tests_my_conn_proxy_get_feature_quark_fail (void) G_GNUC_CONST;
+
G_END_DECLS
#endif /* #ifndef __TP_TESTS_MY_CONN_PROXY_H__ */