Commit 01816f95 authored by Milan Crha's avatar Milan Crha

I#32 - test-cal-meta-backend cannot run without installed Evolution

Closes GNOME/evolution-data-server#32
parent 8da228dd
......@@ -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
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment