diff options
-rw-r--r-- | lib/ephy-file-helpers.c | 15 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 3 | ||||
-rw-r--r-- | tests/ephy-web-app-utils-test.c | 6 | ||||
-rw-r--r-- | tests/meson.build | 17 |
4 files changed, 23 insertions, 18 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index c673942cb..62efb1299 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -62,7 +62,8 @@ typedef enum { EPHY_PROFILE_DIR_UNKNOWN, EPHY_PROFILE_DIR_DEFAULT, - EPHY_PROFILE_DIR_WEB_APP + EPHY_PROFILE_DIR_WEB_APP, + EPHY_PROFILE_DIR_TEST } EphyProfileDirType; static GHashTable *files; @@ -245,7 +246,7 @@ ephy_dot_dir (void) gboolean ephy_dot_dir_is_default (void) { - return dot_dir_type == EPHY_PROFILE_DIR_DEFAULT; + return dot_dir_type == EPHY_PROFILE_DIR_DEFAULT || dot_dir_type == EPHY_PROFILE_DIR_TEST; } /** @@ -271,7 +272,9 @@ ephy_dot_dir_is_web_application (void) char * ephy_default_dot_dir (void) { - return g_build_filename (g_get_user_config_dir (), "epiphany", NULL); + return dot_dir_type == EPHY_PROFILE_DIR_TEST ? + g_strdup (ephy_dot_dir ()) : + g_build_filename (g_get_user_config_dir (), "epiphany", NULL); } /** @@ -302,7 +305,7 @@ ephy_file_helpers_init (const char *profile_dir, (GDestroyNotify)g_free); keep_directory = flags & EPHY_FILE_HELPERS_KEEP_DIR; - private_profile = flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE; + private_profile = (flags & EPHY_FILE_HELPERS_PRIVATE_PROFILE || flags & EPHY_FILE_HELPERS_TESTING_MODE); steal_data_from_profile = flags & EPHY_FILE_HELPERS_STEAL_DATA; if (profile_dir != NULL && !steal_data_from_profile) { @@ -333,11 +336,13 @@ ephy_file_helpers_init (const char *profile_dir, dot_dir = g_build_filename (ephy_file_tmp_dir (), "epiphany", NULL); + if (flags & EPHY_FILE_HELPERS_TESTING_MODE) + dot_dir_type = EPHY_PROFILE_DIR_TEST; } if (dot_dir == NULL) { - dot_dir = ephy_default_dot_dir (); dot_dir_type = EPHY_PROFILE_DIR_DEFAULT; + dot_dir = ephy_default_dot_dir (); } if (flags & EPHY_FILE_HELPERS_ENSURE_EXISTS) diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 0977fc574..923d25460 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -44,7 +44,8 @@ typedef enum EPHY_FILE_HELPERS_KEEP_DIR = 1 << 1, EPHY_FILE_HELPERS_PRIVATE_PROFILE = 1 << 2, EPHY_FILE_HELPERS_ENSURE_EXISTS = 1 << 3, - EPHY_FILE_HELPERS_STEAL_DATA = 1 << 4 + EPHY_FILE_HELPERS_STEAL_DATA = 1 << 4, + EPHY_FILE_HELPERS_TESTING_MODE = 1 << 5 } EphyFileHelpersFlags; gboolean ephy_file_helpers_init (const char *profile_dir, diff --git a/tests/ephy-web-app-utils-test.c b/tests/ephy-web-app-utils-test.c index 8a4b7bab3..8d80ab665 100644 --- a/tests/ephy-web-app-utils-test.c +++ b/tests/ephy-web-app-utils-test.c @@ -65,7 +65,7 @@ test_web_app_lifetime (void) g_test_message ("NAME: %s", test.name); /* Test creation */ - desktop_file = ephy_web_application_create (test.url, test.name, NULL); + desktop_file = ephy_web_application_create (test.name, test.url, NULL); g_assert (g_str_has_prefix (desktop_file, ephy_dot_dir ())); g_assert (g_file_test (desktop_file, G_FILE_TEST_EXISTS)); @@ -91,7 +91,7 @@ test_web_app_lifetime (void) g_assert_cmpstr (app->name, ==, test.name); g_assert_cmpstr (app->url, ==, test.url); g_assert_cmpstr (app->desktop_file, ==, basename); - g_assert (g_str_has_prefix (app->icon_url, profile_dir)); + g_assert_null (app->icon_url); ephy_web_application_free_application_list (apps); @@ -120,7 +120,7 @@ main (int argc, char *argv[]) { int ret; - if (!ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS, NULL)) { + if (!ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_TESTING_MODE | EPHY_FILE_HELPERS_ENSURE_EXISTS, NULL)) { g_debug ("Something wrong happened with ephy_file_helpers_init()"); return -1; } diff --git a/tests/meson.build b/tests/meson.build index 89f903ac3..e03d4ea82 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -169,15 +169,14 @@ if get_option('unit_tests') env: envs, ) - # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=759256 - # web_app_utils_test = executable('test-ephy-web-app-utils', - # 'ephy-web-app-utils-test.c', - # dependencies: ephymain_dep - # ) - # test('Web app utils test', - # web_app_utils_test, - # env: envs - # ) + web_app_utils_test = executable('test-ephy-web-app-utils', + 'ephy-web-app-utils-test.c', + dependencies: ephymain_dep + ) + test('Web app utils test', + web_app_utils_test, + env: envs + ) # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=780280 # web_view_test = executable('test-ephy-web-view', |