aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
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
parentecore: allow other thread to write local data on a thread to increase utility. (diff)
downloadefl-0fb9af05068d1272e4a5b85d400a0ecb3dc2450d.tar.gz
eio: migrate efl.io.manager.ls to use Eina_Future.
Diffstat (limited to 'src/tests')
-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;
#define DONE_CALLED 0xdeadbeef
static void
+_access_cb(void *data, Eina_Accessor *access)
+{
+ uint64_t *number_of_listed_files = data;
+ Eina_Stringshare *s;
+ unsigned int count;
+
+ EINA_ACCESSOR_FOREACH(access, count, s)
+ {
+ (*number_of_listed_files)++;
+ }
+}
+
+static void
_progress_cb(void *data, const Efl_Event *ev)
{
Efl_Future_Event_Progress *p = ev->info;
@@ -28,6 +41,36 @@ _progress_cb(void *data, const Efl_Event *ev)
(*number_of_listed_files) += eina_array_count(batch);
}
+static Eina_Value
+_future_cb(void *data,
+ const Eina_Value file,
+ const Eina_Future *dead EINA_UNUSED)
+{
+ if (file.type == EINA_VALUE_TYPE_ERROR)
+ {
+ Eina_Error err;
+
+ eina_value_get(&file, &err);
+ fprintf(stderr, "Something has gone wrong: %s\n", eina_error_msg_get(err));
+ abort();
+ }
+ if (file.type == EINA_VALUE_TYPE_UINT64)
+ {
+ uint64_t *number_of_listed_files = data;
+ uint64_t value;
+
+ eina_value_get(&file, &value);
+
+ fail_if((*number_of_listed_files) != test_count);
+ fail_if(value != test_count);
+ *number_of_listed_files = DONE_CALLED;
+ }
+
+ ecore_main_loop_quit();
+
+ return file;
+}
+
static void
_done_cb(void *data, const Efl_Event *ev)
{
@@ -196,7 +239,7 @@ START_TEST(efl_io_manager_test_ls)
Eina_Tmpstr *nested_dirname;
Eina_Tmpstr *nested_filename;
Efl_Io_Manager *job;
- Efl_Future *f;
+ Eina_Future *f;
uint64_t main_files = 0;
int ret;
@@ -217,9 +260,9 @@ START_TEST(efl_io_manager_test_ls)
job = efl_add(EFL_IO_MANAGER_CLASS, ecore_main_loop_get());
fail_if(!job);
- f = efl_io_manager_ls(job, test_dirname);
+ f = efl_io_manager_ls(job, test_dirname, &main_files, _access_cb, NULL);
test_count = 6;
- efl_future_then(f, &_done_cb, &_error_cb, &_progress_cb, &main_files);
+ eina_future_then(f, _future_cb, &main_files);
ecore_main_loop_begin();