[libgdata] tests: Fix the set up for /documents/folders/remove_from_folder



commit a627e0e4c586696ead2556eaea36797de2cc25b6
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Sep 27 20:23:13 2016 +0200

    tests: Fix the set up for /documents/folders/remove_from_folder
    
    In Drive v2, we can only remove an entry from a folder if it had
    multiple parents to start with. If there was only a single parent, then
    the request is just ignored.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684920

 gdata/tests/documents.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/gdata/tests/documents.c b/gdata/tests/documents.c
index 902d32b..d43413c 100644
--- a/gdata/tests/documents.c
+++ b/gdata/tests/documents.c
@@ -33,6 +33,22 @@
 
 static UhmServer *mock_server = NULL;
 
+static void
+add_folder_link_to_entry (GDataDocumentsEntry *entry, GDataDocumentsFolder *folder)
+{
+       GDataLink *_link;
+       const gchar *id;
+       gchar *uri;
+
+       /* HACK: Build the GDataLink:uri from the ID by adding the prefix. */
+       id = gdata_entry_get_id (GDATA_ENTRY (folder));
+       uri = g_strconcat ("https://www.googleapis.com/drive/v2/files/";, id, NULL);
+       _link = gdata_link_new (uri, GDATA_LINK_PARENT);
+       gdata_entry_add_link (GDATA_ENTRY (entry), _link);
+       g_object_unref (_link);
+       g_free (uri);
+}
+
 static gboolean
 check_document_is_in_folder (GDataDocumentsDocument *document, GDataDocumentsFolder *folder)
 {
@@ -1173,8 +1189,6 @@ set_up_folders (FoldersData *data, GDataDocumentsService *service, gboolean init
                                                                                            root,
                                                                                            NULL,
                                                                                            &error));
-       g_object_unref (root);
-
        g_assert_no_error (error);
        g_assert (GDATA_IS_DOCUMENTS_FOLDER (data->folder));
 
@@ -1187,6 +1201,10 @@ set_up_folders (FoldersData *data, GDataDocumentsService *service, gboolean init
 
        document = GDATA_DOCUMENTS_DOCUMENT (gdata_documents_text_new (NULL));
        gdata_entry_set_title (GDATA_ENTRY (document), "add_file_folder_move_text");
+       if (initially_in_folder)
+               add_folder_link_to_entry (GDATA_DOCUMENTS_ENTRY (document), root);
+
+       g_object_unref (root);
 
        file_info = g_file_query_info (document_file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," 
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
                                       G_FILE_QUERY_INFO_NONE, NULL, &error);


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