forked from enlightenment/efl
efl/efreet: improve tests, fix bogus warning.
* tests will run locally now, not just from installed files. * efreet_init_new(NULL) is valid, actually used by efreet_desktop_save() SVN revision: 82428
This commit is contained in:
parent
90e4c42919
commit
f57968f158
|
@ -24,6 +24,7 @@ EFREET_COMMON_CPPFLAGS = \
|
||||||
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
|
||||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||||
-DPACKAGE_DATA_DIR=\"$(datadir)/efreet\" \
|
-DPACKAGE_DATA_DIR=\"$(datadir)/efreet\" \
|
||||||
|
-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)\" \
|
||||||
-DDATA_DIR=\"$(datadir)\" \
|
-DDATA_DIR=\"$(datadir)\" \
|
||||||
-DLOCALE_DIR=\"@LOCALE_DIR@\" \
|
-DLOCALE_DIR=\"@LOCALE_DIR@\" \
|
||||||
-DEFL_EFREET_BUILD \
|
-DEFL_EFREET_BUILD \
|
||||||
|
|
|
@ -58,10 +58,8 @@ efreet_ini_new(const char *file)
|
||||||
ini = NEW(Efreet_Ini, 1);
|
ini = NEW(Efreet_Ini, 1);
|
||||||
if (!ini) return NULL;
|
if (!ini) return NULL;
|
||||||
|
|
||||||
/* This can validly be NULL at the moment as _parse() will return NULL
|
if (file)
|
||||||
* if the input file doesn't exist. Should we change _parse() to create
|
ini->data = efreet_ini_parse(file);
|
||||||
* the hash and only return NULL on failed parse? */
|
|
||||||
ini->data = efreet_ini_parse(file);
|
|
||||||
|
|
||||||
return ini;
|
return ini;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +79,7 @@ efreet_ini_parse(const char *file)
|
||||||
Eina_File_Line *line;
|
Eina_File_Line *line;
|
||||||
Eina_File *f;
|
Eina_File *f;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
||||||
f = eina_file_open(file, EINA_FALSE);
|
f = eina_file_open(file, EINA_FALSE);
|
||||||
if (!f)
|
if (!f)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -259,7 +258,8 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
|
||||||
free(dir);
|
free(dir);
|
||||||
f = fopen(file, "wb");
|
f = fopen(file, "wb");
|
||||||
if (!f) return 0;
|
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);
|
fclose(f);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -834,6 +834,7 @@ efreet_mime_mime_types_load(const char *file)
|
||||||
const char *word_start;
|
const char *word_start;
|
||||||
const char *mimetype;
|
const char *mimetype;
|
||||||
|
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(file);
|
||||||
f = eina_file_open(file, 0);
|
f = eina_file_open(file, 0);
|
||||||
if (!f) return ;
|
if (!f) return ;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ ef_cb_desktop_parse(void)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
int ret = 1;
|
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)
|
if (!desktop)
|
||||||
{
|
{
|
||||||
printf("No desktop found.\n");
|
printf("No desktop found.\n");
|
||||||
|
@ -80,7 +80,7 @@ ef_cb_desktop_file_id(void)
|
||||||
Efreet_Desktop *desktop;
|
Efreet_Desktop *desktop;
|
||||||
int ret = 1;
|
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)
|
if (desktop)
|
||||||
{
|
{
|
||||||
const char *id;
|
const char *id;
|
||||||
|
@ -92,6 +92,7 @@ ef_cb_desktop_file_id(void)
|
||||||
char *prefix;
|
char *prefix;
|
||||||
char *expected;
|
char *expected;
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
|
// TODO: once enabled fix to remove PACKAGE_DATA_DIR
|
||||||
{PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"},
|
{PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"},
|
||||||
{PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"},
|
{PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"},
|
||||||
{PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"},
|
{PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"},
|
||||||
|
@ -126,15 +127,22 @@ ef_cb_desktop_save(void)
|
||||||
Efreet_Desktop *desktop;
|
Efreet_Desktop *desktop;
|
||||||
|
|
||||||
printf("\n");
|
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));
|
if (eina_file_copy(ef_test_path_get("test.desktop"),
|
||||||
efreet_desktop_free(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 = efreet_desktop_empty_new("/tmp/test.desktop");
|
||||||
desktop->name = strdup("Efreet Test Application");
|
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,
|
my_type = efreet_desktop_type_add("My_Type", cb_type_parse, NULL,
|
||||||
(Efreet_Desktop_Type_Free_Cb)free);
|
(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)
|
if (!desktop)
|
||||||
{
|
{
|
||||||
printf("No desktop found.\n");
|
printf("No desktop found.\n");
|
||||||
|
|
|
@ -12,7 +12,7 @@ ef_cb_ini_parse(void)
|
||||||
|
|
||||||
putenv("LC_ALL=en_US");
|
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)
|
if (!ini)
|
||||||
{
|
{
|
||||||
printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n");
|
printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n");
|
||||||
|
@ -115,7 +115,7 @@ ef_cb_ini_long_line(void)
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/long.ini");
|
ini = efreet_ini_new(ef_test_path_get("long.ini"));
|
||||||
if (!ini)
|
if (!ini)
|
||||||
{
|
{
|
||||||
printf("Ini failed to parse.\n");
|
printf("Ini failed to parse.\n");
|
||||||
|
@ -162,7 +162,7 @@ ef_cb_ini_garbage(void)
|
||||||
Efreet_Ini *ini;
|
Efreet_Ini *ini;
|
||||||
int ret = 1;
|
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)
|
if (!ini)
|
||||||
{
|
{
|
||||||
printf("Ini failed to parse.\n");
|
printf("Ini failed to parse.\n");
|
||||||
|
|
|
@ -32,7 +32,7 @@ ef_cb_menu_get(void)
|
||||||
Efreet_Menu *menu;
|
Efreet_Menu *menu;
|
||||||
|
|
||||||
menu = efreet_menu_get();
|
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)
|
if (!menu)
|
||||||
{
|
{
|
||||||
printf("efreet_menu_get() returned NULL\n");
|
printf("efreet_menu_get() returned NULL\n");
|
||||||
|
@ -50,7 +50,7 @@ ef_cb_menu_with_slashes(void)
|
||||||
{
|
{
|
||||||
Efreet_Menu *menu;
|
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)
|
if (menu)
|
||||||
{
|
{
|
||||||
printf("efreet_menu_get() didn't return NULL\n");
|
printf("efreet_menu_get() didn't return NULL\n");
|
||||||
|
@ -67,7 +67,7 @@ ef_cb_menu_save(void)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// menu = efreet_menu_get();
|
// 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)
|
if (!menu)
|
||||||
{
|
{
|
||||||
printf("efreet_menu_get() returned NULL\n");
|
printf("efreet_menu_get() returned NULL\n");
|
||||||
|
@ -86,7 +86,7 @@ ef_cb_menu_edit(void)
|
||||||
Efreet_Desktop *desktop;
|
Efreet_Desktop *desktop;
|
||||||
|
|
||||||
// menu = efreet_menu_get();
|
// 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)
|
if (!menu)
|
||||||
{
|
{
|
||||||
printf("efreet_menu_get() returned NULL\n");
|
printf("efreet_menu_get() returned NULL\n");
|
||||||
|
@ -98,7 +98,7 @@ ef_cb_menu_edit(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
|
desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
|
||||||
if (!desktop)
|
if (!desktop)
|
||||||
{
|
{
|
||||||
efreet_menu_free(menu);
|
efreet_menu_free(menu);
|
||||||
|
|
|
@ -19,10 +19,10 @@ ef_mime_cb_get(void)
|
||||||
char *file;
|
char *file;
|
||||||
char *mime;
|
char *mime;
|
||||||
} files[] = {
|
} files[] = {
|
||||||
{PACKAGE_DATA_DIR"/test/test_type.desktop", "application/x-desktop"},
|
{"test_type.desktop", "application/x-desktop"},
|
||||||
{PACKAGE_DATA_DIR"/test/entry.png", "image/png"},
|
{"entry.png", "image/png"},
|
||||||
{PACKAGE_DATA_DIR"/test/entry", "image/png"},
|
{"entry", "image/png"},
|
||||||
{PACKAGE_DATA_DIR"/test/sub", "inode/directory"},
|
{"sub", "inode/directory"},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
double start;
|
double start;
|
||||||
|
@ -35,7 +35,7 @@ ef_mime_cb_get(void)
|
||||||
|
|
||||||
for (i = 0; files[i].file; ++i)
|
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)
|
if (!mime)
|
||||||
{
|
{
|
||||||
printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
|
printf("Got %s as null instead of %s\n", files[i].file, files[i].mime);
|
||||||
|
|
|
@ -8,4 +8,6 @@
|
||||||
#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);
|
#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);
|
||||||
#define NEW(x, c) calloc(c, sizeof(x))
|
#define NEW(x, c) calloc(c, sizeof(x))
|
||||||
|
|
||||||
|
const char *ef_test_path_get(const char *component);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -78,6 +78,32 @@ static Efreet_Test tests[] = {
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
static Eina_List *environment = NULL;
|
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
|
void
|
||||||
environment_store(void)
|
environment_store(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue