summaryrefslogtreecommitdiff
path: root/src/tests/ecore
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-04-11 10:38:21 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-24 16:02:17 -0700
commitccb5642eb9c122deac271da5f8b1353f46d73160 (patch)
tree9a0a93692425677f4853a6f1b8dadd6ee430c5ec /src/tests/ecore
parent36f8a70041a8a16249a07d5b7131d57a8a6ea95b (diff)
Revert "efl_add_ref - fis to use efl_add properly with a parent."
This reverts commit 2fb5cc3ad09f6aaf82b5d1131ac5ed22ed848bd4. Most of this change where wrong as they didn't affect the destruction of the object. efl_add_ref allow for manual handling of the lifecycle of the object and make sure it is still alive during destructor. efl_add will not allow you to access an object after invalidate also efl.parent.get will always return NULL once the object is invalidated. Differential Revision: https://phab.enlightenment.org/D6062
Diffstat (limited to 'src/tests/ecore')
-rw-r--r--src/tests/ecore/ecore_test_ecore_audio.c61
-rw-r--r--src/tests/ecore/efl_app_test_promise.c4
2 files changed, 32 insertions, 33 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c
index 69bbaf66ed..0537014631 100644
--- a/src/tests/ecore/ecore_test_ecore_audio.c
+++ b/src/tests/ecore/ecore_test_ecore_audio.c
@@ -57,14 +57,14 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_pulse)
57 Eina_Bool ret = EINA_FALSE; 57 Eina_Bool ret = EINA_FALSE;
58 Eina_Bool pulse_context_failed = EINA_FALSE; 58 Eina_Bool pulse_context_failed = EINA_FALSE;
59 59
60 in = efl_add(ECORE_AUDIO_IN_SNDFILE_CLASS, efl_main_loop_get()); 60 in = efl_add_ref(ECORE_AUDIO_IN_SNDFILE_CLASS, NULL);
61 fail_if(!in); 61 fail_if(!in);
62 62
63 efl_name_set(in, "sample.wav"); 63 efl_name_set(in, "sample.wav");
64 ret = ecore_audio_obj_source_set(in, TESTS_SRC_DIR"/sample.wav"); 64 ret = ecore_audio_obj_source_set(in, TESTS_SRC_DIR"/sample.wav");
65 fail_if(!ret); 65 fail_if(!ret);
66 66
67 out = efl_add(ECORE_AUDIO_OUT_PULSE_CLASS, efl_main_loop_get()); 67 out = efl_add_ref(ECORE_AUDIO_OUT_PULSE_CLASS, NULL);
68 fail_if(!out); 68 fail_if(!out);
69 69
70 ecore_timer_add(1.8, _seek_vol, in); 70 ecore_timer_add(1.8, _seek_vol, in);
@@ -78,8 +78,8 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_pulse)
78 ecore_main_loop_begin(); 78 ecore_main_loop_begin();
79 fail_if(pulse_context_failed); 79 fail_if(pulse_context_failed);
80 80
81 efl_del(out); 81 efl_unref(out);
82 efl_del(in); 82 efl_unref(in);
83} 83}
84EFL_END_TEST 84EFL_END_TEST
85#endif 85#endif
@@ -96,7 +96,7 @@ static Eina_Bool
96_idle_del(void *data) 96_idle_del(void *data)
97{ 97{
98 Eo *in = data; 98 Eo *in = data;
99 efl_del(in); 99 efl_unref(in);
100 ecore_idler_add(_quit, NULL); 100 ecore_idler_add(_quit, NULL);
101 101
102 return EINA_FALSE; 102 return EINA_FALSE;
@@ -108,12 +108,12 @@ EFL_START_TEST(ecore_test_ecore_audio_cleanup)
108 int freq = 1000; 108 int freq = 1000;
109 Eina_Bool ret = EINA_FALSE; 109 Eina_Bool ret = EINA_FALSE;
110 110
111 in = efl_add(ECORE_AUDIO_IN_TONE_CLASS, efl_main_loop_get()); 111 in = efl_add_ref(ECORE_AUDIO_IN_TONE_CLASS, NULL);
112 fail_if(!in); 112 fail_if(!in);
113 efl_key_data_set(in, ECORE_AUDIO_ATTR_TONE_FREQ, &freq); 113 efl_key_data_set(in, ECORE_AUDIO_ATTR_TONE_FREQ, &freq);
114 ecore_audio_obj_in_length_set(in, 2); 114 ecore_audio_obj_in_length_set(in, 2);
115 115
116 out = efl_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, efl_main_loop_get()); 116 out = efl_add_ref(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
117 fail_if(!out); 117 fail_if(!out);
118 ret = ecore_audio_obj_format_set(out, ECORE_AUDIO_FORMAT_OGG); 118 ret = ecore_audio_obj_format_set(out, ECORE_AUDIO_FORMAT_OGG);
119 fail_if(!ret); 119 fail_if(!ret);
@@ -124,7 +124,6 @@ EFL_START_TEST(ecore_test_ecore_audio_cleanup)
124 fail_if(!ret); 124 fail_if(!ret);
125 125
126 ecore_idler_add(_idle_del, in); 126 ecore_idler_add(_idle_del, in);
127 ecore_idler_add(_idle_del, out);
128 127
129 ecore_main_loop_begin(); 128 ecore_main_loop_begin();
130 129
@@ -140,7 +139,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_tone)
140 Eina_Bool ret; 139 Eina_Bool ret;
141 char *tmp; 140 char *tmp;
142 141
143 in = efl_add(ECORE_AUDIO_IN_TONE_CLASS, efl_main_loop_get()); 142 in = efl_add_ref(ECORE_AUDIO_IN_TONE_CLASS, NULL);
144 fail_if(!in); 143 fail_if(!in);
145 144
146 efl_name_set(in, "tone"); 145 efl_name_set(in, "tone");
@@ -198,7 +197,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_tone)
198 len = ecore_audio_obj_in_remaining_get(in); 197 len = ecore_audio_obj_in_remaining_get(in);
199 fail_if(len != 1.0); 198 fail_if(len != 1.0);
200 199
201 out = efl_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, efl_main_loop_get()); 200 out = efl_add_ref(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
202 fail_if(!out); 201 fail_if(!out);
203 202
204 efl_name_set(out, "tmp.wav"); 203 efl_name_set(out, "tmp.wav");
@@ -215,8 +214,8 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_tone)
215 214
216 ecore_main_loop_begin(); 215 ecore_main_loop_begin();
217 216
218 efl_del(in); 217 efl_unref(in);
219 efl_del(out); 218 efl_unref(out);
220 219
221 //TODO: Compare and fail 220 //TODO: Compare and fail
222 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav"); 221 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav");
@@ -232,7 +231,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_sndfile)
232 Ecore_Audio_Format fmt; 231 Ecore_Audio_Format fmt;
233 const char *src; 232 const char *src;
234 233
235 in = efl_add(ECORE_AUDIO_IN_SNDFILE_CLASS, efl_main_loop_get()); 234 in = efl_add_ref(ECORE_AUDIO_IN_SNDFILE_CLASS, NULL);
236 fail_if(!in); 235 fail_if(!in);
237 236
238 fmt = ecore_audio_obj_format_get(in); 237 fmt = ecore_audio_obj_format_get(in);
@@ -278,7 +277,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_sndfile)
278 len = ecore_audio_obj_in_seek(in, -1.5, SEEK_END); 277 len = ecore_audio_obj_in_seek(in, -1.5, SEEK_END);
279 fail_if(fabs(rem - 1 - len) > 0.6); 278 fail_if(fabs(rem - 1 - len) > 0.6);
280 279
281 out = efl_add(ECORE_AUDIO_OUT_SNDFILE_CLASS, efl_main_loop_get()); 280 out = efl_add_ref(ECORE_AUDIO_OUT_SNDFILE_CLASS, NULL);
282 fail_if(!out); 281 fail_if(!out);
283 282
284 efl_name_set(out, "tmp.wav"); 283 efl_name_set(out, "tmp.wav");
@@ -305,8 +304,8 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_sndfile)
305 304
306 ecore_main_loop_begin(); 305 ecore_main_loop_begin();
307 306
308 efl_del(in); 307 efl_unref(in);
309 efl_del(out); 308 efl_unref(out);
310 309
311 //TODO: Compare and fail 310 //TODO: Compare and fail
312 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav"); 311 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav");
@@ -319,9 +318,9 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_in_out)
319 Eina_List *in3; 318 Eina_List *in3;
320 Eina_Bool attached; 319 Eina_Bool attached;
321 320
322 Eo *in = efl_add(ECORE_AUDIO_IN_CLASS, efl_main_loop_get()); 321 Eo *in = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
323 Eo *in2 = efl_add(ECORE_AUDIO_IN_CLASS, efl_main_loop_get()); 322 Eo *in2 = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
324 Eo *out = efl_add(ECORE_AUDIO_OUT_CLASS, efl_main_loop_get()); 323 Eo *out = efl_add_ref(ECORE_AUDIO_OUT_CLASS, NULL);
325 324
326 fail_if(!in); 325 fail_if(!in);
327 fail_if(!in2); 326 fail_if(!in2);
@@ -358,20 +357,20 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_in_out)
358 fail_if(eina_list_count(in3) != 2); 357 fail_if(eina_list_count(in3) != 2);
359 fail_if(eina_list_data_get(in3) != in); 358 fail_if(eina_list_data_get(in3) != in);
360 359
361 efl_del(in2); 360 efl_unref(in2);
362 361
363 in3 = ecore_audio_obj_out_inputs_get(out); 362 in3 = ecore_audio_obj_out_inputs_get(out);
364 363
365 fail_if(eina_list_count(in3) != 1); 364 fail_if(eina_list_count(in3) != 1);
366 fail_if(eina_list_data_get(in3) != in); 365 fail_if(eina_list_data_get(in3) != in);
367 366
368 efl_del(out); 367 efl_unref(out);
369 368
370 out2 = ecore_audio_obj_in_output_get(in); 369 out2 = ecore_audio_obj_in_output_get(in);
371 370
372 fail_if(out2); 371 fail_if(out2);
373 372
374 efl_del(in); 373 efl_unref(in);
375} 374}
376EFL_END_TEST 375EFL_END_TEST
377 376
@@ -417,10 +416,10 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_vio)
417{ 416{
418 Eo *in, *out; 417 Eo *in, *out;
419 418
420 in = efl_add(ECORE_AUDIO_IN_CLASS, efl_main_loop_get()); 419 in = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
421 fail_if(!in); 420 fail_if(!in);
422 421
423 out = efl_add(ECORE_AUDIO_OUT_CLASS, efl_main_loop_get()); 422 out = efl_add_ref(ECORE_AUDIO_OUT_CLASS, NULL);
424 fail_if(!out); 423 fail_if(!out);
425 424
426 ecore_audio_obj_vio_set(in, &in_vio, NULL, NULL); 425 ecore_audio_obj_vio_set(in, &in_vio, NULL, NULL);
@@ -430,8 +429,8 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_vio)
430 429
431 ecore_main_loop_begin(); 430 ecore_main_loop_begin();
432 431
433 efl_del(out); 432 efl_unref(out);
434 efl_del(in); 433 efl_unref(in);
435} 434}
436EFL_END_TEST 435EFL_END_TEST
437 436
@@ -455,7 +454,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_in)
455 Ecore_Audio_Vio vio; 454 Ecore_Audio_Vio vio;
456 Eina_Bool freed = EINA_FALSE; 455 Eina_Bool freed = EINA_FALSE;
457 456
458 Eo *in = efl_add(ECORE_AUDIO_IN_CLASS, efl_main_loop_get()); 457 Eo *in = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
459 458
460 fail_if(!in); 459 fail_if(!in);
461 460
@@ -530,7 +529,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj_in)
530 fail_if(buf[i] != 0x00); 529 fail_if(buf[i] != 0x00);
531 } 530 }
532 531
533 efl_del(in); 532 efl_unref(in);
534} 533}
535EFL_END_TEST 534EFL_END_TEST
536 535
@@ -542,10 +541,10 @@ EFL_START_TEST(ecore_test_ecore_audio_obj)
542 double volume; 541 double volume;
543 Eo *objs[2], *obj; 542 Eo *objs[2], *obj;
544 543
545 objs[0] = efl_add(ECORE_AUDIO_IN_CLASS, efl_main_loop_get()); 544 objs[0] = efl_add_ref(ECORE_AUDIO_IN_CLASS, NULL);
546 fail_if(!objs[0]); 545 fail_if(!objs[0]);
547 546
548 objs[1] = efl_add(ECORE_AUDIO_OUT_CLASS, efl_main_loop_get()); 547 objs[1] = efl_add_ref(ECORE_AUDIO_OUT_CLASS, NULL);
549 fail_if(!objs[1]); 548 fail_if(!objs[1]);
550 549
551 for (i=0; i<2; i++) { 550 for (i=0; i<2; i++) {
@@ -578,7 +577,7 @@ EFL_START_TEST(ecore_test_ecore_audio_obj)
578 volume = ecore_audio_obj_volume_get(obj); 577 volume = ecore_audio_obj_volume_get(obj);
579 fail_if(volume != 0.5); 578 fail_if(volume != 0.5);
580 579
581 efl_del(obj); 580 efl_unref(obj);
582 } 581 }
583 582
584} 583}
diff --git a/src/tests/ecore/efl_app_test_promise.c b/src/tests/ecore/efl_app_test_promise.c
index 3b9b8ab6aa..fde88793b4 100644
--- a/src/tests/ecore/efl_app_test_promise.c
+++ b/src/tests/ecore/efl_app_test_promise.c
@@ -872,7 +872,7 @@ EFL_START_TEST(efl_test_promise_eo)
872 fail_if(!ecore_init()); 872 fail_if(!ecore_init());
873 873
874 //Use a random object.. 874 //Use a random object..
875 obj = efl_add(EFL_IO_BUFFER_CLASS, efl_main_loop_get()); 875 obj = efl_add_ref(EFL_IO_BUFFER_CLASS, NULL);
876 fail_if(!obj); 876 fail_if(!obj);
877 efl_key_data_set(obj, "free_called", &free_called); 877 efl_key_data_set(obj, "free_called", &free_called);
878 f = eina_future_chain(_int_future_get(), 878 f = eina_future_chain(_int_future_get(),
@@ -931,7 +931,7 @@ EFL_START_TEST(efl_test_promise_eo_link)
931 fail_if(!ecore_init()); 931 fail_if(!ecore_init());
932 932
933 //Use a random object.. 933 //Use a random object..
934 obj = efl_add(EFL_IO_BUFFER_CLASS, efl_main_loop_get()); 934 obj = efl_add_ref(EFL_IO_BUFFER_CLASS, NULL);
935 fail_if(!obj); 935 fail_if(!obj);
936 936
937 efl_key_data_set(obj, "err_called", &err_called); 937 efl_key_data_set(obj, "err_called", &err_called);