From 0c4e48e54752314ac2cfbfec3296fd0df419bc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 14 Oct 2022 13:57:25 +0400 Subject: [PATCH] tests/file-thumbnail: make it work with win32 paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Win32, we get paths with mixed \\ and /, use GFile to resolve and normalize the paths before comparing. Signed-off-by: Marc-André Lureau --- gio/tests/file-thumbnail.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gio/tests/file-thumbnail.c b/gio/tests/file-thumbnail.c index 6e8768a73..5fd265f36 100644 --- a/gio/tests/file-thumbnail.c +++ b/gio/tests/file-thumbnail.c @@ -207,26 +207,25 @@ test_valid_thumbnail_size (gconstpointer data) { GFile *source; GFile *thumbnail; + GFile *f; GError *error = NULL; GFileInfo *info; const gchar *size = data; - char *thumbnail_path; thumbnail = create_thumbnail_from_test_file ("valid.png", size, &source); info = g_file_query_info (source, THUMBNAILS_ATTRIBS, G_FILE_QUERY_INFO_NONE, NULL, &error); g_assert_no_error (error); - thumbnail_path = g_file_get_path (thumbnail); - g_assert_true (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); g_assert_true (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID)); g_assert_false (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)); + f = g_file_new_for_path (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); g_assert_cmpstr ( - g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH), + g_file_peek_path (f), ==, - thumbnail_path + g_file_peek_path (thumbnail) ); /* TODO: We can't really test this without having a proper thumbnail created @@ -238,7 +237,7 @@ test_valid_thumbnail_size (gconstpointer data) g_clear_object (&thumbnail); g_clear_error (&error); g_clear_object (&info); - g_free (thumbnail_path); + g_clear_object (&f); } static void @@ -310,7 +309,7 @@ test_thumbnails_size_priority (void) for (i = 0; i < G_N_ELEMENTS (SIZES_NAMES); i++) { GFile *thumbnail = create_thumbnail (source, SIZES_NAMES[i]); - gchar *thumbnail_path = g_file_get_path (thumbnail); + GFile *f; g_ptr_array_add (sized_thumbnails, thumbnail); @@ -322,14 +321,15 @@ test_thumbnails_size_priority (void) g_assert_true (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID)); g_assert_false (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)); + f = g_file_new_for_path (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); g_assert_cmpstr ( - g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH), + g_file_peek_path (f), ==, - thumbnail_path + g_file_peek_path (thumbnail) ); - g_free (thumbnail_path); g_clear_object (&info); + g_clear_object (&f); } g_assert_cmpuint (sized_thumbnails->len, ==, G_N_ELEMENTS (SIZES_NAMES)); @@ -339,7 +339,7 @@ test_thumbnails_size_priority (void) { GFile *thumbnail = g_ptr_array_index (sized_thumbnails, i - 1); GFile *less_priority_thumbnail = g_ptr_array_index (sized_thumbnails, i - 2); - gchar *thumbnail_path = g_file_get_path (less_priority_thumbnail); + GFile *f; g_file_delete (thumbnail, NULL, &error); g_assert_no_error (error); @@ -352,14 +352,15 @@ test_thumbnails_size_priority (void) g_assert_true (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID)); g_assert_false (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED)); + f = g_file_new_for_path (g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH)); g_assert_cmpstr ( - g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH), + g_file_peek_path (f), ==, - thumbnail_path + g_file_peek_path (less_priority_thumbnail) ); - g_free (thumbnail_path); g_clear_object (&info); + g_clear_object (&f); } /* And now let's remove the last valid one, so that failed should have priority */