summaryrefslogtreecommitdiff
path: root/src/tests/efreet/main.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-29 23:04:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-12-29 23:04:40 +0000
commit4bc0210bd31ed1de6554441562bd93ea863ee9d9 (patch)
tree5d83be12538f8c8d3816bbf65916ce383d050c2e /src/tests/efreet/main.c
parent727ddbeaf0c53f31cd62c254fdebe26823d537eb (diff)
efl: merge efreet.
seems to be fine, pass distcheck and friends. please report. changes: - documentation hierarchy fixes - replaced __UNUSED__ with EINA_UNUSED - replaced PKG_DATA_DIR with PACKAGE_DATA_DIR"/efreet" SVN revision: 81889
Diffstat (limited to 'src/tests/efreet/main.c')
-rw-r--r--src/tests/efreet/main.c188
1 files changed, 188 insertions, 0 deletions
diff --git a/src/tests/efreet/main.c b/src/tests/efreet/main.c
new file mode 100644
index 0000000000..de6cf37add
--- /dev/null
+++ b/src/tests/efreet/main.c
@@ -0,0 +1,188 @@
1#include "Efreet.h"
2/* no logging */
3#define EFREET_MODULE_LOG_DOM
4#include "efreet_private.h"
5#include "Efreet_Mime.h"
6#include "config.h"
7#include <Ecore.h>
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11
12int ef_cb_efreet_data_home(void);
13int ef_cb_efreet_config_home(void);
14int ef_cb_efreet_cache_home(void);
15int ef_cb_efreet_data_dirs(void);
16int ef_cb_efreet_config_dirs(void);
17int ef_cb_efreet_icon_theme(void);
18int ef_cb_efreet_icon_theme_list(void);
19int ef_cb_efreet_icon_match(void);
20int ef_cb_ini_parse(void);
21int ef_cb_ini_long_line(void);
22int ef_cb_ini_garbage(void);
23#if DEFAULT_VISIBILITY
24int ef_cb_locale(void);
25#endif
26int ef_cb_desktop_parse(void);
27int ef_cb_desktop_save(void);
28int ef_cb_desktop_command_get(void);
29int ef_cb_desktop_type_parse(void);
30#if 0
31int ef_cb_desktop_file_id(void);
32#endif
33int ef_cb_menu_get(void);
34int ef_cb_menu_with_slashes(void);
35int ef_cb_menu_save(void);
36#if 0
37int ef_cb_menu_edit(void);
38#endif
39int ef_cb_utils(void);
40int ef_mime_cb_get(void);
41
42typedef struct Efreet_Test Efreet_Test;
43struct Efreet_Test
44{
45 char *name;
46 int (*cb)(void);
47};
48
49static Efreet_Test tests[] = {
50 {"Data Home", ef_cb_efreet_data_home},
51 {"Config Home", ef_cb_efreet_config_home},
52 {"Cache Home", ef_cb_efreet_cache_home},
53 {"Data Directories", ef_cb_efreet_data_dirs},
54 {"Config Directories", ef_cb_efreet_config_dirs},
55 {"Icon Theme Basic", ef_cb_efreet_icon_theme},
56 {"Icon Theme List", ef_cb_efreet_icon_theme_list},
57 {"Icon Matching", ef_cb_efreet_icon_match},
58 {"INI Parsing", ef_cb_ini_parse},
59 {"INI Long Line Parsing", ef_cb_ini_long_line},
60 {"INI Garbage Parsing", ef_cb_ini_garbage},
61#if DEFAULT_VISIBILITY
62 {"Locale Parsing", ef_cb_locale},
63#endif
64 {"Desktop Parsing", ef_cb_desktop_parse},
65 {"Desktop Type Parsing", ef_cb_desktop_type_parse},
66 {"Desktop Save", ef_cb_desktop_save},
67 {"Desktop Command", ef_cb_desktop_command_get},
68#if 0
69 {"Desktop File ID", ef_cb_desktop_file_id},
70#endif
71 {"Menu Parsing", ef_cb_menu_get},
72 {"Menu Incorrect Names", ef_cb_menu_with_slashes},
73 {"Menu Save", ef_cb_menu_save},
74#if 0
75 {"Menu Edit", ef_cb_menu_edit},
76#endif
77 {"Utils", ef_cb_utils},
78 {"Mime", ef_mime_cb_get},
79 {NULL, NULL}
80};
81
82extern char **environ;
83static Eina_List *environment = NULL;
84
85void
86environment_store(void)
87{
88 char *env;
89 char **e;
90#ifdef HAVE_CLEARENV
91 EINA_LIST_FREE(environment, env)
92 free(env);
93 for (e = environ; *e; e++)
94 environment = eina_list_append(environment, strdup(*e));
95#endif
96}
97
98void
99environment_restore(void)
100{
101 Eina_List *l;
102 char *e;
103 if (!environment) return;
104#ifdef HAVE_CLEARENV
105 clearenv();
106 EINA_LIST_FOREACH(environment, l, e)
107 putenv(e);
108#endif
109}
110
111int
112main(int argc, char ** argv)
113{
114 int i, passed = 0, num_tests = 0;
115 Eina_List *run = NULL;
116 double total;
117 char *env;
118
119 eina_init();
120 ecore_init();
121
122 total = ecore_time_get();
123 if (argc > 1)
124 {
125 for (i = 1; i < argc; i++)
126 {
127 if ((!strcmp(argv[i], "-h")) ||
128 (!strcmp(argv[i], "--help")))
129 {
130 for (i = 0; tests[i].name; i++)
131 {
132 printf("%s\n", tests[i].name);
133 }
134 return 1;
135 }
136 run = eina_list_append(run, argv[i]);
137 }
138 }
139
140 efreet_cache_update = 0;
141 environment_store();
142 for (i = 0; tests[i].name; i++)
143 {
144 int ret;
145 double start;
146
147 /* we've been given specific tests and it isn't in the list */
148 if (run && !eina_list_search_unsorted(run, EINA_COMPARE_CB(strcasecmp),
149 tests[i].name))
150 continue;
151
152 if (!efreet_init())
153 {
154 printf("Error initializing Efreet\n");
155 continue;
156 }
157
158 num_tests ++;
159
160 printf("%s:\t\t", tests[i].name);
161 fflush(stdout);
162 start = ecore_time_get();
163 ret = tests[i].cb();
164 printf("%s in %.3f seconds\n", (ret ? "PASSED" : "FAILED"),
165 ecore_time_get() - start);
166 passed += ret;
167
168 efreet_shutdown();
169 environment_restore();
170 }
171
172 printf("\n-----------------\n");
173#ifdef HAVE_CLEARENV
174 clearenv();
175 EINA_LIST_FREE(environment, env)
176 free(env);
177#endif
178 printf("Passed %d of %d tests.\n", passed, num_tests);
179
180 while (run)
181 run = eina_list_remove_list(run, run);
182
183 printf("Total run: %.3f seconds\n", ecore_time_get() - total);
184
185 ecore_shutdown();
186 eina_shutdown();
187 return 0;
188}