summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Efreet.am1
-rw-r--r--src/lib/efreet/efreet_ini.c10
-rw-r--r--src/lib/efreet/efreet_mime.c1
-rw-r--r--src/tests/efreet/ef_desktop.c30
-rw-r--r--src/tests/efreet/ef_ini.c6
-rw-r--r--src/tests/efreet/ef_menu.c10
-rw-r--r--src/tests/efreet/ef_mime.c10
-rw-r--r--src/tests/efreet/ef_test.h2
-rw-r--r--src/tests/efreet/main.c26
9 files changed, 67 insertions, 29 deletions
diff --git a/src/Makefile_Efreet.am b/src/Makefile_Efreet.am
index 8c3a1af46c..dd905c1730 100644
--- a/src/Makefile_Efreet.am
+++ b/src/Makefile_Efreet.am
@@ -24,6 +24,7 @@ EFREET_COMMON_CPPFLAGS = \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/efreet\" \
+-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)\" \
-DDATA_DIR=\"$(datadir)\" \
-DLOCALE_DIR=\"@LOCALE_DIR@\" \
-DEFL_EFREET_BUILD \
diff --git a/src/lib/efreet/efreet_ini.c b/src/lib/efreet/efreet_ini.c
index abc184673c..fec11c3e3f 100644
--- a/src/lib/efreet/efreet_ini.c
+++ b/src/lib/efreet/efreet_ini.c
@@ -58,10 +58,8 @@ efreet_ini_new(const char *file)
ini = NEW(Efreet_Ini, 1);
if (!ini) return NULL;
- /* This can validly be NULL at the moment as _parse() will return NULL
- * if the input file doesn't exist. Should we change _parse() to create
- * the hash and only return NULL on failed parse? */
- ini->data = efreet_ini_parse(file);
+ if (file)
+ ini->data = efreet_ini_parse(file);
return ini;
}
@@ -81,6 +79,7 @@ efreet_ini_parse(const char *file)
Eina_File_Line *line;
Eina_File *f;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
f = eina_file_open(file, EINA_FALSE);
if (!f)
return NULL;
@@ -259,7 +258,8 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
free(dir);
f = fopen(file, "wb");
if (!f) return 0;
- eina_hash_foreach(ini->data, efreet_ini_section_save, f);
+ if (ini->data)
+ eina_hash_foreach(ini->data, efreet_ini_section_save, f);
fclose(f);
return 1;
diff --git a/src/lib/efreet/efreet_mime.c b/src/lib/efreet/efreet_mime.c
index 20ae5c568c..07fff9827c 100644
--- a/src/lib/efreet/efreet_mime.c
+++ b/src/lib/efreet/efreet_mime.c
@@ -834,6 +834,7 @@ efreet_mime_mime_types_load(const char *file)
const char *word_start;
const char *mimetype;
+ EINA_SAFETY_ON_NULL_RETURN(file);
f = eina_file_open(file, 0);
if (!f) return ;
diff --git a/src/tests/efreet/ef_desktop.c b/src/tests/efreet/ef_desktop.c
index 97036963b5..d26ba85807 100644
--- a/src/tests/efreet/ef_desktop.c
+++ b/src/tests/efreet/ef_desktop.c
@@ -17,7 +17,7 @@ ef_cb_desktop_parse(void)
Eina_List *l;
int ret = 1;
- desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
+ desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
if (!desktop)
{
printf("No desktop found.\n");
@@ -80,7 +80,7 @@ ef_cb_desktop_file_id(void)
Efreet_Desktop *desktop;
int ret = 1;
- desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
+ desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
if (desktop)
{
const char *id;
@@ -92,6 +92,7 @@ ef_cb_desktop_file_id(void)
char *prefix;
char *expected;
} tests[] = {
+ // TODO: once enabled fix to remove PACKAGE_DATA_DIR
{PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"},
{PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"},
{PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"},
@@ -126,15 +127,22 @@ ef_cb_desktop_save(void)
Efreet_Desktop *desktop;
printf("\n");
- desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
- if (!desktop)
- {
- printf("Failed to get Desktop file\n");
- return 0;
- }
- printf("save data: %d\n", efreet_desktop_save(desktop));
- efreet_desktop_free(desktop);
+ if (eina_file_copy(ef_test_path_get("test.desktop"),
+ "/tmp/test.desktop", 0, NULL, NULL))
+ {
+ desktop = efreet_desktop_get("/tmp/test.desktop");
+ if (!desktop)
+ {
+ unlink("/tmp/test.desktop");
+ printf("Failed to get Desktop file\n");
+ return 0;
+ }
+
+ printf("save data: %d\n", efreet_desktop_save(desktop));
+ efreet_desktop_free(desktop);
+ unlink("/tmp/test.desktop");
+ }
desktop = efreet_desktop_empty_new("/tmp/test.desktop");
desktop->name = strdup("Efreet Test Application");
@@ -376,7 +384,7 @@ ef_cb_desktop_type_parse(void)
my_type = efreet_desktop_type_add("My_Type", cb_type_parse, NULL,
(Efreet_Desktop_Type_Free_Cb)free);
- desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test_type.desktop");
+ desktop = efreet_desktop_get(ef_test_path_get("test_type.desktop"));
if (!desktop)
{
printf("No desktop found.\n");
diff --git a/src/tests/efreet/ef_ini.c b/src/tests/efreet/ef_ini.c
index d31fb456f8..66bc48649a 100644
--- a/src/tests/efreet/ef_ini.c
+++ b/src/tests/efreet/ef_ini.c
@@ -12,7 +12,7 @@ ef_cb_ini_parse(void)
putenv("LC_ALL=en_US");
- ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test.ini");
+ ini = efreet_ini_new(ef_test_path_get("test.ini"));
if (!ini)
{
printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n");
@@ -115,7 +115,7 @@ ef_cb_ini_long_line(void)
{NULL, 0}
};
- ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/long.ini");
+ ini = efreet_ini_new(ef_test_path_get("long.ini"));
if (!ini)
{
printf("Ini failed to parse.\n");
@@ -162,7 +162,7 @@ ef_cb_ini_garbage(void)
Efreet_Ini *ini;
int ret = 1;
- ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test_garbage");
+ ini = efreet_ini_new(ef_test_path_get("test_garbage"));
if (!ini)
{
printf("Ini failed to parse.\n");
diff --git a/src/tests/efreet/ef_menu.c b/src/tests/efreet/ef_menu.c
index 4adbd941c0..9f148efc6c 100644
--- a/src/tests/efreet/ef_menu.c
+++ b/src/tests/efreet/ef_menu.c
@@ -32,7 +32,7 @@ ef_cb_menu_get(void)
Efreet_Menu *menu;
menu = efreet_menu_get();
-// menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu");
+// menu = efreet_menu_parse(ef_test_path_get("test.menu"));
if (!menu)
{
printf("efreet_menu_get() returned NULL\n");
@@ -50,7 +50,7 @@ ef_cb_menu_with_slashes(void)
{
Efreet_Menu *menu;
- menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test_menu_slash_bad.menu");
+ menu = efreet_menu_parse(ef_test_path_get("test_menu_slash_bad.menu"));
if (menu)
{
printf("efreet_menu_get() didn't return NULL\n");
@@ -67,7 +67,7 @@ ef_cb_menu_save(void)
int ret;
// menu = efreet_menu_get();
- menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu");
+ menu = efreet_menu_parse(ef_test_path_get("test.menu"));
if (!menu)
{
printf("efreet_menu_get() returned NULL\n");
@@ -86,7 +86,7 @@ ef_cb_menu_edit(void)
Efreet_Desktop *desktop;
// menu = efreet_menu_get();
- menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu");
+ menu = efreet_menu_parse(ef_test_path_get("test.menu"));
if (!menu)
{
printf("efreet_menu_get() returned NULL\n");
@@ -98,7 +98,7 @@ ef_cb_menu_edit(void)
printf("\n");
#endif
- desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
+ desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
if (!desktop)
{
efreet_menu_free(menu);
diff --git a/src/tests/efreet/ef_mime.c b/src/tests/efreet/ef_mime.c
index 18f36b024c..3bdba9b8f1 100644
--- a/src/tests/efreet/ef_mime.c
+++ b/src/tests/efreet/ef_mime.c
@@ -19,10 +19,10 @@ ef_mime_cb_get(void)
char *file;
char *mime;
} files[] = {
- {PACKAGE_DATA_DIR"/test/test_type.desktop", "application/x-desktop"},
- {PACKAGE_DATA_DIR"/test/entry.png", "image/png"},
- {PACKAGE_DATA_DIR"/test/entry", "image/png"},
- {PACKAGE_DATA_DIR"/test/sub", "inode/directory"},
+ {"test_type.desktop", "application/x-desktop"},
+ {"entry.png", "image/png"},
+ {"entry", "image/png"},
+ {"sub", "inode/directory"},
{NULL, NULL}
};
double start;
@@ -35,7 +35,7 @@ ef_mime_cb_get(void)
for (i = 0; files[i].file; ++i)
{
- mime = efreet_mime_type_get(files[i].file);
+ mime = efreet_mime_type_get(ef_test_path_get(files[i].file));
if (!mime)
{
printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
diff --git a/src/tests/efreet/ef_test.h b/src/tests/efreet/ef_test.h
index 2e88c68d25..5d2b83a1df 100644
--- a/src/tests/efreet/ef_test.h
+++ b/src/tests/efreet/ef_test.h
@@ -8,4 +8,6 @@
#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);
#define NEW(x, c) calloc(c, sizeof(x))
+const char *ef_test_path_get(const char *component);
+
#endif
diff --git a/src/tests/efreet/main.c b/src/tests/efreet/main.c
index 634431b1a8..083374402a 100644
--- a/src/tests/efreet/main.c
+++ b/src/tests/efreet/main.c
@@ -78,6 +78,32 @@ static Efreet_Test tests[] = {
extern char **environ;
static Eina_List *environment = NULL;
+const char *ef_test_path_get(const char *component)
+{
+ static int is_local = -1;
+ static char buf[PATH_MAX];
+
+ if (is_local == -1)
+ {
+ struct stat st;
+ is_local = (stat(PACKAGE_BUILD_DIR"/src/tests/efreet/data/test.desktop", &st) == 0);
+ }
+
+ if (is_local)
+ {
+ eina_str_join(buf, sizeof(buf), '/',
+ PACKAGE_BUILD_DIR"/src/tests/efreet/data",
+ component);
+ }
+ else
+ {
+ eina_str_join(buf, sizeof(buf), '/', PACKAGE_DATA_DIR "/tests",
+ component);
+ }
+
+ return buf;
+}
+
void
environment_store(void)
{