[libgdata] [tests] Rearrange tests to use --no-internet option



commit c033884168796d4ebd685532717dc47a24d7b703
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Aug 7 17:16:02 2010 +0100

    [tests] Rearrange tests to use --no-internet option
    
    This also removes the dependency of a lot of tests on the -m (mode) command
    line option, meaning that more tests get run by default.

 gdata/tests/calendar.c  |   43 +++++++++++++++++---------------
 gdata/tests/contacts.c  |   54 ++++++++++++++++++++++++----------------
 gdata/tests/documents.c |   46 +++++++++++++++++++----------------
 gdata/tests/picasaweb.c |   58 +++++++++++++++++++++++++-------------------
 gdata/tests/youtube.c   |   62 +++++++++++++++++++++++++---------------------
 5 files changed, 147 insertions(+), 116 deletions(-)
---
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index aed81ca..3a434a1 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -291,7 +291,7 @@ test_insert_simple (gconstpointer service)
 }
 
 static void
-test_xml_dates (gconstpointer service)
+test_xml_dates (void)
 {
 	GDataCalendarEvent *event;
 	GList *times, *i;
@@ -385,7 +385,7 @@ test_xml_dates (gconstpointer service)
 }
 
 static void
-test_xml_recurrence (gconstpointer service)
+test_xml_recurrence (void)
 {
 	GDataCalendarEvent *event;
 	GError *error = NULL;
@@ -734,38 +734,41 @@ int
 main (int argc, char *argv[])
 {
 	gint retval;
-	GDataService *service;
+	GDataService *service = NULL;
 
 	gdata_test_init (argc, argv);
 
-	service = GDATA_SERVICE (gdata_calendar_service_new (CLIENT_ID));
-	gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
+	if (gdata_test_internet () == TRUE) {
+		service = GDATA_SERVICE (gdata_calendar_service_new (CLIENT_ID));
+		gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
 
-	g_test_add_func ("/calendar/authentication", test_authentication);
-	if (g_test_thorough () == TRUE)
+		g_test_add_func ("/calendar/authentication", test_authentication);
 		g_test_add_func ("/calendar/authentication_async", test_authentication_async);
-	g_test_add_data_func ("/calendar/query/all_calendars", service, test_query_all_calendars);
-	if (g_test_thorough () == TRUE)
+
+		g_test_add_data_func ("/calendar/query/all_calendars", service, test_query_all_calendars);
 		g_test_add_data_func ("/calendar/query/all_calendars_async", service, test_query_all_calendars_async);
-	g_test_add_data_func ("/calendar/query/own_calendars", service, test_query_own_calendars);
-	if (g_test_thorough () == TRUE)
+		g_test_add_data_func ("/calendar/query/own_calendars", service, test_query_own_calendars);
 		g_test_add_data_func ("/calendar/query/own_calendars_async", service, test_query_own_calendars_async);
-	g_test_add_data_func ("/calendar/query/events", service, test_query_events);
-	if (g_test_slow () == TRUE)
+		g_test_add_data_func ("/calendar/query/events", service, test_query_events);
+
 		g_test_add_data_func ("/calendar/insert/simple", service, test_insert_simple);
-	g_test_add_data_func ("/calendar/xml/dates", service, test_xml_dates);
-	g_test_add_data_func ("/calendar/xml/recurrence", service, test_xml_recurrence);
-	g_test_add_func ("/calendar/query/uri", test_query_uri);
-	g_test_add_func ("/calendar/query/etag", test_query_etag);
-	g_test_add_data_func ("/calendar/acls/get_rules", service, test_acls_get_rules);
-	if (g_test_slow () == TRUE) {
+
+		g_test_add_data_func ("/calendar/acls/get_rules", service, test_acls_get_rules);
 		g_test_add_data_func ("/calendar/acls/insert_rule", service, test_acls_insert_rule);
 		g_test_add_data_func ("/calendar/acls/update_rule", service, test_acls_update_rule);
 		g_test_add_data_func ("/calendar/acls/delete_rule", service, test_acls_delete_rule);
 	}
 
+	g_test_add_func ("/calendar/xml/dates", test_xml_dates);
+	g_test_add_func ("/calendar/xml/recurrence", test_xml_recurrence);
+
+	g_test_add_func ("/calendar/query/uri", test_query_uri);
+	g_test_add_func ("/calendar/query/etag", test_query_etag);
+
 	retval = g_test_run ();
-	g_object_unref (service);
+
+	if (service != NULL)
+		g_object_unref (service);
 
 	return retval;
 }
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index 2d79bf8..f819f53 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -689,7 +689,7 @@ test_query_properties (void)
 }
 
 static void
-test_parser_minimal (gconstpointer service)
+test_parser_minimal (void)
 {
 	GDataContactsContact *contact;
 	GDate birthday;
@@ -751,7 +751,7 @@ test_parser_minimal (gconstpointer service)
 }
 
 static void
-test_parser_normal (gconstpointer service)
+test_parser_normal (void)
 {
 	GDataContactsContact *contact;
 	GDate date;
@@ -972,7 +972,7 @@ test_parser_normal (gconstpointer service)
 }
 
 static void
-test_parser_error_handling (gconstpointer service)
+test_parser_error_handling (void)
 {
 	GDataContactsContact *contact;
 	GError *error = NULL;
@@ -1482,37 +1482,47 @@ test_id (void)
 int
 main (int argc, char *argv[])
 {
-	GDataService *service;
 	gint retval;
+	GDataService *service = NULL;
 
 	gdata_test_init (argc, argv);
 
-	service = GDATA_SERVICE (gdata_contacts_service_new (CLIENT_ID));
-	gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
+	if (gdata_test_internet () == TRUE) {
+		service = GDATA_SERVICE (gdata_contacts_service_new (CLIENT_ID));
+		gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
+
+		g_test_add_func ("/contacts/authentication", test_authentication);
 
-	g_test_add_func ("/contacts/authentication", test_authentication);
-	g_test_add_data_func ("/contacts/insert/simple", service, test_insert_simple);
-	g_test_add_data_func ("/contacts/query/all_contacts", service, test_query_all_contacts);
-	if (g_test_thorough () == TRUE)
+		g_test_add_data_func ("/contacts/insert/simple", service, test_insert_simple);
+
+		g_test_add_data_func ("/contacts/query/all_contacts", service, test_query_all_contacts);
 		g_test_add_data_func ("/contacts/query/all_contacts_async", service, test_query_all_contacts_async);
+
+		g_test_add_data_func ("/contacts/photo/has_photo", service, test_photo_has_photo);
+		g_test_add_data_func ("/contacts/photo/add", service, test_photo_add);
+		g_test_add_data_func ("/contacts/photo/get", service, test_photo_get);
+		g_test_add_data_func ("/contacts/photo/delete", service, test_photo_delete);
+
+		g_test_add_data_func ("/contacts/batch", service, test_batch);
+		g_test_add ("/contacts/batch/async", BatchAsyncData, service, setup_batch_async, test_batch_async, teardown_batch_async);
+		g_test_add ("/contacts/batch/async/cancellation", BatchAsyncData, service, setup_batch_async, test_batch_async_cancellation,
+		            teardown_batch_async);
+	}
+
 	g_test_add_func ("/contacts/query/uri", test_query_uri);
 	g_test_add_func ("/contacts/query/etag", test_query_etag);
 	g_test_add_func ("/contacts/query/properties", test_query_properties);
-	g_test_add_data_func ("/contacts/parser/minimal", service, test_parser_minimal);
-	g_test_add_data_func ("/contacts/parser/normal", service, test_parser_normal);
-	g_test_add_data_func ("/contacts/parser/error_handling", service, test_parser_error_handling);
-	g_test_add_data_func ("/contacts/photo/has_photo", service, test_photo_has_photo);
-	g_test_add_data_func ("/contacts/photo/add", service, test_photo_add);
-	g_test_add_data_func ("/contacts/photo/get", service, test_photo_get);
-	g_test_add_data_func ("/contacts/photo/delete", service, test_photo_delete);
-	g_test_add_data_func ("/contacts/batch", service, test_batch);
-	g_test_add ("/contacts/batch/async", BatchAsyncData, service, setup_batch_async, test_batch_async, teardown_batch_async);
-	g_test_add ("/contacts/batch/async/cancellation", BatchAsyncData, service, setup_batch_async, test_batch_async_cancellation,
-	            teardown_batch_async);
+
+	g_test_add_func ("/contacts/parser/minimal", test_parser_minimal);
+	g_test_add_func ("/contacts/parser/normal", test_parser_normal);
+	g_test_add_func ("/contacts/parser/error_handling", test_parser_error_handling);
+
 	g_test_add_func ("/contacts/id", test_id);
 
 	retval = g_test_run ();
-	g_object_unref (service);
+
+	if (service != NULL)
+		g_object_unref (service);
 
 	return retval;
 }
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 454ab85..1a78605 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -583,43 +583,47 @@ test_query_etag (void)
 int
 main (int argc, char *argv[])
 {
-	GDataService *service;
 	gint retval;
+	GDataService *service = NULL;
 
 	gdata_test_init (argc, argv);
 
-	service = GDATA_SERVICE (gdata_documents_service_new (CLIENT_ID));
-	gdata_service_authenticate (service, DOCUMENTS_USERNAME, PASSWORD, NULL, NULL);
+	if (gdata_test_internet () == TRUE) {
+		service = GDATA_SERVICE (gdata_documents_service_new (CLIENT_ID));
+		gdata_service_authenticate (service, DOCUMENTS_USERNAME, PASSWORD, NULL, NULL);
 
-	g_test_add_func ("/documents/authentication", test_authentication);
+		g_test_add_func ("/documents/authentication", test_authentication);
 
-	g_test_add_data_func ("/documents/remove/all", service, test_remove_all_documents_and_folders);
+		g_test_add_data_func ("/documents/remove/all", service, test_remove_all_documents_and_folders);
 
-	g_test_add_data_func ("/documents/upload/only_file_get_entry", service, test_upload_file_get_entry);
-	g_test_add_data_func ("/documents/upload/metadata_file", service, test_upload_metadata_file);
-	g_test_add_data_func ("/documents/upload/only_metadata", service, test_upload_metadata);
-	g_test_add_data_func ("/documents/upload/metadata_file_in_new_folder", service, test_upload_file_metadata_in_new_folder);
-	g_test_add_data_func ("/documents/download/download_all_documents", service, test_download_all_documents);
-	g_test_add_data_func ("/documents/update/only_metadata", service, test_update_metadata);
-	g_test_add_data_func ("/documents/update/only_file", service, test_update_file);
-	g_test_add_data_func ("/documents/update/metadata_file", service, test_update_metadata_file);
+		g_test_add_data_func ("/documents/upload/only_file_get_entry", service, test_upload_file_get_entry);
+		g_test_add_data_func ("/documents/upload/metadata_file", service, test_upload_metadata_file);
+		g_test_add_data_func ("/documents/upload/only_metadata", service, test_upload_metadata);
+		g_test_add_data_func ("/documents/upload/metadata_file_in_new_folder", service, test_upload_file_metadata_in_new_folder);
 
-	g_test_add_data_func ("/documents/access_rules/add_document_with_a_collaborator", service, test_new_document_with_collaborator);
+		g_test_add_data_func ("/documents/download/download_all_documents", service, test_download_all_documents);
 
-	g_test_add_data_func ("/documents/query/all_documents_with_folder", service, test_query_all_documents_with_folder);
-	g_test_add_data_func ("/documents/query/all_documents", service, test_query_all_documents);
-	if (g_test_thorough () == TRUE)
+		g_test_add_data_func ("/documents/update/only_metadata", service, test_update_metadata);
+		g_test_add_data_func ("/documents/update/only_file", service, test_update_file);
+		g_test_add_data_func ("/documents/update/metadata_file", service, test_update_metadata_file);
+
+		g_test_add_data_func ("/documents/access_rules/add_document_with_a_collaborator", service, test_new_document_with_collaborator);
+
+		g_test_add_data_func ("/documents/query/all_documents_with_folder", service, test_query_all_documents_with_folder);
+		g_test_add_data_func ("/documents/query/all_documents", service, test_query_all_documents);
 		g_test_add_data_func ("/documents/query/all_documents_async", service, test_query_all_documents_async);
 
-	g_test_add_data_func ("/documents/move/move_to_folder", service, test_add_file_folder_and_move);
-	g_test_add_data_func ("/documents/move/remove_from_folder", service, test_add_remove_file_from_folder);
-	/*g_test_add_data_func ("/documents/remove/all", service, test_remove_all_documents_and_folders);*/
+		g_test_add_data_func ("/documents/move/move_to_folder", service, test_add_file_folder_and_move);
+		g_test_add_data_func ("/documents/move/remove_from_folder", service, test_add_remove_file_from_folder);
+		/*g_test_add_data_func ("/documents/remove/all", service, test_remove_all_documents_and_folders);*/
+	}
 
 	g_test_add_func ("/documents/query/etag", test_query_etag);
 
 	retval = g_test_run ();
 
-	g_object_unref (service);
+	if (service != NULL)
+		g_object_unref (service);
 
 	return retval;
 }
diff --git a/gdata/tests/picasaweb.c b/gdata/tests/picasaweb.c
index 58b0dea..ad6895b 100644
--- a/gdata/tests/picasaweb.c
+++ b/gdata/tests/picasaweb.c
@@ -1274,7 +1274,7 @@ test_query_all_albums_async (gconstpointer service)
 }
 
 static void
-test_album_new (gconstpointer service)
+test_album_new (void)
 {
 	GDataPicasaWebAlbum *album;
 	gchar *xml, *parsed_time_str;
@@ -1358,41 +1358,49 @@ test_query_etag (void)
 int
 main (int argc, char *argv[])
 {
-	GDataService *service;
 	gint retval;
+	GDataService *service = NULL;
 
 	gdata_test_init (argc, argv);
 
-	service = GDATA_SERVICE (gdata_picasaweb_service_new (CLIENT_ID));
-	gdata_service_authenticate (service, PW_USERNAME, PASSWORD, NULL, NULL);
+	if (gdata_test_internet () == TRUE) {
+		service = GDATA_SERVICE (gdata_picasaweb_service_new (CLIENT_ID));
+		gdata_service_authenticate (service, PW_USERNAME, PASSWORD, NULL, NULL);
 
-	g_test_add_func ("/picasaweb/authentication", test_authentication);
-	if (g_test_thorough () == TRUE)
+		g_test_add_func ("/picasaweb/authentication", test_authentication);
 		g_test_add_func ("/picasaweb/authentication_async", test_authentication_async);
-	g_test_add_data_func ("/picasaweb/upload/photo", service, test_upload_simple);
-	if (g_test_thorough () == TRUE)
+
+		g_test_add_data_func ("/picasaweb/upload/photo", service, test_upload_simple);
 		g_test_add_data_func ("/picasaweb/upload/photo_async", service, test_upload_async);
-	g_test_add_data_func ("/picasaweb/query/all_albums", service, test_query_all_albums);
-	g_test_add_data_func ("/picasaweb/query/user", service, test_query_user);
-	if (g_test_thorough () == TRUE)
+
+		g_test_add_data_func ("/picasaweb/query/all_albums", service, test_query_all_albums);
+		g_test_add_data_func ("/picasaweb/query/user", service, test_query_user);
 		g_test_add_data_func ("/picasaweb/query/all_albums_async", service, test_query_all_albums_async);
-	g_test_add_data_func ("/picasaweb/query/new_with_limits", service, test_query_new_with_limits);
-	g_test_add_data_func ("/picasaweb/query/album_feed", service, test_album_feed);
-	g_test_add_data_func ("/picasaweb/query/album_feed_entry", service, test_album_feed_entry);
-	g_test_add_data_func ("/picasaweb/query/album", service, test_album);
-	g_test_add_data_func ("/picasaweb/insert/album", service, test_insert_album);
-	g_test_add_data_func ("/picasaweb/query/photo_feed", service, test_photo_feed);
-	g_test_add_data_func ("/picasaweb/query/photo_feed_entry", service, test_photo_feed_entry);
-	g_test_add_data_func ("/picasaweb/query/photo", service, test_photo);
-	g_test_add_data_func ("/picasaweb/query/photo_single", service, test_photo_single);
-	g_test_add_data_func ("/picasaweb/upload/photo", service, test_upload_simple);
-	g_test_add_data_func ("/picasaweb/download/photo", service, test_download);
-	g_test_add_data_func ("/picasaweb/download/thumbnails", service, test_download_thumbnails);
-	g_test_add_data_func ("/picasaweb/album/new", service, test_album_new);
+		g_test_add_data_func ("/picasaweb/query/new_with_limits", service, test_query_new_with_limits);
+		g_test_add_data_func ("/picasaweb/query/album_feed", service, test_album_feed);
+		g_test_add_data_func ("/picasaweb/query/album_feed_entry", service, test_album_feed_entry);
+		g_test_add_data_func ("/picasaweb/query/album", service, test_album);
+
+		g_test_add_data_func ("/picasaweb/insert/album", service, test_insert_album);
+
+		g_test_add_data_func ("/picasaweb/query/photo_feed", service, test_photo_feed);
+		g_test_add_data_func ("/picasaweb/query/photo_feed_entry", service, test_photo_feed_entry);
+		g_test_add_data_func ("/picasaweb/query/photo", service, test_photo);
+		g_test_add_data_func ("/picasaweb/query/photo_single", service, test_photo_single);
+
+		g_test_add_data_func ("/picasaweb/upload/photo", service, test_upload_simple);
+
+		g_test_add_data_func ("/picasaweb/download/photo", service, test_download);
+		g_test_add_data_func ("/picasaweb/download/thumbnails", service, test_download_thumbnails);
+	}
+
+	g_test_add_func ("/picasaweb/album/new", test_album_new);
 	g_test_add_func ("/picasaweb/query/etag", test_query_etag);
 
 	retval = g_test_run ();
-	g_object_unref (service);
+
+	if (service != NULL)
+		g_object_unref (service);
 
 	return retval;
 }
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index 32b8cf6..e60dd83 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -319,7 +319,7 @@ test_upload_simple (gconstpointer service)
 }
 
 static void
-test_parsing_app_control (gconstpointer service)
+test_parsing_app_control (void)
 {
 	GDataYouTubeVideo *video;
 	GDataYouTubeState *state;
@@ -371,7 +371,7 @@ test_parsing_app_control (gconstpointer service)
 }
 
 static void
-test_parsing_yt_recorded (gconstpointer service)
+test_parsing_yt_recorded (void)
 {
 	GDataYouTubeVideo *video;
 	GTimeVal recorded;
@@ -453,7 +453,7 @@ test_parsing_yt_recorded (gconstpointer service)
 }
 
 static void
-test_parsing_yt_access_control (gconstpointer service)
+test_parsing_yt_access_control (void)
 {
 	GDataYouTubeVideo *video;
 	gchar *xml;
@@ -546,7 +546,7 @@ test_parsing_yt_access_control (gconstpointer service)
 }
 
 static void
-test_parsing_yt_category (gconstpointer service)
+test_parsing_yt_category (void)
 {
 	GDataYouTubeCategory *category;
 	gboolean assignable, deprecated;
@@ -1080,43 +1080,49 @@ int
 main (int argc, char *argv[])
 {
 	gint retval;
-	GDataService *service;
+	GDataService *service = NULL;
 
 	gdata_test_init (argc, argv);
 
-	service = GDATA_SERVICE (gdata_youtube_service_new (DEVELOPER_KEY, CLIENT_ID));
-	gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
+	if (gdata_test_internet () == TRUE) {
+		service = GDATA_SERVICE (gdata_youtube_service_new (DEVELOPER_KEY, CLIENT_ID));
+		gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
 
-	g_test_add_func ("/youtube/authentication", test_authentication);
-	if (g_test_thorough () == TRUE)
+		g_test_add_func ("/youtube/authentication", test_authentication);
 		g_test_add_func ("/youtube/authentication_async", test_authentication_async);
-	g_test_add_data_func ("/youtube/query/standard_feed", service, test_query_standard_feed);
-	if (g_test_thorough () == TRUE)
+
+		g_test_add_data_func ("/youtube/query/standard_feed", service, test_query_standard_feed);
 		g_test_add_data_func ("/youtube/query/standard_feed_async", service, test_query_standard_feed_async);
-	g_test_add_data_func ("/youtube/query/related", service, test_query_related);
-	if (g_test_thorough () == TRUE)
+		g_test_add_data_func ("/youtube/query/related", service, test_query_related);
 		g_test_add_data_func ("/youtube/query/related_async", service, test_query_related_async);
-	if (g_test_slow () == TRUE)
+
 		g_test_add_data_func ("/youtube/upload/simple", service, test_upload_simple);
-	g_test_add_data_func ("/youtube/parsing/app:control", service, test_parsing_app_control);
+
+		g_test_add_data_func ("/youtube/query/single", service, test_query_single);
+		g_test_add_data_func ("/youtube/query/single_async", service, test_query_single_async);
+
+		g_test_add_data_func ("/youtube/categories", service, test_categories);
+		g_test_add_data_func ("/youtube/categories/async", service, test_categories_async);
+
+		g_test_add ("/youtube/batch", BatchData, service, setup_batch, test_batch, teardown_batch);
+		g_test_add ("/youtube/batch/async", BatchData, service, setup_batch, test_batch_async, teardown_batch);
+		g_test_add ("/youtube/batch/async/cancellation", BatchData, service, setup_batch, test_batch_async_cancellation, teardown_batch);
+	}
+
+	g_test_add_func ("/youtube/parsing/app:control", test_parsing_app_control);
 	/*g_test_add_func ("/youtube/parsing/comments/feedLink", test_parsing_comments_feed_link);*/
-	g_test_add_data_func ("/youtube/parsing/yt:recorded", service, test_parsing_yt_recorded);
-	g_test_add_data_func ("/youtube/parsing/yt:accessControl", service, test_parsing_yt_access_control);
-	g_test_add_data_func ("/youtube/parsing/yt:category", service, test_parsing_yt_category);
+	g_test_add_func ("/youtube/parsing/yt:recorded", test_parsing_yt_recorded);
+	g_test_add_func ("/youtube/parsing/yt:accessControl", test_parsing_yt_access_control);
+	g_test_add_func ("/youtube/parsing/yt:category", test_parsing_yt_category);
+	g_test_add_func ("/youtube/parsing/video_id_from_uri", test_parsing_video_id_from_uri);
+
 	g_test_add_func ("/youtube/query/uri", test_query_uri);
 	g_test_add_func ("/youtube/query/etag", test_query_etag);
-	g_test_add_data_func ("/youtube/query/single", service, test_query_single);
-	if (g_test_slow () == TRUE)
-		g_test_add_data_func ("/youtube/query/single_async", service, test_query_single_async);
-	g_test_add_func ("/youtube/parsing/video_id_from_uri", test_parsing_video_id_from_uri);
-	g_test_add_data_func ("/youtube/categories", service, test_categories);
-	g_test_add_data_func ("/youtube/categories/async", service, test_categories_async);
-	g_test_add ("/youtube/batch", BatchData, service, setup_batch, test_batch, teardown_batch);
-	g_test_add ("/youtube/batch/async", BatchData, service, setup_batch, test_batch_async, teardown_batch);
-	g_test_add ("/youtube/batch/async/cancellation", BatchData, service, setup_batch, test_batch_async_cancellation, teardown_batch);
 
 	retval = g_test_run ();
-	g_object_unref (service);
+
+	if (service != NULL)
+		g_object_unref (service);
 
 	return retval;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]