summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-07-30 15:22:03 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-07-30 15:22:03 -0400
commitd0e10dd2734ce9d1cac6569e4c2c3975dbffcbe8 (patch)
tree2f8937d8f8f04ce48e4c556a9dec6a5f42f55966
parentc594c83a02cdd0000dd7ccefd6761ec613330278 (diff)
ecore: Fix download test.
Summary: After ecore_main_loop_quit() changes, calling it from outside the main loop does not make the next iteration of the main loop quit, causing the original version of the test to deadlock. Also update the function documentation about it. Reviewers: zmike Reviewed By: zmike Subscribers: cedric, #reviewers, felipealmeida, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9448
-rw-r--r--src/lib/ecore/Ecore_Common.h6
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c13
2 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h
index 1530036..8f1a99b 100644
--- a/src/lib/ecore/Ecore_Common.h
+++ b/src/lib/ecore/Ecore_Common.h
@@ -317,8 +317,10 @@ EAPI void ecore_main_loop_begin(void);
317 * Quits the main loop once all the events currently on the queue have 317 * Quits the main loop once all the events currently on the queue have
318 * been processed. 318 * been processed.
319 * 319 *
320 * This function returns immediately, but will mark the ecore_main_loop_begin() 320 * This function returns immediately, but if called inside the main loop
321 * function to return at the end of the current main loop iteration. 321 * it will mark the ecore_main_loop_begin() function to return at the
322 * end of the current main loop iteration.
323 *
322 */ 324 */
323EAPI void ecore_main_loop_quit(void); 325EAPI void ecore_main_loop_quit(void);
324 326
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index fe0e73f..3b6fcff 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -104,9 +104,13 @@ completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status)
104} 104}
105 105
106void 106void
107err_completion_cb(void *data EINA_UNUSED, const char *file EINA_UNUSED, int status) 107err_completion_cb(void *data, const char *file EINA_UNUSED, int status)
108{ 108{
109 if (data)
110 *((int*) data) = status;
109 fail_if(status != 1); 111 fail_if(status != 1);
112 // NOP if called from outside main loop. Keep it here if abort fails and
113 // we get called from there.
110 ecore_main_loop_quit(); 114 ecore_main_loop_quit();
111} 115}
112 116
@@ -521,12 +525,15 @@ EFL_START_TEST(ecore_test_ecore_file_download)
521 progress_cb, NULL, &job); 525 progress_cb, NULL, &job);
522 fail_if(res != EINA_FALSE); 526 fail_if(res != EINA_FALSE);
523 527
528 int status = 0;
524 res = ecore_file_download(download_url, dest_name, err_completion_cb, 529 res = ecore_file_download(download_url, dest_name, err_completion_cb,
525 progress_cb, NULL, &job); 530 progress_cb, &status, &job);
526 fail_if(res != EINA_TRUE); 531 fail_if(res != EINA_TRUE);
527 fail_if(!job); 532 fail_if(!job);
528 ecore_file_download_abort(job); 533 ecore_file_download_abort(job);
529 ecore_main_loop_begin(); 534 fail_if(status != 1);
535 if (!status)
536 ecore_main_loop_begin();
530 if (timeout_reached) goto end; 537 if (timeout_reached) goto end;
531 res = ecore_file_remove(dest_name); 538 res = ecore_file_remove(dest_name);
532 fail_if(res != EINA_TRUE); 539 fail_if(res != EINA_TRUE);