[libgdata/wip/rishi/drive: 3/11] Port the tests



commit db4c5cada06af3d375c81eb3d2fca868f413a424
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Sep 4 15:13:24 2015 +0200

    Port the tests
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684920

 gdata/tests/Makefile.am |    5 +---
 gdata/tests/documents.c |   53 ++++++++++++++++++++++++++++------------------
 2 files changed, 33 insertions(+), 25 deletions(-)
---
diff --git a/gdata/tests/Makefile.am b/gdata/tests/Makefile.am
index d5a1de5..b72e821 100644
--- a/gdata/tests/Makefile.am
+++ b/gdata/tests/Makefile.am
@@ -51,6 +51,7 @@ test_programs = \
        general \
        calendar \
        contacts \
+       documents \
        tasks \
        perf \
        authorization \
@@ -60,10 +61,6 @@ test_programs = \
        youtube \
        $(NULL)
 
-# FIXME: Temporarily disabled until they are ported for the changes in the v2
-# to v3 API transitions.
-#all_test_programs += documents
-
 # PicasaWeb does not work since Google made the API read-only:
 # https://developers.google.com/picasa-web/docs/3.0/releasenotes#picasa-is-retiring-february-12-2016
 #all_test_programs += picasaweb
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 4c207e3..e564d1a 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -191,22 +191,31 @@ static void
 set_up_temp_folder (TempFolderData *data, gconstpointer service)
 {
        GDataDocumentsFolder *folder;
-       gchar *upload_uri;
+       GDataDocumentsFolder *root;
 
        gdata_test_mock_server_start_trace (mock_server, "setup-temp-folder");
 
+       root = GDATA_DOCUMENTS_FOLDER (gdata_service_query_single_entry (GDATA_SERVICE (service),
+                                                                        
gdata_documents_service_get_primary_authorization_domain (),
+                                                                        "root",
+                                                                        NULL,
+                                                                        GDATA_TYPE_DOCUMENTS_FOLDER,
+                                                                        NULL,
+                                                                        NULL));
+
        /* Create a folder */
        folder = gdata_documents_folder_new (NULL);
        gdata_entry_set_title (GDATA_ENTRY (folder), "Temporary Folder");
 
        /* Insert the folder */
-       upload_uri = gdata_documents_service_get_upload_uri (NULL);
-       data->folder = GDATA_DOCUMENTS_FOLDER (gdata_service_insert_entry (GDATA_SERVICE (service),
-                                                                          
gdata_documents_service_get_primary_authorization_domain (),
-                                                                          upload_uri, GDATA_ENTRY (folder), 
NULL, NULL));
+       data->folder = GDATA_DOCUMENTS_FOLDER (gdata_documents_service_add_entry_to_folder 
(GDATA_DOCUMENTS_SERVICE (service),
+                                                                                           
GDATA_DOCUMENTS_ENTRY (folder),
+                                                                                           root,
+                                                                                           NULL,
+                                                                                           NULL));
        g_assert (GDATA_IS_DOCUMENTS_FOLDER (data->folder));
-       g_free (upload_uri);
        g_object_unref (folder);
+       g_object_unref (root);
 
        uhm_server_end_trace (mock_server);
 }
