[evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Adapt emoticon tests
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/webkit-jsc-api] test-html-editor-units: Adapt emoticon tests
- Date: Tue, 18 Feb 2020 15:18:07 +0000 (UTC)
commit 9ecf17889cd5d3c4e47d24b0452b6d143ba3d108
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 18 16:19:46 2020 +0100
test-html-editor-units: Adapt emoticon tests
src/e-util/test-html-editor-units-utils.c | 20 ++++++--------------
src/e-util/test-html-editor-units-utils.h | 3 +--
src/e-util/test-html-editor-units.c | 22 ++++++++++------------
3 files changed, 17 insertions(+), 28 deletions(-)
---
diff --git a/src/e-util/test-html-editor-units-utils.c b/src/e-util/test-html-editor-units-utils.c
index 06e09c3c4b..25dca04aef 100644
--- a/src/e-util/test-html-editor-units-utils.c
+++ b/src/e-util/test-html-editor-units-utils.c
@@ -1292,35 +1292,27 @@ test_utils_get_content_editor (TestFixture *fixture)
}
gchar *
-test_utils_get_base64_data_for_image (const gchar *path)
+test_utils_dup_image_uri (const gchar *path)
{
- gchar *image_data = NULL;
- gchar *image_data_base64;
- gsize image_data_length = 0;
- gboolean success;
+ gchar *image_uri = NULL;
GError *error = NULL;
if (path && strchr (path, G_DIR_SEPARATOR)) {
- success = g_file_get_contents (path, &image_data, &image_data_length, &error);
+ image_uri = g_filename_to_uri (path, NULL, &error);
} else {
gchar *filename;
filename = e_icon_factory_get_icon_filename (path, GTK_ICON_SIZE_MENU);
if (filename) {
- success = g_file_get_contents (filename, &image_data, &image_data_length, &error);
+ image_uri = g_filename_to_uri (filename, NULL, &error);
g_free (filename);
} else {
g_set_error (&error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Icon '%s' not found", path);
- success = FALSE;
}
}
g_assert_no_error (error);
- g_assert (success);
-
- image_data_base64 = g_base64_encode ((const guchar *) image_data, image_data_length);
-
- g_free (image_data);
+ g_assert_nonnull (image_uri);
- return image_data_base64;
+ return image_uri;
}
diff --git a/src/e-util/test-html-editor-units-utils.h b/src/e-util/test-html-editor-units-utils.h
index c314561cad..a24ba56033 100644
--- a/src/e-util/test-html-editor-units-utils.h
+++ b/src/e-util/test-html-editor-units-utils.h
@@ -105,8 +105,7 @@ void test_utils_set_clipboard_text (const gchar *text,
gchar * test_utils_get_clipboard_text (gboolean request_html);
EContentEditor *
test_utils_get_content_editor (TestFixture *fixture);
-gchar * test_utils_get_base64_data_for_image
- (const gchar *path);
+gchar * test_utils_dup_image_uri (const gchar *path);
G_END_DECLS
diff --git a/src/e-util/test-html-editor-units.c b/src/e-util/test-html-editor-units.c
index 9738a65483..83a316526b 100644
--- a/src/e-util/test-html-editor-units.c
+++ b/src/e-util/test-html-editor-units.c
@@ -3690,24 +3690,23 @@ test_image_insert (TestFixture *fixture)
static void
test_emoticon_insert_typed (TestFixture *fixture)
{
- gchar *image_data_base64;
+ gchar *image_uri;
gchar *expected_html;
test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-magic-smileys", TRUE);
test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-unicode-smileys", FALSE);
- image_data_base64 = test_utils_get_base64_data_for_image ("face-smile");
+ image_uri = test_utils_dup_image_uri ("face-smile");
- expected_html = g_strconcat (HTML_PREFIX "<div>before <img src=\"data:image/png;base64,",
- image_data_base64, "\" alt=\":-)\">after</div>" HTML_SUFFIX, NULL);
+ expected_html = g_strconcat (HTML_PREFIX "<div>before <img src=\"", image_uri, "\" alt=\":-)\"
width=\"16px\" height=\"16px\">after</div>" HTML_SUFFIX, NULL);
- g_free (image_data_base64);
+ g_free (image_uri);
if (!test_utils_run_simple_test (fixture,
"mode:html\n"
"type:before :)after\n",
expected_html,
- "before :-)after"))
+ "before :-)after\n"))
g_test_fail ();
g_free (expected_html);
@@ -3716,24 +3715,23 @@ test_emoticon_insert_typed (TestFixture *fixture)
static void
test_emoticon_insert_typed_dash (TestFixture *fixture)
{
- gchar *image_data_base64;
+ gchar *image_uri;
gchar *expected_html;
test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-magic-smileys", TRUE);
test_utils_fixture_change_setting_boolean (fixture, "org.gnome.evolution.mail",
"composer-unicode-smileys", FALSE);
- image_data_base64 = test_utils_get_base64_data_for_image ("face-smile");
+ image_uri = test_utils_dup_image_uri ("face-smile");
- expected_html = g_strconcat (HTML_PREFIX "<div>before <img src=\"data:image/png;base64,",
- image_data_base64, "\" alt=\":-)\">after</div>" HTML_SUFFIX, NULL);
+ expected_html = g_strconcat (HTML_PREFIX "<div>before <img src=\"", image_uri, "\" alt=\":-)\"
width=\"16px\" height=\"16px\">after</div>" HTML_SUFFIX, NULL);
- g_free (image_data_base64);
+ g_free (image_uri);
if (!test_utils_run_simple_test (fixture,
"mode:html\n"
"type:before :-)after\n",
expected_html,
- "before :-)after"))
+ "before :-)after\n"))
g_test_fail ();
g_free (expected_html);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]