summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkabeer khan <kabeer.khan@samsung.com>2014-11-24 09:35:48 -0500
committerChris Michael <cp.michael@samsung.com>2014-11-24 09:36:02 -0500
commit0ba1239ac1b3184a546bc90b6753b66e6dc9374e (patch)
tree79194abe20f60e98c4c1bf5819f3b87321222c65
parentf6e73c79039f1cb0a8b334dad299eaec607f4b82 (diff)
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
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index d850e1c030..515ff54b59 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -86,6 +86,22 @@ file_monitor_cb(void *data EINA_UNUSED, Ecore_File_Monitor *em EINA_UNUSED,
86 } 86 }
87} 87}
88 88
89void
90completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status)
91{
92 fprintf(stderr, "Done (status: %d)\n", status);
93 ecore_main_loop_quit();
94}
95
96int
97progress_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED,
98 long int dltotal, long int dlnow,
99 long int ultotal EINA_UNUSED, long int ulnow EINA_UNUSED)
100{
101 fprintf(stderr, "Progress: %ld/%ld\n", dlnow, dltotal);
102 return ECORE_FILE_PROGRESS_CONTINUE;
103}
104
89START_TEST(ecore_test_ecore_file_init) 105START_TEST(ecore_test_ecore_file_init)
90{ 106{
91 int ret; 107 int ret;
@@ -272,9 +288,56 @@ START_TEST(ecore_test_ecore_file_monitor)
272} 288}
273END_TEST 289END_TEST
274 290
291START_TEST(ecore_test_ecore_file_download)
292{
293 const char *download_dir;
294 const char *download_file;
295 const char *download_url = "http://check.sourceforge.net/xml/check_unittest.xslt";
296 char dest_name[MAXSIZE] = {'\0'};
297 Eina_Bool res;
298 Eina_Hash *headers;
299 int ret;
300
301 ret = ecore_file_init();
302 fail_if(ret != 1);
303
304 download_dir = get_tmp_dir();
305 fail_if(!download_dir);
306 download_file = ecore_file_file_get(download_url);
307 fail_if(!download_file);
308 strcat(dest_name, download_dir);
309 strcat(dest_name, "/");
310 strcat(dest_name, download_file);
311 res = ecore_file_download(download_url, dest_name, completion_cb,
312 progress_cb, NULL, NULL);
313 fail_if(res != EINA_TRUE);
314 ecore_main_loop_begin();
315 fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
316 res = ecore_file_exists(dest_name);
317 fail_if(res != EINA_TRUE);
318 res = ecore_file_unlink(dest_name);
319 fail_if(res != EINA_TRUE);
320
321 headers = eina_hash_string_small_new(NULL);
322 eina_hash_add(headers, "Content-type", "text/xml");
323
324 res = ecore_file_download_full(download_url, dest_name, completion_cb,
325 progress_cb, NULL, NULL, headers);
326 fail_if(res != EINA_TRUE);
327 ecore_main_loop_begin();
328 fprintf(stderr, "Downloaded %lld bytes\n", ecore_file_size(dest_name));
329 res = ecore_file_exists(dest_name);
330 fail_if(res != EINA_TRUE);
331
332 ret = ecore_file_shutdown();
333 fail_if(ret != 0);
334}
335END_TEST
336
275void ecore_test_ecore_file(TCase *tc) 337void ecore_test_ecore_file(TCase *tc)
276{ 338{
277 tcase_add_test(tc, ecore_test_ecore_file_init); 339 tcase_add_test(tc, ecore_test_ecore_file_init);
278 tcase_add_test(tc, ecore_test_ecore_file_operations); 340 tcase_add_test(tc, ecore_test_ecore_file_operations);
279 tcase_add_test(tc, ecore_test_ecore_file_monitor); 341 tcase_add_test(tc, ecore_test_ecore_file_monitor);
342 tcase_add_test(tc, ecore_test_ecore_file_download);
280} 343}