@@ -266,25 +275,26 @@ _set_up_temp_document (GDataDocumentsEntry *entry, GDataService *service, GFile
        /* Finish the upload */
        document = gdata_documents_service_finish_upload (GDATA_DOCUMENTS_SERVICE (service), upload_stream, 
&error);
        g_assert_no_error (error);
+       g_assert (GDATA_IS_DOCUMENTS_DOCUMENT (document));
 
        g_object_unref (upload_stream);
 
        /* HACK: Query for the new document, as Google's servers appear to modify it behind our back when 
creating the document:
         * http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=2337. We have to wait a few 
seconds before trying this to allow the
         * various Google servers to catch up with each other. Thankfully, we don't have to wait when running 
against the mock server. */
-       if (uhm_server_get_enable_online (mock_server) == TRUE) {
-               g_usleep (5 * G_USEC_PER_SEC);
-       }
+       /* if (uhm_server_get_enable_online (mock_server) == TRUE) { */
+       /*      g_usleep (5 * G_USEC_PER_SEC); */
+       /* } */
 
-       new_document = GDATA_DOCUMENTS_DOCUMENT (gdata_service_query_single_entry (service,
-                                                                                  
gdata_documents_service_get_primary_authorization_domain (),
-                                                                                  gdata_entry_get_id 
(GDATA_ENTRY (document)), NULL,
-                                                                                  G_OBJECT_TYPE (document), 
NULL, NULL));
-       g_assert (GDATA_IS_DOCUMENTS_DOCUMENT (new_document));
+       /* new_document = GDATA_DOCUMENTS_DOCUMENT (gdata_service_query_single_entry (service, */
+       /*                                                                            
gdata_documents_service_get_primary_authorization_domain (), */
+       /*                                                                            gdata_entry_get_id 
(GDATA_ENTRY (document)), NULL, */
+       /*                                                                            G_OBJECT_TYPE 
(document), NULL, NULL)); */
+       /* g_assert (GDATA_IS_DOCUMENTS_DOCUMENT (new_document)); */
 
-       g_object_unref (document);
+       /* g_object_unref (document); */
 
-       return new_document;
+       return document;
 }
 
 static void
@@ -1164,7 +1174,7 @@ test_copy_document (TempCopyDocumentData *data, gconstpointer service)
        /* Copy the document */
        data->new_document = gdata_documents_service_copy_document (GDATA_DOCUMENTS_SERVICE (service), 
data->parent.document, NULL, &error);
        g_assert_no_error (error);
-       g_assert (GDATA_IS_DOCUMENTS_SPREADSHEET (data->new_document));
+       g_assert (GDATA_IS_DOCUMENTS_DOCUMENT (data->new_document));
 
        /* Check their IDs are different but that their other properties (e.g. title) are the same. */
        g_assert_cmpstr (gdata_entry_get_id (GDATA_ENTRY (data->parent.document)), !=, gdata_entry_get_id 
(GDATA_ENTRY (data->new_document)));
@@ -2042,6 +2052,7 @@ mock_server_notify_resolver_cb (GObject *object, GParamSpec *pspec, gpointer use
                uhm_resolver_add_A (resolver, "lh3.googleusercontent.com", ip_address);
                uhm_resolver_add_A (resolver, "lh5.googleusercontent.com", ip_address);
                uhm_resolver_add_A (resolver, "lh6.googleusercontent.com", ip_address);
+               uhm_resolver_add_A (resolver, "www.googleapis.com", ip_address);
        }
 }
 
@@ -2245,10 +2256,10 @@ main (int argc, char *argv[])
                    set_up_folders_remove_from_folder_async, 
test_folders_remove_from_folder_async_cancellation,
                    tear_down_folders_remove_from_folder_async);
 
-       g_test_add_data_func ("/documents/batch", service, test_batch);
-       g_test_add ("/documents/batch/async", BatchAsyncData, service, set_up_batch_async, test_batch_async, 
tear_down_batch_async);
-       g_test_add ("/documents/batch/async/cancellation", BatchAsyncData, service, set_up_batch_async, 
test_batch_async_cancellation,
-                   tear_down_batch_async);
+       /* g_test_add_data_func ("/documents/batch", service, test_batch); */
+       /* g_test_add ("/documents/batch/async", BatchAsyncData, service, set_up_batch_async, 
test_batch_async, tear_down_batch_async); */
+       /* g_test_add ("/documents/batch/async/cancellation", BatchAsyncData, service, set_up_batch_async, 
test_batch_async_cancellation, */
+       /*             tear_down_batch_async); */
 
        g_test_add_func ("/documents/folder/parser/normal", test_folder_parser_normal);
        g_test_add_func ("/documents/query/etag", test_query_etag);


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