summaryrefslogtreecommitdiff
path: root/src/tests/efreet
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-08 23:45:48 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-08 23:45:48 +0000
commitf57968f1581e443472689488f26f8cd3bcede1cc (patch)
tree43e0c63094d122b2e50eb7e2af74b1373a497c4b /src/tests/efreet
parent90e4c429193f103005acfa16258100a8507c1b41 (diff)
downloadefl-f57968f1581e443472689488f26f8cd3bcede1cc.tar.gz
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
Diffstat (limited to 'src/tests/efreet')
-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
6 files changed, 60 insertions, 24 deletions
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)
{