summaryrefslogtreecommitdiff
path: root/src/tests/eio/eio_test_manager.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-04-09 11:52:02 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-01 10:39:01 -0700
commit5b4d64ac13073a2c16fa3d75a009a2d30e449a7b (patch)
treebc802b035836f2d6ef0a6f1107b748fbaff0f0d0 /src/tests/eio/eio_test_manager.c
parent702bcd7de9049776ebf97492775ffe6e35c7caf4 (diff)
eio: migrate tests to use new Efl.Model API.
Diffstat (limited to '')
-rw-r--r--src/tests/eio/eio_test_manager.c73
1 files changed, 41 insertions, 32 deletions
diff --git a/src/tests/eio/eio_test_manager.c b/src/tests/eio/eio_test_manager.c
index a9d5ecc020..3f82af51cf 100644
--- a/src/tests/eio/eio_test_manager.c
+++ b/src/tests/eio/eio_test_manager.c
@@ -19,26 +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) 22_access_cb(void *data, Eina_Array *paths)
23{ 23{
24 uint64_t *number_of_listed_files = data; 24 uint64_t *number_of_listed_files = data;
25 Eina_Stringshare *s;
26 unsigned int count;
27 25
28 EINA_ACCESSOR_FOREACH(access, count, s) 26 *number_of_listed_files += eina_array_count(paths);
29 {
30 (*number_of_listed_files)++;
31 }
32} 27}
33 28
34static void 29static void
35_progress_cb(void *data, const Efl_Event *ev) 30_progress_cb(void *data, Eina_Array *entries)
36{ 31{
37 Efl_Future_Event_Progress *p = ev->info;
38 const Eina_Array *batch = p->progress;
39 uint64_t *number_of_listed_files = data; 32 uint64_t *number_of_listed_files = data;
40 33
41 (*number_of_listed_files) += eina_array_count(batch); 34 (*number_of_listed_files) += eina_array_count(entries);
42} 35}
43 36
44static Eina_Value 37static Eina_Value
@@ -71,27 +64,42 @@ _future_cb(void *data,
71 return file; 64 return file;
72} 65}
73 66
74static void 67static Eina_Value
75_done_cb(void *data, const Efl_Event *ev) 68_done_cb(void *data,
69 const Eina_Value file,
70 const Eina_Future *dead EINA_UNUSED)
76{ 71{
77 Efl_Future_Event_Success *success = ev->info;
78 uint64_t *files_count = success->value;
79 uint64_t *number_of_listed_files = data; 72 uint64_t *number_of_listed_files = data;
80 73
81 fail_if((*number_of_listed_files) != test_count); 74 if (eina_value_type_get(&file) == EINA_VALUE_TYPE_ERROR)
82 fail_if(*files_count != test_count); 75 {
83 *number_of_listed_files = DONE_CALLED; 76 Eina_Error err = 0;
84 ecore_main_loop_quit(); 77 const char *msg;
85}
86 78
87static void 79 eina_value_error_get(&file, &err);
88_error_cb(void *data EINA_UNUSED, const Efl_Event *ev) 80 msg = eina_error_msg_get(err);
89{ 81
90 Efl_Future_Event_Failure *failure = ev->info; 82 EINA_LOG_ERR("error: %s", msg);
91 const char *msg = eina_error_msg_get(failure->error); 83 abort();
84 }
85 else
86 {
87 Eina_Value convert = EINA_VALUE_EMPTY;
88 uint64_t files_count = 0;
89
90 eina_value_setup(&convert, EINA_VALUE_TYPE_ULONG);
91 eina_value_convert(&file, &convert);
92 eina_value_ulong_get(&convert, &files_count);
93
94 fail_if((*number_of_listed_files) != test_count);
95 fail_if(files_count != test_count);
96
97 *number_of_listed_files = DONE_CALLED;
98 }
92 99
93 EINA_LOG_ERR("error: %s", msg);
94 ecore_main_loop_quit(); 100 ecore_main_loop_quit();
101
102 return file;
95} 103}
96 104
97static Eina_Value 105static Eina_Value
@@ -152,29 +160,30 @@ _stat_done_cb(void *data,
152} 160}
153 161
154static void 162static void
155_test_ls(Efl_Future *(*func)(Eo *obj, const char *path, Eina_Bool recursive), 163_test_ls(Eina_Future *(*func)(Eo *obj, const char *path, Eina_Bool recursive,
164 void *info_data, EflIoDirectInfo info, Eina_Free_Cb info_free_cb),
156 uint64_t expected_test_count, 165 uint64_t expected_test_count,
157 const char* test_dirname) 166 const char* test_dirname)
158{ 167{
159 Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, efl_main_loop_get()); 168 Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, efl_main_loop_get());
160 Efl_Future *f = NULL; 169 Eina_Future *f = NULL;
161 uint64_t main_files = 0; 170 uint64_t main_files = 0;
162 171
163 fail_if(!job); 172 fail_if(!job);
164 173
165 f = func(job, test_dirname, EINA_FALSE); 174 f = func(job, test_dirname, EINA_FALSE, &main_files, _progress_cb, NULL);
166 fail_if(!f); 175 fail_if(!f);
167 test_count = expected_test_count; 176 test_count = expected_test_count;
168 efl_future_then(f, &_done_cb, &_error_cb, &_progress_cb, &main_files); 177 eina_future_then(f, &_done_cb, &main_files);
169 178
170 ecore_main_loop_begin(); 179 ecore_main_loop_begin();
171 180
172 fail_if(main_files != DONE_CALLED); 181 fail_if(main_files != DONE_CALLED);
173 main_files = 0; 182 main_files = 0;
174 183
175 f = func(job, test_dirname, EINA_TRUE); 184 f = func(job, test_dirname, EINA_TRUE, &main_files, _progress_cb, NULL);
176 test_count = expected_test_count + 4; 185 test_count = expected_test_count + 4;
177 efl_future_then(f, &_done_cb, &_error_cb, &_progress_cb, &main_files); 186 eina_future_then(f, &_done_cb, &main_files);
178 187
179 ecore_main_loop_begin(); 188 ecore_main_loop_begin();
180 189