Tests: adapt some tests for Exactness

Home directory cannot be used for the tests as the shots will always be
different between machines.
A test directory is created to solve this issue.
This commit is contained in:
Daniel Zaoui 2018-12-05 22:54:38 +02:00
parent ede6c1316b
commit 8ef82132f9
4 changed files with 58 additions and 17 deletions

View File

@ -511,13 +511,33 @@ _edje_filter(const char *path, Eina_Bool dir,
return EINA_FALSE;
}
static void
_create_dir_struct(void)
{
FILE *fp;
if (mkdir("/tmp/test_fs", S_IRWXU) < 0)
printf("make dir /tmp/test_fs failed!\n");
fp = fopen("/tmp/test_fs/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs/m_file.txt", "w");
if (fp) fclose(fp);
if (mkdir("/tmp/test_fs/a_subdir", S_IRWXU) < 0)
printf("make dir /tmp/test_fs/a_subdir failed!\n");
fp = fopen("/tmp/test_fs/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
void
test_fileselector(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *fs, *box, *vbox, *sep;
const char * home_env;
/* Set the locale according to the system pref.
* If you don't do so the file selector will order the files list in
@ -538,6 +558,7 @@ test_fileselector(void *data EINA_UNUSED,
elm_win_resize_object_add(win, box);
evas_object_show(box);
_create_dir_struct(); /* Create a dir struct in /tmp */
fs = elm_fileselector_add(box);
evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
@ -548,9 +569,7 @@ test_fileselector(void *data EINA_UNUSED,
elm_fileselector_is_save_set(fs, EINA_TRUE);
/* make the file list a tree with dir expandable in place */
elm_fileselector_expandable_set(fs, EINA_FALSE);
/* start the fileselector in the home dir */
home_env = eina_environment_home_get();
elm_fileselector_path_set(fs, home_env);
elm_fileselector_path_set(fs, "/tmp/test_fs");
/* provides suggested name (just for showing) */
elm_fileselector_current_name_set(fs, "No name");

View File

@ -65,7 +65,7 @@ _api_bt_clicked(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
}
static void
create_dir_struct(void)
_create_dir_struct(void)
{
FILE *fp;
if (mkdir("/tmp/test_fs_bt", S_IRWXU) < 0)
@ -182,7 +182,7 @@ test_fileselector_button(void *data EINA_UNUSED,
elm_box_pack_end(bxx, vbox);
create_dir_struct(); /* Create a dir struct in /tmp */
_create_dir_struct(); /* Create a dir struct in /tmp */
/* file selector button */
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");

View File

@ -65,25 +65,25 @@ _api_bt_clicked(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
}
static void
create_dir_struct(void)
_create_dir_struct(void)
{
FILE *fp;
int ret = 0;
ret = mkdir("/tmp/test_fs_bt", S_IRWXU);
ret = mkdir("/tmp/test_fs_en", S_IRWXU);
if (ret < 0) return;
fp = fopen("/tmp/test_fs_bt/a_file.txt", "w");
fp = fopen("/tmp/test_fs_en/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/k_file.txt", "w");
fp = fopen("/tmp/test_fs_en/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/m_file.txt", "w");
fp = fopen("/tmp/test_fs_en/m_file.txt", "w");
if (fp) fclose(fp);
ret = mkdir("/tmp/test_fs_bt/a_subdir", S_IRWXU);
ret = mkdir("/tmp/test_fs_en/a_subdir", S_IRWXU);
if (ret < 0) return;
fp = fopen("/tmp/test_fs_bt/a_subdir/d_sub_file.txt", "w");
fp = fopen("/tmp/test_fs_en/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/a_subdir/j_sub_file.txt", "w");
fp = fopen("/tmp/test_fs_en/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
@ -190,14 +190,14 @@ test_fileselector_entry(void *data EINA_UNUSED,
elm_box_pack_end(bxx, vbox);
create_dir_struct(); /* Create a dir struct in /tmp */
_create_dir_struct(); /* Create a dir struct in /tmp */
/* file selector entry */
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
fs_en = elm_fileselector_entry_add(win);
elm_fileselector_path_set(fs_en, "/tmp/test_fs_bt");
elm_fileselector_path_set(fs_en, "/tmp/test_fs_en");
elm_object_text_set(fs_en, "Select a file");
elm_object_part_content_set(fs_en, "button icon", ic);
evas_object_size_hint_weight_set(fs_en, EVAS_HINT_EXPAND, 0.0);

View File

@ -83,6 +83,27 @@ _item_del(void *data, Evas_Object *obj EINA_UNUSED)
eina_stringshare_del(data);
}
static void
_create_dir_struct(void)
{
FILE *fp;
if (mkdir("/tmp/test_panel", S_IRWXU) < 0)
printf("make dir /tmp/test_panel failed!\n");
fp = fopen("/tmp/test_panel/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_panel/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_panel/m_file.txt", "w");
if (fp) fclose(fp);
if (mkdir("/tmp/test_panel/a_subdir", S_IRWXU) < 0)
printf("make dir /tmp/test_panel/a_subdir failed!\n");
fp = fopen("/tmp/test_panel/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_panel/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
static void
_fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
{
@ -95,7 +116,8 @@ _fill_list(Evas_Object *obj, Elm_Genlist_Item_Class *itc)
Eina_Iterator *it;
const char *name;
it = eina_file_ls(eina_environment_home_get());
_create_dir_struct();
it = eina_file_ls("/tmp/test_panel");
EINA_ITERATOR_FOREACH(it, name)
{
if (x >= LIST_ITEM_MAX)