Ecore FIle: Added test case for ecore_file download
Summary: Added test cases for ecore_file_download and ecore_file_download_full Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: devilhorns, stefan_schmidt Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D1683
This commit is contained in:
parent
f6e73c7903
commit
0ba1239ac1
|
@ -86,6 +86,22 @@ file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status)
|
||||
{
|
||||
fprintf(stderr, "Done (status: %d)\n", status);
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
int
|
||||
progress_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED,
|
||||
long int dltotal, long int dlnow,
|
||||
long int ultotal EINA_UNUSED, long int ulnow EINA_UNUSED)
|
||||
{
|
||||
fprintf(stderr, "Progress: %ld/%ld\n", dlnow, dltotal);
|
||||
return ECORE_FILE_PROGRESS_CONTINUE;
|
||||
}
|
||||
|
||||
START_TEST(ecore_test_ecore_file_init)
|
||||
{
|
||||
int ret;
|
||||
|
@ -272,9 +288,56 @@ START_TEST(ecore_test_ecore_file_monitor)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(ecore_test_ecore_file_download)
|
||||
{
|
||||
const char *download_dir;
|
||||
const char *download_file;
|
||||
const char *download_url = "http://check.sourceforge.net/xml/check_unittest.xslt";
|
||||
char dest_name[MAXSIZE] = {'\0'};
|
||||
Eina_Bool res;
|
||||
Eina_Hash *headers;
|
||||
int ret;
|
||||
|
||||
ret = ecore_file_init();
|
||||
fail_if(ret != 1);
|
||||
|
||||
download_dir = get_tmp_dir();
|
||||
fail_if(!download_dir);
|
||||
download_file = ecore_file_file_get(download_url);
|
||||
fail_if(!download_file);
|
||||
strcat(dest_name, download_dir);
|
||||
strcat(dest_name, "/");
|
||||
strcat(dest_name, download_file);
|
||||
res = ecore_file_download(download_url, dest_name, completion_cb,
|
||||
progress_cb, NULL, NULL);
|
||||
fail_if(res != EINA_TRUE);
|
||||
ecore_main_loop_begin();
|
||||
fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
|
||||
res = ecore_file_exists(dest_name);
|
||||
fail_if(res != EINA_TRUE);
|
||||
res = ecore_file_unlink(dest_name);
|
||||
fail_if(res != EINA_TRUE);
|
||||
|
||||
headers = eina_hash_string_small_new(NULL);
|
||||
eina_hash_add(headers, "Content-type", "text/xml");
|
||||
|
||||
res = ecore_file_download_full(download_url, dest_name, completion_cb,
|
||||
progress_cb, NULL, NULL, headers);
|
||||
fail_if(res != EINA_TRUE);
|
||||
ecore_main_loop_begin();
|
||||
fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
|
||||
res = ecore_file_exists(dest_name);
|
||||
fail_if(res != EINA_TRUE);
|
||||
|
||||
ret = ecore_file_shutdown();
|
||||
fail_if(ret != 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void ecore_test_ecore_file(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, ecore_test_ecore_file_init);
|
||||
tcase_add_test(tc, ecore_test_ecore_file_operations);
|
||||
tcase_add_test(tc, ecore_test_ecore_file_monitor);
|
||||
tcase_add_test(tc, ecore_test_ecore_file_download);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue