[next] telepathy-glib: future-account test: add a test for CreateChannel failing
Jonny Lamb
jonny at kemper.freedesktop.org
Fri May 11 02:41:34 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 241acf6d9cd8f6f0b001d16e56269f7673cac69c
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=241acf6d9cd8f6f0b001d16e56269f7673cac69c
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Thu Apr 26 16:51:17 2012 +0100
future-account test: add a test for CreateChannel failing
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
tests/dbus/future-account.c | 35 ++++++++++++++++++++++++++++++++---
tests/lib/simple-account-manager.c | 8 ++++++++
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/tests/dbus/future-account.c b/tests/dbus/future-account.c
index 1511764..0b6b697 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -227,7 +227,7 @@ test_properties (Test *test,
}
static void
-test_create (Test *test,
+test_create_succeed (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpAccount *account;
@@ -283,6 +283,33 @@ test_create (Test *test,
g_object_unref (account);
}
+static void
+test_create_fail (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ TpAccount *account;
+
+ test->account = tp_future_account_new (test->account_manager,
+ "gabble", "jabber");
+
+ tp_future_account_set_display_name (test->account, "Walter White");
+
+ /* this will make CreateChannel fail */
+ tp_future_account_set_parameter_string (test->account,
+ "fail", "yes");
+
+ tp_future_account_create_account_async (test->account,
+ tp_tests_result_ready_cb, &test->result);
+ tp_tests_run_until_result (&test->result);
+
+ account = tp_future_account_create_account_finish (test->account,
+ test->result, &test->error);
+ g_assert (test->error != NULL);
+ g_assert (account == NULL);
+
+ g_clear_error (&test->error);
+}
+
int
main (int argc,
char **argv)
@@ -301,8 +328,10 @@ main (int argc,
test_parameters, teardown);
g_test_add ("/future-account/properties", Test, NULL, setup,
test_properties, teardown);
- g_test_add ("/future-account/create", Test, NULL, setup,
- test_create, teardown);
+ g_test_add ("/future-account/create-succeed", Test, NULL, setup,
+ test_create_succeed, teardown);
+ g_test_add ("/future-account/create-fail", Test, NULL, setup,
+ test_create_fail, teardown);
return g_test_run ();
}
diff --git a/tests/lib/simple-account-manager.c b/tests/lib/simple-account-manager.c
index 9caf86f..e1fec67 100644
--- a/tests/lib/simple-account-manager.c
+++ b/tests/lib/simple-account-manager.c
@@ -61,6 +61,14 @@ tp_tests_simple_account_manager_create_account (TpSvcAccountManager *svc,
TpTestsSimpleAccountManager *self = (TpTestsSimpleAccountManager *) svc;
const gchar *out = TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/lospolloshermanos";
+ /* if we have fail=yes as a parameter, make the call fail */
+ if (!tp_strdiff (tp_asv_get_string (in_Parameters, "fail"), "yes"))
+ {
+ GError e = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "loldongs" };
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+
self->create_cm = g_strdup (in_Connection_Manager);
self->create_protocol = g_strdup (in_Protocol);
self->create_display_name = g_strdup (in_Display_Name);
More information about the telepathy-commits
mailing list