devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0ba1239ac1b3184a546bc90b6753b66e6dc9374e

commit 0ba1239ac1b3184a546bc90b6753b66e6dc9374e
Author: kabeer khan <[email protected]>
Date:   Mon Nov 24 09:35:48 2014 -0500

    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 <[email protected]>
    
    Reviewers: devilhorns, stefan_schmidt
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D1683
---
 src/tests/ecore/ecore_test_ecore_file.c | 63 +++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/src/tests/ecore/ecore_test_ecore_file.c 
b/src/tests/ecore/ecore_test_ecore_file.c
index d850e1c..515ff54 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,
      }
 }
 
+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);
 }

-- 


Reply via email to