forked from enlightenment/efl
eio: add a test for T3237.
I have been trying to reproduce the reported ephoto issue, but couldn't. This test case reproduce the reported scenario.
This commit is contained in:
parent
cec3eddb41
commit
351c2007f6
|
@ -242,6 +242,65 @@ START_TEST(eio_test_monitor_directory_file_created_notify)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
struct {
|
||||
Eina_Stringshare *s;
|
||||
Eina_Bool checked;
|
||||
} multi_files[] = {
|
||||
{ NULL, EINA_FALSE },
|
||||
{ NULL, EINA_FALSE },
|
||||
{ NULL, EINA_FALSE },
|
||||
{ NULL, EINA_FALSE }
|
||||
};
|
||||
|
||||
static void
|
||||
_multi_file_created_cb(void *data EINA_UNUSED, int type, void *event)
|
||||
{
|
||||
Eio_Monitor_Event *ev = event;
|
||||
Eina_Bool checked = EINA_TRUE;
|
||||
int i;
|
||||
|
||||
ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_CREATED);
|
||||
|
||||
for (i = 0; multi_files[i].s && strcmp(multi_files[i].s, ev->filename); i++)
|
||||
;
|
||||
|
||||
if (!multi_files[i].s) return ;
|
||||
multi_files[i].checked = EINA_TRUE;
|
||||
|
||||
for (i = 0; multi_files[i].s; i++)
|
||||
checked &= multi_files[i].checked;
|
||||
|
||||
if (!checked) return ;
|
||||
|
||||
_cancel_timeout();
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
START_TEST(eio_test_monitor_directory_multi_file_created_notify)
|
||||
{
|
||||
Eina_Tmpstr *dirname = _common_init();
|
||||
|
||||
multi_files[0].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m1file_created_notify", dirname);
|
||||
multi_files[1].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m2file_created_notify", dirname);
|
||||
multi_files[2].s = eina_stringshare_printf("%s/eio_test_monitor_directory_m3file_created_notify", dirname);
|
||||
|
||||
//sleep to avoid catching event generated by above manipulations
|
||||
usleep(500000);
|
||||
|
||||
//monitor directory
|
||||
eio_monitor_add(dirname);
|
||||
ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, (Ecore_Event_Handler_Cb)_multi_file_created_cb, NULL);
|
||||
|
||||
ecore_timer_add(TEST_OPERATION_DELAY, _create_file, multi_files[0].s);
|
||||
ecore_timer_add(TEST_OPERATION_DELAY, _create_file, multi_files[1].s);
|
||||
ecore_timer_add(TEST_OPERATION_DELAY + TEST_OPERATION_DELAY, _create_file, multi_files[2].s);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
_common_shutdown(dirname);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void _file_deleted_cb(void *data, int type, void *event)
|
||||
{
|
||||
ck_assert_int_eq(type, (int)EIO_MONITOR_FILE_DELETED);
|
||||
|
@ -729,6 +788,7 @@ void eio_test_monitor(TCase *tc)
|
|||
tcase_add_test(tc, eio_test_monitor_add_add_remove_remove);
|
||||
|
||||
tcase_add_test(tc, eio_test_monitor_directory_file_created_notify);
|
||||
tcase_add_test(tc, eio_test_monitor_directory_multi_file_created_notify);
|
||||
tcase_add_test(tc, eio_test_monitor_directory_file_deleted_notify);
|
||||
tcase_add_test(tc, eio_test_monitor_directory_file_modified_notify);
|
||||
#if !defined(_WIN32) && !defined(__MACH__)
|
||||
|
|
Loading…
Reference in New Issue