summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-28 18:18:38 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-28 18:31:34 -0700
commit0fb9af05068d1272e4a5b85d400a0ecb3dc2450d (patch)
tree3772952ed5a5727242ae6e6bfe6ebafe4568aa6a /src/tests/eio
parentab1080bdd36c1f80a287015dc50f81f3456321ad (diff)
eio: migrate efl.io.manager.ls to use Eina_Future.
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/eio_test_manager.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/tests/eio/eio_test_manager.c b/src/tests/eio/eio_test_manager.c
index 8224af207a..4fa1767ed2 100644
--- a/src/tests/eio/eio_test_manager.c
+++ b/src/tests/eio/eio_test_manager.c
@@ -19,6 +19,19 @@ static Eina_Bool direct = EINA_FALSE;
19#define DONE_CALLED 0xdeadbeef 19#define DONE_CALLED 0xdeadbeef
20 20
21static void 21static void
22_access_cb(void *data, Eina_Accessor *access)
23{
24 uint64_t *number_of_listed_files = data;
25 Eina_Stringshare *s;
26 unsigned int count;
27
28 EINA_ACCESSOR_FOREACH(access, count, s)
29 {
30 (*number_of_listed_files)++;
31 }
32}
33
34static void
22_progress_cb(void *data, const Efl_Event *ev) 35_progress_cb(void *data, const Efl_Event *ev)
23{ 36{
24 Efl_Future_Event_Progress *p = ev->info; 37 Efl_Future_Event_Progress *p = ev->info;
@@ -28,6 +41,36 @@ _progress_cb(void *data, const Efl_Event *ev)
28 (*number_of_listed_files) += eina_array_count(batch); 41 (*number_of_listed_files) += eina_array_count(batch);
29} 42}
30 43
44static Eina_Value
45_future_cb(void *data,
46 const Eina_Value file,
47 const Eina_Future *dead EINA_UNUSED)
48{
49 if (file.type == EINA_VALUE_TYPE_ERROR)
50 {
51 Eina_Error err;
52
53 eina_value_get(&file, &err);
54 fprintf(stderr, "Something has gone wrong: %s\n", eina_error_msg_get(err));
55 abort();
56 }
57 if (file.type == EINA_VALUE_TYPE_UINT64)
58 {
59 uint64_t *number_of_listed_files = data;
60 uint64_t value;
61
62 eina_value_get(&file, &value);
63
64 fail_if((*number_of_listed_files) != test_count);
65 fail_if(value != test_count);
66 *number_of_listed_files = DONE_CALLED;
67 }
68
69 ecore_main_loop_quit();
70
71 return file;
72}
73
31static void 74static void
32_done_cb(void *data, const Efl_Event *ev) 75_done_cb(void *data, const Efl_Event *ev)
33{ 76{
@@ -196,7 +239,7 @@ START_TEST(efl_io_manager_test_ls)
196 Eina_Tmpstr *nested_dirname; 239 Eina_Tmpstr *nested_dirname;
197 Eina_Tmpstr *nested_filename; 240 Eina_Tmpstr *nested_filename;
198 Efl_Io_Manager *job; 241 Efl_Io_Manager *job;
199 Efl_Future *f; 242 Eina_Future *f;
200 uint64_t main_files = 0; 243 uint64_t main_files = 0;
201 int ret; 244 int ret;
202 245
@@ -217,9 +260,9 @@ START_TEST(efl_io_manager_test_ls)
217 job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get()); 260 job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get());
218 fail_if(!job); 261 fail_if(!job);
219 262
220 f = efl_io_manager_ls(job, test_dirname); 263 f = efl_io_manager_ls(job, test_dirname, &main_files, _access_cb, NULL);
221 test_count = 6; 264 test_count = 6;
222 efl_future_then(f, &_done_cb, &_error_cb, &_progress_cb, &main_files); 265 eina_future_then(f, _future_cb, &main_files);
223 266
224 ecore_main_loop_begin(); 267 ecore_main_loop_begin();
225 268