2014-09-23 12:48:16 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
2011-01-16 11:07:19 -08:00
|
|
|
#include "Efreet.h"
|
2011-04-12 15:41:34 -07:00
|
|
|
/* no logging */
|
|
|
|
#define EFREET_MODULE_LOG_DOM
|
|
|
|
#include "efreet_private.h"
|
2011-01-16 11:07:19 -08:00
|
|
|
#include "Efreet_Mime.h"
|
2011-01-30 02:50:14 -08:00
|
|
|
#include "config.h"
|
2011-01-16 11:07:19 -08:00
|
|
|
#include <Ecore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-04-12 15:41:48 -07:00
|
|
|
int ef_cb_efreet_data_home(void);
|
2011-01-16 11:07:19 -08:00
|
|
|
int ef_cb_efreet_config_home(void);
|
|
|
|
int ef_cb_efreet_cache_home(void);
|
|
|
|
int ef_cb_efreet_data_dirs(void);
|
|
|
|
int ef_cb_efreet_config_dirs(void);
|
|
|
|
int ef_cb_efreet_icon_theme(void);
|
|
|
|
int ef_cb_efreet_icon_theme_list(void);
|
|
|
|
int ef_cb_efreet_icon_match(void);
|
|
|
|
int ef_cb_ini_parse(void);
|
|
|
|
int ef_cb_ini_long_line(void);
|
|
|
|
int ef_cb_ini_garbage(void);
|
|
|
|
int ef_cb_locale(void);
|
|
|
|
int ef_cb_desktop_parse(void);
|
|
|
|
int ef_cb_desktop_save(void);
|
|
|
|
int ef_cb_desktop_command_get(void);
|
|
|
|
int ef_cb_desktop_type_parse(void);
|
|
|
|
#if 0
|
|
|
|
int ef_cb_desktop_file_id(void);
|
|
|
|
#endif
|
|
|
|
int ef_cb_menu_get(void);
|
|
|
|
int ef_cb_menu_with_slashes(void);
|
|
|
|
int ef_cb_menu_save(void);
|
|
|
|
#if 0
|
|
|
|
int ef_cb_menu_edit(void);
|
|
|
|
#endif
|
|
|
|
int ef_cb_utils(void);
|
|
|
|
int ef_mime_cb_get(void);
|
|
|
|
|
|
|
|
typedef struct Efreet_Test Efreet_Test;
|
|
|
|
struct Efreet_Test
|
|
|
|
{
|
2013-01-14 13:04:30 -08:00
|
|
|
char *name;
|
|
|
|
int (*cb)(void);
|
2011-01-16 11:07:19 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
static Efreet_Test tests[] = {
|
2013-01-14 13:04:30 -08:00
|
|
|
{"Data Home", ef_cb_efreet_data_home},
|
|
|
|
{"Config Home", ef_cb_efreet_config_home},
|
|
|
|
{"Cache Home", ef_cb_efreet_cache_home},
|
|
|
|
{"Data Directories", ef_cb_efreet_data_dirs},
|
|
|
|
{"Config Directories", ef_cb_efreet_config_dirs},
|
|
|
|
{"Icon Theme Basic", ef_cb_efreet_icon_theme},
|
|
|
|
{"Icon Theme List", ef_cb_efreet_icon_theme_list},
|
|
|
|
{"Icon Matching", ef_cb_efreet_icon_match},
|
|
|
|
{"INI Parsing", ef_cb_ini_parse},
|
|
|
|
{"INI Long Line Parsing", ef_cb_ini_long_line},
|
|
|
|
{"INI Garbage Parsing", ef_cb_ini_garbage},
|
|
|
|
{"Locale Parsing", ef_cb_locale},
|
|
|
|
{"Desktop Parsing", ef_cb_desktop_parse},
|
|
|
|
{"Desktop Type Parsing", ef_cb_desktop_type_parse},
|
|
|
|
{"Desktop Save", ef_cb_desktop_save},
|
|
|
|
{"Desktop Command", ef_cb_desktop_command_get},
|
2011-01-16 11:07:19 -08:00
|
|
|
#if 0
|
2013-01-14 13:04:30 -08:00
|
|
|
{"Desktop File ID", ef_cb_desktop_file_id},
|
2011-01-16 11:07:19 -08:00
|
|
|
#endif
|
2013-01-14 13:04:30 -08:00
|
|
|
{"Menu Parsing", ef_cb_menu_get},
|
|
|
|
{"Menu Incorrect Names", ef_cb_menu_with_slashes},
|
|
|
|
{"Menu Save", ef_cb_menu_save},
|
2011-01-16 11:07:19 -08:00
|
|
|
#if 0
|
2013-01-14 13:04:30 -08:00
|
|
|
{"Menu Edit", ef_cb_menu_edit},
|
2011-01-16 11:07:19 -08:00
|
|
|
#endif
|
2013-01-14 13:04:30 -08:00
|
|
|
{"Utils", ef_cb_utils},
|
|
|
|
{"Mime", ef_mime_cb_get},
|
|
|
|
{ }
|
2011-01-16 11:07:19 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern char **environ;
|
|
|
|
|
2013-01-08 15:45:48 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-01-16 11:07:19 -08:00
|
|
|
int
|
|
|
|
main(int argc, char ** argv)
|
|
|
|
{
|
2013-01-14 13:04:30 -08:00
|
|
|
int i, passed = 0, num_tests = 0;
|
|
|
|
Eina_List *run = NULL;
|
|
|
|
double total;
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
eina_init();
|
|
|
|
ecore_init();
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
total = ecore_time_get();
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
2011-01-16 11:07:19 -08:00
|
|
|
for (i = 1; i < argc; i++)
|
2013-01-14 13:04:30 -08:00
|
|
|
{
|
|
|
|
if ((!strcmp(argv[i], "-h")) ||
|
|
|
|
(!strcmp(argv[i], "--help")))
|
|
|
|
{
|
|
|
|
for (i = 0; tests[i].name; i++)
|
2011-01-16 11:07:19 -08:00
|
|
|
printf("%s\n", tests[i].name);
|
2013-10-14 04:22:34 -07:00
|
|
|
eina_list_free(run);
|
2013-01-14 13:04:35 -08:00
|
|
|
return 0;
|
2013-01-14 13:04:30 -08:00
|
|
|
}
|
|
|
|
run = eina_list_append(run, argv[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_cache_update = 0;
|
|
|
|
for (i = 0; tests[i].name; i++)
|
|
|
|
{
|
2011-01-16 11:07:19 -08:00
|
|
|
int ret;
|
|
|
|
double start;
|
|
|
|
|
|
|
|
/* we've been given specific tests and it isn't in the list */
|
|
|
|
if (run && !eina_list_search_unsorted(run, EINA_COMPARE_CB(strcasecmp),
|
2013-01-14 13:04:30 -08:00
|
|
|
tests[i].name))
|
|
|
|
continue;
|
2011-01-16 11:07:19 -08:00
|
|
|
|
|
|
|
if (!efreet_init())
|
2013-01-14 13:04:30 -08:00
|
|
|
{
|
|
|
|
printf("Error initializing Efreet\n");
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-16 11:07:19 -08:00
|
|
|
|
|
|
|
num_tests ++;
|
|
|
|
|
2013-01-14 13:04:40 -08:00
|
|
|
printf("Starting \'%s\':\n", tests[i].name);
|
2011-01-16 11:07:19 -08:00
|
|
|
start = ecore_time_get();
|
2013-01-14 13:04:22 -08:00
|
|
|
|
|
|
|
environ = NULL;
|
2011-01-16 11:07:19 -08:00
|
|
|
ret = tests[i].cb();
|
2013-01-14 13:04:22 -08:00
|
|
|
|
2013-01-14 13:04:40 -08:00
|
|
|
printf("FINISHED \'%s\': %s in %.3f seconds\n", tests[i].name,
|
|
|
|
(ret ? "PASSED" : "FAILED"), ecore_time_get() - start);
|
|
|
|
passed += !!ret;
|
2011-01-16 11:07:19 -08:00
|
|
|
|
|
|
|
efreet_shutdown();
|
2013-01-14 13:04:30 -08:00
|
|
|
}
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
printf("\n-----------------\n");
|
|
|
|
printf("Passed %d of %d tests.\n", passed, num_tests);
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
while (run)
|
|
|
|
run = eina_list_remove_list(run, run);
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
printf("Total run: %.3f seconds\n", ecore_time_get() - total);
|
2011-01-16 11:07:19 -08:00
|
|
|
|
2013-01-14 13:04:30 -08:00
|
|
|
ecore_shutdown();
|
|
|
|
eina_shutdown();
|
|
|
|
return 0;
|
2011-01-16 11:07:19 -08:00
|
|
|
}
|