From: <svn...@op...> - 2009-08-07 17:57:34
|
Author: bellmich Date: Fri Aug 7 19:57:20 2009 New Revision: 1248 URL: http://libsyncml.opensync.org/changeset/1248 Log: updated test framework Modified: trunk/tests/CMakeLists.txt trunk/tests/check_data_sync_api_change_item.c trunk/tests/check_data_sync_api_map_item.c trunk/tests/check_devinf.c trunk/tests/check_ds.c trunk/tests/check_manager.c trunk/tests/check_session.c trunk/tests/check_sync.c trunk/tests/check_wbxml_assembler.c trunk/tests/check_xml_assembler.c trunk/tests/check_xml_parser.c trunk/tests/support.h Modified: trunk/tests/CMakeLists.txt ============================================================================== --- trunk/tests/CMakeLists.txt Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/CMakeLists.txt Fri Aug 7 19:57:20 2009 (r1248) @@ -91,14 +91,10 @@ SML_START_TEST( "change_item" data_sync_api_change_item check_data_sync_api_change_item.c ${TEST_TARGET_LIBRARIES} ) SML_ADD_TESTCASE( change_item_new ) - SML_ADD_TESTCASE( change_item_set_local ) - SML_ADD_TESTCASE( change_item_set_local_null ) - SML_ADD_TESTCASE( change_item_set_local_missing_uri ) - SML_ADD_TESTCASE( change_item_get_local ) - SML_ADD_TESTCASE( change_item_set_remote ) - SML_ADD_TESTCASE( change_item_set_remote_null ) - SML_ADD_TESTCASE( change_item_set_remote_missing_uri ) - SML_ADD_TESTCASE( change_item_get_remote ) + SML_ADD_TESTCASE( change_item_set_location ) + SML_ADD_TESTCASE( change_item_set_location_null ) + SML_ADD_TESTCASE( change_item_set_location_missing_uri ) + SML_ADD_TESTCASE( change_item_get_location ) SML_ADD_TESTCASE( change_item_set_data ) SML_ADD_TESTCASE( change_item_set_data_with_limit ) SML_ADD_TESTCASE( change_item_set_data_with_length ) Modified: trunk/tests/check_data_sync_api_change_item.c ============================================================================== --- trunk/tests/check_data_sync_api_change_item.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_data_sync_api_change_item.c Fri Aug 7 19:57:20 2009 (r1248) @@ -32,108 +32,19 @@ } END_TEST -START_TEST (change_item_set_local) +START_TEST (change_item_set_location) { setup_testbed(NULL); GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_local_null) -{ - setup_testbed(NULL); - - GError *error = NULL; - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_local_missing_uri) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(!sml_change_item_set_local(item, location, &error), "The location must have an URI."); - sml_fail_unless(error != NULL, NULL); - - g_error_free(error); - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_get_local) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - SmlChangeItem *item = sml_change_item_new(); - sml_fail_unless(item != NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) == NULL, "The local location is not set until now."); - - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) != NULL, "The local location must be set now."); - sml_fail_unless(sml_change_item_get_local(item) == location, "The local location must be 1234."); - - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - - sml_fail_unless(sml_change_item_get_local(item) == NULL, "The local location was deleted."); - - g_object_unref(location); - g_object_unref(item); -} -END_TEST - -START_TEST (change_item_set_remote) -{ - setup_testbed(NULL); - - GError *error = NULL; - SmlLocation *location = sml_location_new(); - sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(location); @@ -141,7 +52,7 @@ } END_TEST -START_TEST (change_item_set_remote_null) +START_TEST (change_item_set_location_null) { setup_testbed(NULL); @@ -150,14 +61,14 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(item); } END_TEST -START_TEST (change_item_set_remote_missing_uri) +START_TEST (change_item_set_location_missing_uri) { setup_testbed(NULL); @@ -168,7 +79,7 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(!sml_change_item_set_remote(item, location, &error), "The location must have an URI."); + sml_fail_unless(!sml_change_item_set_location(item, location, &error), "The location must have an URI."); sml_fail_unless(error != NULL, NULL); g_error_free(error); @@ -177,31 +88,30 @@ } END_TEST -START_TEST (change_item_get_remote) +START_TEST (change_item_get_location) { setup_testbed(NULL); GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, "The remote location is not set until now."); + sml_fail_unless(sml_change_item_get_location(item) == NULL, "The location is not set until now."); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) != NULL, "The remote location must be set now."); - sml_fail_unless(sml_change_item_get_remote(item) == location, "The remote location must be 1234."); + sml_fail_unless(sml_change_item_get_location(item) != NULL, "The location must be set now."); + sml_fail_unless(sml_change_item_get_location(item) == location, "The location must be 1234."); - sml_fail_unless(sml_change_item_set_remote(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, "The remote location was deleted."); + sml_fail_unless(sml_change_item_get_location(item) == NULL, "The location was deleted."); g_object_unref(location); g_object_unref(item); @@ -285,7 +195,7 @@ SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); - sml_fail_unless(sml_change_item_set_local(item, NULL, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, NULL, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); g_object_unref(item); @@ -389,8 +299,6 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); @@ -412,8 +320,6 @@ { setup_testbed(NULL); - GError *error = NULL; - SmlChangeItem *item = sml_change_item_new(); sml_fail_unless(item != NULL, NULL); @@ -545,8 +451,7 @@ SmlChangeItem *frag = sml_change_item_get_fragment(item, 0, 10, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == TRUE, NULL); /* only the first element contains the size */ @@ -560,12 +465,9 @@ SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(item, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -575,8 +477,7 @@ frag = sml_change_item_get_fragment(item, 10, 10, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == location, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == location, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) != NULL, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(frag), "text/plain") == 0, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == TRUE, NULL); @@ -590,8 +491,7 @@ frag = sml_change_item_get_fragment(item, 20, 16, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == location, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == location, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) != NULL, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(frag), "text/plain") == 0, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == FALSE, NULL); @@ -622,8 +522,7 @@ SmlChangeItem *frag = sml_change_item_get_fragment(item, 0, strlen(data)+1, &error); sml_fail_unless(frag != NULL, "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_get_local(frag) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(frag) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(frag) == NULL, NULL); sml_fail_unless(sml_change_item_get_missing_data(frag) == FALSE, NULL); sml_fail_unless(sml_change_item_get_planned_size(frag) == 0, NULL); @@ -712,8 +611,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == TRUE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(item) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(item) == NULL, NULL); g_object_unref(frag); frag = NULL; @@ -722,12 +620,9 @@ SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); - sml_fail_unless(sml_change_item_set_local(item, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(item, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(item, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(item, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -739,9 +634,7 @@ sml_fail_unless(sml_change_item_set_data(frag, data3, 0, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_change_item_set_missing_data(frag, FALSE); - sml_fail_unless(sml_change_item_set_local(frag, location, &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_change_item_set_remote(frag, location, &error), "%s", error?error->message:"No GError set."); + sml_fail_unless(sml_change_item_set_location(frag, location, &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); sml_fail_unless(sml_change_item_set_content_type(frag, "text/plain", &error), "%s", error?error->message:"No GError set."); sml_fail_unless(error == NULL, NULL); @@ -751,8 +644,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2) + strlen(data3), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == FALSE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == location, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == location, NULL); + sml_fail_unless(sml_change_item_get_location(item) == location, NULL); sml_fail_unless(strcmp(sml_change_item_get_content_type(item), "text/plain") == 0, NULL); g_object_unref(frag); frag = NULL; @@ -826,8 +718,7 @@ sml_fail_unless(strlen(sml_change_item_get_data(item)) == strlen(data1) + strlen(data2), NULL); sml_fail_unless(sml_change_item_get_missing_data(item) == FALSE, NULL); - sml_fail_unless(sml_change_item_get_local(item) == NULL, NULL); - sml_fail_unless(sml_change_item_get_remote(item) == NULL, NULL); + sml_fail_unless(sml_change_item_get_location(item) == NULL, NULL); sml_fail_unless(sml_change_item_get_content_type(item) == NULL, NULL); g_object_unref(frag); frag = NULL; Modified: trunk/tests/check_data_sync_api_map_item.c ============================================================================== --- trunk/tests/check_data_sync_api_map_item.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_data_sync_api_map_item.c Fri Aug 7 19:57:20 2009 (r1248) @@ -38,8 +38,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -76,10 +75,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_name(location, "my 1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_name(location, "my 1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -100,10 +97,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(location, "56", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_parent_uri(location, "56"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -144,8 +139,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -170,8 +164,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -208,10 +201,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_name(location, "my 1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_name(location, "my 1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -232,10 +223,8 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); - sml_fail_unless(sml_location_set_parent_uri(location, "56", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); + sml_location_set_parent_uri(location, "56"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -276,8 +265,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -302,8 +290,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -329,8 +316,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -355,8 +341,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -381,12 +366,10 @@ GError *error = NULL; SmlLocation *local = sml_location_new(); sml_fail_unless(local != NULL, NULL); - sml_fail_unless(sml_location_set_uri(local, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(local, "1234"); SmlLocation *remote = sml_location_new(); sml_fail_unless(remote != NULL, NULL); - sml_fail_unless(sml_location_set_uri(remote, "5678", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(remote, "5678"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -401,7 +384,7 @@ sml_fail_unless(error == NULL, NULL); /* add name */ - sml_fail_unless(sml_location_set_name(local, "my 1234", &error), "%s", error?error->message:"No GError set."); + sml_location_set_name(local, "my 1234"); sml_fail_unless(!sml_map_item_is_compliant(item, NULL), "The item is not compliant."); sml_fail_unless(!sml_map_item_is_compliant(item, &error), "The item is not compliant."); @@ -421,12 +404,10 @@ GError *error = NULL; SmlLocation *local = sml_location_new(); sml_fail_unless(local != NULL, NULL); - sml_fail_unless(sml_location_set_uri(local, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(local, "1234"); SmlLocation *remote = sml_location_new(); sml_fail_unless(remote != NULL, NULL); - sml_fail_unless(sml_location_set_uri(remote, "5678", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(remote, "5678"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); @@ -441,7 +422,7 @@ sml_fail_unless(error == NULL, NULL); /* add parent */ - sml_fail_unless(sml_location_set_parent_uri(remote, "56", &error), "%s", error?error->message:"No GError set."); + sml_location_set_parent_uri(remote, "56"); sml_fail_unless(!sml_map_item_is_compliant(item, NULL), "The item is not compliant."); sml_fail_unless(!sml_map_item_is_compliant(item, &error), "The item is not compliant."); @@ -461,8 +442,7 @@ GError *error = NULL; SmlLocation *location = sml_location_new(); sml_fail_unless(location != NULL, NULL); - sml_fail_unless(sml_location_set_uri(location, "1234", &error), "%s", error?error->message:"No GError set."); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(location, "1234"); SmlMapItem *item = sml_map_item_new(); sml_fail_unless(item != NULL, NULL); Modified: trunk/tests/check_devinf.c ============================================================================== --- trunk/tests/check_devinf.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_devinf.c Fri Aug 7 19:57:20 2009 (r1248) @@ -23,7 +23,7 @@ #include <libsyncml/objects/sml_auth.h> #include <libsyncml/objects/sml_devinf_obj.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include "libsyncml/parser/sml_xml_parse.h" #include <string.h> @@ -45,7 +45,7 @@ unsigned int defaultMaxMsgSize = 10240; unsigned int defaultMaxObjSize = 1024000; -static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata) +static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); managerTracker *tracker = userdata; @@ -123,9 +123,9 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); /* The authenticator */ SmlAuthenticator *auth2 = smlAuthNew(&error); @@ -252,13 +252,13 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); - SmlLocation *loc1 = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc1 = sml_location_new(); sml_fail_unless(loc1 != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc1, "test"); /* The devinf obj */ SmlDevInf *devinf = sml_dev_inf_new(); Modified: trunk/tests/check_ds.c ============================================================================== --- trunk/tests/check_ds.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_ds.c Fri Aug 7 19:57:20 2009 (r1248) @@ -28,7 +28,7 @@ #include <libsyncml/objects/sml_ds_server_internals.h> #include <libsyncml/sml_session_internals.h> #include <libsyncml/sml_elements_internals.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> typedef struct SmlSessionThread { GMainContext *context; @@ -269,32 +269,28 @@ smlTrace(TRACE_EXIT, "%s", __func__); } -static gboolean _recv_changes(SmlDsSession *dsession, SmlChangeType type, const char *uid, char *data, gsize size, const char *contenttype, void *userdata, GError **error) +static gboolean _recv_changes(SmlDsSession *dsession, SmlChangeItem *item, void *userdata, GError **error) { - smlTrace(TRACE_ENTRY, "%s(%p, %i, %s, %s, %i, %s, %p, %p)", __func__, dsession, type, VA_STRING(uid), VA_STRING(data), size, VA_STRING(contenttype), userdata, error); + smlTrace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, dsession, item, userdata, error); - if (type == SML_CHANGE_ADD) { + if (sml_change_item_get_action(item) == SML_CHANGE_ADD) { g_atomic_int_add(&adds_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!strncmp(data, "data", size)); - g_assert(size == 4); - } else if (type == SML_CHANGE_REPLACE) { + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!strncmp(sml_change_item_get_data(item), "data", strlen(sml_change_item_get_data(item)))); + g_assert(strlen(sml_change_item_get_data(item)) == 4); + } else if (sml_change_item_get_action(item) == SML_CHANGE_REPLACE) { g_atomic_int_add(&modifies_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!strncmp(data, "newdata", size)); - g_assert(size == 7); - } else if (type == SML_CHANGE_DELETE) { + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!strncmp(sml_change_item_get_data(item), "newdata", strlen(sml_change_item_get_data(item)))); + g_assert(strlen(sml_change_item_get_data(item)) == 7); + } else if (sml_change_item_get_action(item) == SML_CHANGE_DELETE) { g_atomic_int_add(&deletes_received, 1); - g_assert(!strcmp(uid, "uid")); - g_assert(!data); - g_assert(size == 0); + g_assert(!strcmp(sml_location_get_uri(sml_change_item_get_location(item)), "uid")); + g_assert(!sml_change_item_get_data(item)); } else { - sml_fail_unless(FALSE, "An unexpected SyncML change type %d was received.", type); + sml_fail_unless(FALSE, "An unexpected SyncML change type %d was received.", sml_change_item_get_action(item)); } - if (data) - smlSafeCFree(&data); - smlTrace(TRACE_EXIT, "%s", __func__); return TRUE; } @@ -399,11 +395,10 @@ { setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *server = smlDsServerNew(SML_ELEMENT_TEXT_VCARD, loc, &error); sml_fail_unless(server != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -418,11 +413,10 @@ { setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *server = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); sml_fail_unless(server != NULL, NULL); sml_fail_unless(error == NULL, NULL); @@ -522,11 +516,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); _server_corr *client_corr = g_malloc0(sizeof(_server_corr)); @@ -634,12 +627,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); - + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); _server_corr *client_corr = g_malloc0(sizeof(_server_corr)); @@ -760,11 +751,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -909,11 +899,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1077,11 +1066,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1138,8 +1126,6 @@ smlDsSessionGetAlert(client_corr->dsession, _recv_alert, GINT_TO_POINTER(1)); - - while (alerts_received != 2) { smlDsSessionDispatch(client_corr->dsession); usleep(500); @@ -1147,7 +1133,9 @@ smlDsSessionSendSync(client_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1257,11 +1245,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1327,7 +1314,9 @@ smlDsSessionSendSync(client_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1350,7 +1339,9 @@ smlDsSessionSendSync(server_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1371,11 +1362,15 @@ } SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -1463,11 +1458,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1533,7 +1527,9 @@ smlDsSessionSendSync(client_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1556,7 +1552,9 @@ smlDsSessionSendSync(server_corr->dsession, 1, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1649,11 +1647,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1719,13 +1716,19 @@ smlDsSessionSendSync(client_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(client_corr->dsession, &error); @@ -1748,13 +1751,19 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_REPLACE, "uid", "newdata", 7, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _modify_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_DELETE, "uid", NULL, 0, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _delete_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); smlDsSessionCloseSync(server_corr->dsession, &error); @@ -1775,11 +1784,15 @@ } SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -1869,11 +1882,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -1938,7 +1950,9 @@ int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -1963,7 +1977,9 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -1986,11 +2002,15 @@ for (i = 0; i < num; i++) { SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -2082,11 +2102,10 @@ /* General setup */ setup_testbed(NULL); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/vcards", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "/vcards"); SmlDsServer *client = smlDsClientNew(SML_ELEMENT_TEXT_VCARD, loc, loc, &error); @@ -2151,7 +2170,9 @@ int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -2173,7 +2194,9 @@ smlDsSessionSendSync(server_corr->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } @@ -2193,11 +2216,15 @@ for (i = 0; i < num; i++) { SmlMapItem *item = sml_map_item_new(); - SmlLocation *local = sml_location_new_with_options("uid", NULL, &error); + SmlLocation *local = sml_location_new(); + sml_fail_unless(local != NULL, NULL); + sml_location_set_uri(local, "uid"); sml_map_item_set_local(item, local, &error); g_object_unref(local); local = NULL; - SmlLocation *remote = sml_location_new_with_options("newuid", NULL, &error); + SmlLocation *remote = sml_location_new(); + sml_fail_unless(remote != NULL, NULL); + sml_location_set_uri(remote, "newuid"); sml_map_item_set_remote(item, remote, &error); g_object_unref(remote); remote = NULL; @@ -2396,21 +2423,27 @@ smlDsSessionSendSync(client_corr1->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); int i = 0; for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr1->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr1->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr1->dsession, &error); smlDsSessionSendSync(client_corr2->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr2->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr2->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr2->dsession, &error); smlDsSessionSendSync(client_corr3->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(client_corr3->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(client_corr3->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(2), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(client_corr3->dsession, &error); @@ -2438,21 +2471,27 @@ smlDsSessionSendSync(server_corr1->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr1->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr1->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr1->dsession, &error); smlDsSessionSendSync(server_corr2->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr2->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr2->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr2->dsession, &error); smlDsSessionSendSync(server_corr3->dsession, 0, _sync_reply, GINT_TO_POINTER(1), &error); for (i = 0; i < num; i++) { - sml_fail_unless(smlDsSessionQueueChange(server_corr3->dsession, SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_NEW(SML_CHANGE_ADD, "uid", "data", 4, SML_ELEMENT_TEXT_VCARD); + sml_fail_unless(smlDsSessionQueueChange(server_corr3->dsession, TEST_CHANGE_ITEM, _add_reply, GINT_TO_POINTER(1), &error), NULL); + TEST_CHANGE_ITEM_FREE(); sml_fail_unless(error == NULL, NULL); } smlDsSessionCloseSync(server_corr3->dsession, &error); Modified: trunk/tests/check_manager.c ============================================================================== --- trunk/tests/check_manager.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_manager.c Fri Aug 7 19:57:20 2009 (r1248) @@ -22,7 +22,7 @@ #include "tests/support.h" #include <libsyncml/sml_session_internals.h> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include <libsyncml/sml_error_internals.h> #define NUM_SESSIONS 30 @@ -108,7 +108,7 @@ setup_testbed(NULL); } -static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, GError *error, void *userdata) +static void _manager_event(SmlManager *manager, SmlManagerEventType type, SmlSession *session, const GError *error, void *userdata) { smlTrace(TRACE_ENTRY, "%s(%p, %i, %p, %p, %p)", __func__, manager, type, session, error, userdata); managerTracker *tracker = userdata; @@ -510,7 +510,6 @@ { reset_testbed(); - GError *gerror = NULL; GError *error = NULL; SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); @@ -536,9 +535,9 @@ sml_fail_unless(smlManagerStart(servermanager, &error), NULL); sml_fail_unless(error == NULL, NULL); - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(gerror == NULL, NULL); + sml_location_set_uri(loc, "test"); sml_fail_unless(smlManagerObjectRegister(servermanager, SML_COMMAND_TYPE_ALERT, NULL, loc, NULL, NULL, _recv_alert, NULL, NULL, &error), NULL); sml_fail_unless(error == NULL, NULL); @@ -630,9 +629,10 @@ { reset_testbed(); - GError *gerror = NULL; GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("test", NULL, &gerror); + SmlLocation *loc = sml_location_new(); + sml_fail_unless(loc != NULL, NULL); + sml_location_set_uri(loc, "test"); SmlTransport *server = smlTransportNew(SML_TRANSPORT_HTTP_SERVER, &error); SmlTransport *client = smlTransportNew(SML_TRANSPORT_HTTP_CLIENT, &error); Modified: trunk/tests/check_session.c ============================================================================== --- trunk/tests/check_session.c Fri Aug 7 19:56:42 2009 (r1247) +++ trunk/tests/check_session.c Fri Aug 7 19:57:20 2009 (r1248) @@ -1,7 +1,7 @@ /* * libsyncml - A syncml protocol implementation * Copyright (C) 2005 Armin Bauer <arm...@op...> - * Copyright (C) 2008 Michael Bell <mic...@op...> + * Copyright (C) 2008-2009 Michael Bell <mic...@op...> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,7 @@ #include <libsyncml/sml_command_internals.h> #include <libsyncml/sml_transport_internals.h> #include <libsyncml/objects/sml_auth.c> -#include <libsyncml/data_sync_api/sml_location_internals.h> +#include <libsyncml/data_sync_api/sml_location.h> #include <libsyncml/sml_notification.h> @@ -320,9 +320,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); + sml_location_set_uri(loc, "/test"); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); sml_fail_unless(session != NULL, NULL); @@ -341,9 +341,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); @@ -385,51 +385,42 @@ g_atomic_int_inc(¤t_cmd_id); if (GPOINTER_TO_INT(userdata) == 3 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - smlAssert(size == 8); + smlAssert(strlen(data) == 8); smlAssert(!strncmp(data, "datadata", 8)); } if (GPOINTER_TO_INT(userdata) == 4 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - smlAssert(size == 20); + smlAssert(strlen(data) == 20); smlAssert(!strncmp(data, "datadatadatadatatest", 20)); } if (GPOINTER_TO_INT(userdata) == 5 && command->type == SML_COMMAND_TYPE_ADD) { - smlAssert(command->private.change.items); - smlAssert(g_list_length(command->private.change.items)); - SmlItem *item = g_list_nth_data(command->private.change.items, 0); + smlAssert(smlCommandGetNumChanges(command)); + SmlChangeItem *item = smlCommandGetNthChange(command, 0); smlAssert(item); - smlAssert(smlItemCheck(item)); + //smlAssert(smlItemCheck(item)); - char *data = NULL; - gsize size = 0; - smlAssert(smlItemGetData(item, &data, &size, &locerror)); + const char *data = sml_change_item_get_data(item); - if (size != 4) { - smlAssert(size == item_size); + if (strlen(data) != 4) { + smlAssert(strlen(data) == item_size); smlAssert(!strncmp(data, item_data, item_size)); } else { - smlAssert(size == 4); + smlAssert(strlen(data) == 4); smlAssert(!strncmp(data, "data", 4)); } } @@ -535,9 +526,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -576,9 +567,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -618,9 +609,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); const char *input = "<SyncML xmlns=\"SYNCML:SYNCML1.2\"><SyncHdr><VerProto>SyncML/1.1</VerProto><VerDTD>1.2</VerDTD><MsgID>1</MsgID><SessionID>1</SessionID><Target><LocURI>/test</LocURI></Target><Source><LocURI>/test</LocURI></Source></SyncHdr><SyncBody><Alert><CmdID>1</CmdID><Item><Target><LocURI>/test</LocURI></Target><Source><LocURI>/test</LocURI></Source><Meta><Anchor xmlns=\"syncml:metinf\"><Next>last</Next><Last>next</Last></Anchor></Meta></Item><Data>200</Data></Alert><Final></Final></SyncBody></SyncML>"; @@ -671,9 +662,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -751,9 +742,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -829,9 +820,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session, &to_session); @@ -926,9 +917,9 @@ GError *error = NULL; - SmlLocation *loc = sml_location_new_with_options("/test", NULL, &error); + SmlLocation *loc = sml_location_new(); sml_fail_unless(loc != NULL, NULL); - sml_fail_unless(error == NULL, NULL); + sml_location_set_uri(loc, "/test"); SmlSession *session = smlSessionNew(SML_SESSION_TYPE_CLIENT, SML_MIMETYPE_XML, SML_VERSION_12, SML_PROTOCOL_SYNCML, loc, loc, 1, 0, &error); SmlSessionThread *thread1 = smlSessionRunAsync(session,... [truncated message content] |