diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-10-28 13:17:22 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-11 16:49:05 +0000 |
commit | a48cf1a835d94ea6220d67883eca4071e686a4a7 (patch) | |
tree | 75ce749de3bc8dfaabfd2fc3183b0da03dc226a9 /tests | |
parent | 689c4297ff8cd7cf971ba4bf46ad605a3149f6b4 (diff) | |
download | telepathy-glib-a48cf1a835d94ea6220d67883eca4071e686a4a7.tar.gz |
tp_protocol_identify_account_async: add and test
To make the test a little more interesting and a little more realistic,
we normalize the 'account' parameter to lower-case.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71048
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dbus/protocol-objects.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c index 248805728..fee4afe4b 100644 --- a/tests/dbus/protocol-objects.c +++ b/tests/dbus/protocol-objects.c @@ -567,6 +567,62 @@ test_normalize (Test *test, g_clear_error (&test->error); } +static void +test_id (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + GAsyncResult *result = NULL; + gchar *s; + + tp_tests_proxy_run_until_prepared (test->cm, NULL); + test->protocol = g_object_ref ( + tp_connection_manager_get_protocol_object (test->cm, "example")); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("{ 'account': <'Hello'> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_no_error (test->error); + g_assert_cmpstr (s, ==, "hello"); + g_clear_object (&result); + g_free (s); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("{ 'account': <'Hello'>, 'unknown-param': <42> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("@a{sv} {}"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); + + tp_protocol_identify_account_async (test->protocol, + g_variant_new_parsed ("@a{sv} { 'account': <''> }"), + NULL, tp_tests_result_ready_cb, &result); + tp_tests_run_until_result (&result); + s = tp_protocol_identify_account_finish (test->protocol, result, + &test->error); + g_assert_error (test->error, TP_ERROR, TP_ERROR_INVALID_ARGUMENT); + g_assert_cmpstr (s, ==, NULL); + g_clear_object (&result); + g_clear_error (&test->error); +} + int main (int argc, char **argv) @@ -592,6 +648,8 @@ main (int argc, test_protocol_object_from_file, teardown); g_test_add ("/protocol-objects/normalize", Test, NULL, setup, test_normalize, teardown); + g_test_add ("/protocol-objects/id", Test, NULL, setup, + test_id, teardown); return tp_tests_run_with_bus (); } |