From: Tristan Van Berkom Date: Mon, 21 Jan 2013 08:35:13 +0000 (+0900) Subject: Improving test-client-remove-contact X-Git-Tag: upstream/3.7.5~153 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fbb82c17f22686414840df6e51e770bd0ceabaf2;p=platform%2Fupstream%2Fevolution-data-server.git Improving test-client-remove-contact Check for error type is more clear and safe now. --- diff --git a/tests/libebook/client/test-client-remove-contact.c b/tests/libebook/client/test-client-remove-contact.c index 2649f09..bb314aa 100644 --- a/tests/libebook/client/test-client-remove-contact.c +++ b/tests/libebook/client/test-client-remove-contact.c @@ -8,12 +8,28 @@ static ETestServerClosure book_closure = { E_TEST_SERVER_ADDRESS_BOOK, NULL, 0 }; static void +check_removed_contact (EBookClient *book_client, + const gchar *uid) +{ + GError *error = NULL; + EContact *contact = NULL; + + if (e_book_client_get_contact_sync (book_client, uid, &contact, NULL, &error)) + g_error ("succeeded to fetch removed contact"); + else if (!g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) + g_error ("Wrong error in get contact sync on removed contact: %s (domain: %s, code: %d)", + error->message, g_quark_to_string (error->domain), error->code); + else + g_clear_error (&error); +} + +static void test_remove_contact_sync (ETestServerFixture *fixture, gconstpointer user_data) { EBookClient *book_client; GError *error = NULL; - EContact *contact; + EContact *contact = NULL; gchar *uid; book_client = E_TEST_SERVER_UTILS_SERVICE (fixture, EBookClient); @@ -28,11 +44,7 @@ test_remove_contact_sync (ETestServerFixture *fixture, g_object_unref (contact); - if (!e_book_client_get_contact_sync (book_client, uid, &contact, NULL, &error) && - g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) { - g_clear_error (&error); - } else - g_error ("fail with get contact sync on removed contact: %s", error->message); + check_removed_contact (book_client, uid); g_free (uid); } @@ -49,16 +61,11 @@ remove_contact_cb (GObject *source_object, { RemoveData *data = (RemoveData *) user_data; GError *error = NULL; - EContact *contact = NULL; if (!e_book_client_remove_contact_finish (E_BOOK_CLIENT (source_object), result, &error)) g_error ("remove contact finish: %s", error->message); - if (!e_book_client_get_contact_sync (E_BOOK_CLIENT (source_object), data->uid, &contact, NULL, &error) && - g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) { - g_clear_error (&error); - } else - g_error ("fail with get contact on removed contact: %s", error->message); + check_removed_contact (E_BOOK_CLIENT (source_object), data->uid); g_main_loop_quit (data->loop); }