[evolution-data-server] I#32 - test-cal-meta-backend cannot run without installed Evolution



commit fc713e85c41613cb88153b1ccfc36a5c66b9a71a
Author: Milan Crha <mcrha redhat com>
Date:   Thu Sep 20 21:30:07 2018 +0200

    I#32 - test-cal-meta-backend cannot run without installed Evolution
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/32

 tests/libedata-cal/components/event-7.ics  |  2 +-
 tests/libedata-cal/test-cal-cache-utils.c  | 39 ++++++++++++++++++++++++++----
 tests/libedata-cal/test-cal-cache-utils.h  |  1 +
 tests/libedata-cal/test-cal-meta-backend.c |  9 ++++++-
 4 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/tests/libedata-cal/components/event-7.ics b/tests/libedata-cal/components/event-7.ics
index b08d39222..68c1a1303 100644
--- a/tests/libedata-cal/components/event-7.ics
+++ b/tests/libedata-cal/components/event-7.ics
@@ -6,7 +6,7 @@ DTEND;TZID=/freeassociation.sourceforge.net/America/New_York:20170221T145000
 SEQUENCE:1
 SUMMARY:With attachment
 TRANSP:OPAQUE
-ATTACH:file:///usr/share/icons/hicolor/48x48/apps/evolution.png
+ATTACH:$EVENT1URI$
 CLASS:PUBLIC
 CREATED:20170221T125054Z
 LAST-MODIFIED:20170221T125054Z
diff --git a/tests/libedata-cal/test-cal-cache-utils.c b/tests/libedata-cal/test-cal-cache-utils.c
index 8ccc20fae..037c1fb16 100644
--- a/tests/libedata-cal/test-cal-cache-utils.c
+++ b/tests/libedata-cal/test-cal-cache-utils.c
@@ -119,13 +119,10 @@ tcu_fixture_teardown (TCUFixture *fixture,
 }
 
 gchar *
-tcu_new_icalstring_from_test_case (const gchar *case_name)
+tcu_get_test_case_filename (const gchar *case_name)
 {
        gchar *filename;
        gchar *case_filename;
-       GFile * file;
-       GError *error = NULL;
-       gchar *icalstring = NULL;
 
        case_filename = g_strdup_printf ("%s.ics", case_name);
 
@@ -137,16 +134,48 @@ tcu_new_icalstring_from_test_case (const gchar *case_name)
        else
                filename = g_build_filename (SRCDIR, "..", "libedata-cal", "components", case_filename, NULL);
 
+       g_free (case_filename);
+
+       return filename;
+}
+
+gchar *
+tcu_new_icalstring_from_test_case (const gchar *case_name)
+{
+       gchar *filename;
+       GFile * file;
+       GError *error = NULL;
+       gchar *icalstring = NULL, *uripart;
+
+       filename = tcu_get_test_case_filename (case_name);
+
        file = g_file_new_for_path (filename);
        if (!g_file_load_contents (file, NULL, &icalstring, NULL, NULL, &error))
                g_error (
                        "Failed to read test iCal string file '%s': %s",
                        filename, error->message);
 
-       g_free (case_filename);
        g_free (filename);
        g_object_unref (file);
 
+       uripart = strstr (icalstring, "$EVENT1URI$");
+       if (uripart) {
+               gchar *uri;
+               GString *str;
+
+               filename = tcu_get_test_case_filename ("event-1");
+               uri = g_filename_to_uri (filename, NULL, NULL);
+               g_free (filename);
+
+               str = g_string_new_len (icalstring, uripart - icalstring);
+               g_string_append (str, uri);
+               g_string_append (str, uripart + 11);
+               g_free (icalstring);
+               g_free (uri);
+
+               icalstring = g_string_free (str, FALSE);
+       }
+
        return icalstring;
 }
 
diff --git a/tests/libedata-cal/test-cal-cache-utils.h b/tests/libedata-cal/test-cal-cache-utils.h
index d3616fc1e..0107b9dfd 100644
--- a/tests/libedata-cal/test-cal-cache-utils.h
+++ b/tests/libedata-cal/test-cal-cache-utils.h
@@ -46,6 +46,7 @@ ECalComponent *       tcu_new_component_from_test_case        (const gchar *case_name);
 void           tcu_add_component_from_test_case        (TCUFixture *fixture,
                                                         const gchar *case_name,
                                                         ECalComponent **out_component);
+gchar *                tcu_get_test_case_filename              (const gchar *case_name);
 
 G_END_DECLS
 
diff --git a/tests/libedata-cal/test-cal-meta-backend.c b/tests/libedata-cal/test-cal-meta-backend.c
index dc953f656..f13215443 100644
--- a/tests/libedata-cal/test-cal-meta-backend.c
+++ b/tests/libedata-cal/test-cal-meta-backend.c
@@ -1287,6 +1287,7 @@ static void
 test_get_attachment_uris (ECalMetaBackend *meta_backend)
 {
        ECalBackendSyncClass *backend_class;
+       gchar *expected_uri, *filename;
        GSList *uris = NULL;
        GError *error = NULL;
 
@@ -1319,7 +1320,13 @@ test_get_attachment_uris (ECalMetaBackend *meta_backend)
        g_assert_no_error (error);
        g_assert_nonnull (uris);
        g_assert_cmpint (g_slist_length (uris), ==, 1);
-       g_assert_cmpstr (uris->data, ==, "file:///usr/share/icons/hicolor/48x48/apps/evolution.png");
+
+       filename = tcu_get_test_case_filename ("event-1");
+       expected_uri = g_filename_to_uri (filename, NULL, NULL);
+       g_free (filename);
+
+       g_assert_cmpstr (uris->data, ==, expected_uri);
+       g_free (expected_uri);
 
        g_slist_free_full (uris, g_free);
 }


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