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)
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 9703696..d26ba85 100644
--- a/src/tests/efreet/ef_desktop.c
+++ b/src/tests/efreet/ef_desktop.c
@@ -17,7 +17,7 @@ ef_cb_desktop_parse(void)
17 Eina_List *l; 17 Eina_List *l;
18 int ret = 1; 18 int ret = 1;
19 19
20 desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop"); 20 desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
21 if (!desktop) 21 if (!desktop)
22 { 22 {
23 printf("No desktop found.\n"); 23 printf("No desktop found.\n");
@@ -80,7 +80,7 @@ ef_cb_desktop_file_id(void)
80 Efreet_Desktop *desktop; 80 Efreet_Desktop *desktop;
81 int ret = 1; 81 int ret = 1;
82 82
83 desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop"); 83 desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
84 if (desktop) 84 if (desktop)
85 { 85 {
86 const char *id; 86 const char *id;
@@ -92,6 +92,7 @@ ef_cb_desktop_file_id(void)
92 char *prefix; 92 char *prefix;
93 char *expected; 93 char *expected;
94 } tests[] = { 94 } tests[] = {
95 // TODO: once enabled fix to remove PACKAGE_DATA_DIR
95 {PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"}, 96 {PACKAGE_DATA_DIR"/test/", 0, NULL, "test.desktop"},
96 {PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"}, 97 {PACKAGE_DATA_DIR"/", 0, NULL, "test-test.desktop"},
97 {PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"}, 98 {PACKAGE_DATA_DIR"/", 1, NULL, "test.desktop"},
@@ -126,15 +127,22 @@ ef_cb_desktop_save(void)
126 Efreet_Desktop *desktop; 127 Efreet_Desktop *desktop;
127 128
128 printf("\n"); 129 printf("\n");
129 desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop");
130 if (!desktop)
131 {
132 printf("Failed to get Desktop file\n");
133 return 0;
134 }
135 130
136 printf("save data: %d\n", efreet_desktop_save(desktop)); 131 if (eina_file_copy(ef_test_path_get("test.desktop"),
137 efreet_desktop_free(desktop); 132 "/tmp/test.desktop", 0, NULL, NULL))
133 {
134 desktop = efreet_desktop_get("/tmp/test.desktop");
135 if (!desktop)
136 {
137 unlink("/tmp/test.desktop");
138 printf("Failed to get Desktop file\n");
139 return 0;
140 }
141
142 printf("save data: %d\n", efreet_desktop_save(desktop));
143 efreet_desktop_free(desktop);
144 unlink("/tmp/test.desktop");
145 }
138 146
139 desktop = efreet_desktop_empty_new("/tmp/test.desktop"); 147 desktop = efreet_desktop_empty_new("/tmp/test.desktop");
140 desktop->name = strdup("Efreet Test Application"); 148 desktop->name = strdup("Efreet Test Application");
@@ -376,7 +384,7 @@ ef_cb_desktop_type_parse(void)
376 my_type = efreet_desktop_type_add("My_Type", cb_type_parse, NULL, 384 my_type = efreet_desktop_type_add("My_Type", cb_type_parse, NULL,
377 (Efreet_Desktop_Type_Free_Cb)free); 385 (Efreet_Desktop_Type_Free_Cb)free);
378 386
379 desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test_type.desktop"); 387 desktop = efreet_desktop_get(ef_test_path_get("test_type.desktop"));
380 if (!desktop) 388 if (!desktop)
381 { 389 {
382 printf("No desktop found.\n"); 390 printf("No desktop found.\n");
diff --git a/src/tests/efreet/ef_ini.c b/src/tests/efreet/ef_ini.c
index d31fb45..66bc486 100644
--- a/src/tests/efreet/ef_ini.c
+++ b/src/tests/efreet/ef_ini.c
@@ -12,7 +12,7 @@ ef_cb_ini_parse(void)
12 12
13 putenv("LC_ALL=en_US"); 13 putenv("LC_ALL=en_US");
14 14
15 ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test.ini"); 15 ini = efreet_ini_new(ef_test_path_get("test.ini"));
16 if (!ini) 16 if (!ini)
17 { 17 {
18 printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n"); 18 printf("efreet_ini_parse() Failed to initialize Efreet_Ini\n");
@@ -115,7 +115,7 @@ ef_cb_ini_long_line(void)
115 {NULL, 0} 115 {NULL, 0}
116 }; 116 };
117 117
118 ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/long.ini"); 118 ini = efreet_ini_new(ef_test_path_get("long.ini"));
119 if (!ini) 119 if (!ini)
120 { 120 {
121 printf("Ini failed to parse.\n"); 121 printf("Ini failed to parse.\n");
@@ -162,7 +162,7 @@ ef_cb_ini_garbage(void)
162 Efreet_Ini *ini; 162 Efreet_Ini *ini;
163 int ret = 1; 163 int ret = 1;
164 164
165 ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test_garbage"); 165 ini = efreet_ini_new(ef_test_path_get("test_garbage"));
166 if (!ini) 166 if (!ini)
167 { 167 {
168 printf("Ini failed to parse.\n"); 168 printf("Ini failed to parse.\n");
diff --git a/src/tests/efreet/ef_menu.c b/src/tests/efreet/ef_menu.c
index 4adbd94..9f148ef 100644
--- a/src/tests/efreet/ef_menu.c
+++ b/src/tests/efreet/ef_menu.c
@@ -32,7 +32,7 @@ ef_cb_menu_get(void)
32 Efreet_Menu *menu; 32 Efreet_Menu *menu;
33 33
34 menu = efreet_menu_get(); 34 menu = efreet_menu_get();
35// menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu"); 35// menu = efreet_menu_parse(ef_test_path_get("test.menu"));
36 if (!menu) 36 if (!menu)
37 { 37 {
38 printf("efreet_menu_get() returned NULL\n"); 38 printf("efreet_menu_get() returned NULL\n");
@@ -50,7 +50,7 @@ ef_cb_menu_with_slashes(void)
50{ 50{
51 Efreet_Menu *menu; 51 Efreet_Menu *menu;
52 52
53 menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test_menu_slash_bad.menu"); 53 menu = efreet_menu_parse(ef_test_path_get("test_menu_slash_bad.menu"));
54 if (menu) 54 if (menu)
55 { 55 {
56 printf("efreet_menu_get() didn't return NULL\n"); 56 printf("efreet_menu_get() didn't return NULL\n");
@@ -67,7 +67,7 @@ ef_cb_menu_save(void)
67 int ret; 67 int ret;
68 68
69// menu = efreet_menu_get(); 69// menu = efreet_menu_get();
70 menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu"); 70 menu = efreet_menu_parse(ef_test_path_get("test.menu"));
71 if (!menu) 71 if (!menu)
72 { 72 {
73 printf("efreet_menu_get() returned NULL\n"); 73 printf("efreet_menu_get() returned NULL\n");
@@ -86,7 +86,7 @@ ef_cb_menu_edit(void)
86 Efreet_Desktop *desktop; 86 Efreet_Desktop *desktop;
87 87
88// menu = efreet_menu_get(); 88// menu = efreet_menu_get();
89 menu = efreet_menu_parse(PACKAGE_DATA_DIR"/test/test.menu"); 89 menu = efreet_menu_parse(ef_test_path_get("test.menu"));
90 if (!menu) 90 if (!menu)
91 { 91 {
92 printf("efreet_menu_get() returned NULL\n"); 92 printf("efreet_menu_get() returned NULL\n");
@@ -98,7 +98,7 @@ ef_cb_menu_edit(void)
98 printf("\n"); 98 printf("\n");
99#endif 99#endif
100 100
101 desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop"); 101 desktop = efreet_desktop_get(ef_test_path_get("test.desktop"));
102 if (!desktop) 102 if (!desktop)
103 { 103 {
104 efreet_menu_free(menu); 104 efreet_menu_free(menu);
diff --git a/src/tests/efreet/ef_mime.c b/src/tests/efreet/ef_mime.c
index 18f36b0..3bdba9b 100644
--- a/src/tests/efreet/ef_mime.c
+++ b/src/tests/efreet/ef_mime.c
@@ -19,10 +19,10 @@ ef_mime_cb_get(void)
19 char *file; 19 char *file;
20 char *mime; 20 char *mime;
21 } files[] = { 21 } files[] = {
22 {PACKAGE_DATA_DIR"/test/test_type.desktop", "application/x-desktop"}, 22 {"test_type.desktop", "application/x-desktop"},
23 {PACKAGE_DATA_DIR"/test/entry.png", "image/png"}, 23 {"entry.png", "image/png"},
24 {PACKAGE_DATA_DIR"/test/entry", "image/png"}, 24 {"entry", "image/png"},
25 {PACKAGE_DATA_DIR"/test/sub", "inode/directory"}, 25 {"sub", "inode/directory"},
26 {NULL, NULL} 26 {NULL, NULL}
27 }; 27 };
28 double start; 28 double start;
@@ -35,7 +35,7 @@ ef_mime_cb_get(void)
35 35
36 for (i = 0; files[i].file; ++i) 36 for (i = 0; files[i].file; ++i)
37 { 37 {
38 mime = efreet_mime_type_get(files[i].file); 38 mime = efreet_mime_type_get(ef_test_path_get(files[i].file));
39 if (!mime) 39 if (!mime)
40 { 40 {
41 printf("Got %s as null instead of %s\n", files[i].file, files[i].mime); 41 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 2e88c68..5d2b83a 100644
--- a/src/tests/efreet/ef_test.h
+++ b/src/tests/efreet/ef_test.h
@@ -8,4 +8,6 @@
8#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0); 8#define IF_FREE(x) do { if (x) free(x); x = NULL; } while (0);
9#define NEW(x, c) calloc(c, sizeof(x)) 9#define NEW(x, c) calloc(c, sizeof(x))
10 10
11const char *ef_test_path_get(const char *component);
12
11#endif 13#endif
diff --git a/src/tests/efreet/main.c b/src/tests/efreet/main.c
index 634431b..0833744 100644
--- a/src/tests/efreet/main.c
+++ b/src/tests/efreet/main.c
@@ -78,6 +78,32 @@ static Efreet_Test tests[] = {
78extern char **environ; 78extern char **environ;
79static Eina_List *environment = NULL; 79static Eina_List *environment = NULL;
80 80
81const char *ef_test_path_get(const char *component)
82{
83 static int is_local = -1;
84 static char buf[PATH_MAX];
85
86 if (is_local == -1)
87 {
88 struct stat st;
89 is_local = (stat(PACKAGE_BUILD_DIR"/src/tests/efreet/data/test.desktop", &st) == 0);
90 }
91
92 if (is_local)
93 {
94 eina_str_join(buf, sizeof(buf), '/',
95 PACKAGE_BUILD_DIR"/src/tests/efreet/data",
96 component);
97 }
98 else
99 {
100 eina_str_join(buf, sizeof(buf), '/', PACKAGE_DATA_DIR "/tests",
101 component);
102 }
103
104 return buf;
105}
106
81void 107void
82environment_store(void) 108environment_store(void)
83{ 109{