2015-04-05 06:19:45 -07:00
|
|
|
//Compile with:
|
|
|
|
// gcc -o emodel_test_file emodel_test_file.c `pkg-config --cflags --libs emodel`
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Eo.h>
|
2016-04-20 13:07:53 -07:00
|
|
|
#include <Eio.h>
|
2015-04-05 06:19:45 -07:00
|
|
|
#include <Ecore.h>
|
2015-04-05 06:19:59 -07:00
|
|
|
#include <Efl.h>
|
2016-04-20 13:07:53 -07:00
|
|
|
#include <stdio.h>
|
2015-04-05 06:19:45 -07:00
|
|
|
|
2018-03-26 11:19:28 -07:00
|
|
|
#include "eio_suite.h"
|
2015-04-05 06:19:45 -07:00
|
|
|
|
2015-04-09 18:46:24 -07:00
|
|
|
Eina_Tmpstr* temp_filename = NULL;
|
|
|
|
const char* tmpdir = NULL;
|
2016-04-20 13:07:53 -07:00
|
|
|
Eina_Bool children_deleted = EINA_FALSE;
|
2015-04-05 06:19:45 -07:00
|
|
|
|
2019-02-23 05:57:19 -08:00
|
|
|
// This will ensure that the child have the time to be automatically destroyed
|
|
|
|
static Eina_Value
|
|
|
|
_delayed_quit(Eo *o EINA_UNUSED, void *data EINA_UNUSED, const Eina_Value v)
|
|
|
|
{
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Value
|
|
|
|
_children_got(Eo *o, void *data EINA_UNUSED, const Eina_Value v)
|
|
|
|
{
|
|
|
|
Eo *child = NULL;
|
|
|
|
unsigned int i, len;
|
|
|
|
Eina_Value r = (Eina_Value) v;
|
|
|
|
|
|
|
|
EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
|
|
|
|
{
|
|
|
|
Eina_Value *path;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
path = efl_model_property_get(child, "path");
|
|
|
|
fail_if(path == NULL);
|
|
|
|
str = eina_value_to_string(path);
|
|
|
|
fail_if(str == NULL);
|
|
|
|
|
|
|
|
if (temp_filename && strcmp(str, temp_filename) == 0)
|
|
|
|
r = eina_future_as_value(efl_future_then(efl_loop_get(o),
|
|
|
|
efl_loop_job(efl_loop_get(o)),
|
|
|
|
.success = _delayed_quit));
|
|
|
|
|
|
|
|
|
|
|
|
free(str);
|
|
|
|
eina_value_free(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Value
|
|
|
|
_children_failed(Eo *o EINA_UNUSED, void *data EINA_UNUSED, const Eina_Error err)
|
|
|
|
{
|
2019-04-23 09:56:09 -07:00
|
|
|
if (err != ECANCELED)
|
|
|
|
ck_abort_msg( "Failed to get the child with '%s'.\n", eina_error_msg_get(err));
|
2019-02-23 05:57:19 -08:00
|
|
|
return eina_value_error_init(err);
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event)
|
2015-04-05 06:19:55 -07:00
|
|
|
{
|
2018-04-09 11:52:02 -07:00
|
|
|
Efl_Model_Children_Event* evt = event->info;
|
|
|
|
Eina_Value *path;
|
|
|
|
char *str;
|
2015-04-05 06:19:55 -07:00
|
|
|
|
2019-02-23 05:57:19 -08:00
|
|
|
if (!evt->child)
|
|
|
|
{
|
|
|
|
Eina_Future *f;
|
|
|
|
|
|
|
|
// Last time we can fetch the object
|
|
|
|
f = efl_future_then(event->object,
|
|
|
|
efl_model_children_slice_get(event->object, evt->index, 1),
|
|
|
|
.success = _children_got,
|
|
|
|
.error = _children_failed,
|
|
|
|
.success_type = EINA_VALUE_TYPE_ARRAY);
|
|
|
|
fail_if(f == NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
fail_if(evt->child == NULL);
|
|
|
|
path = efl_model_property_get(evt->child, "path");
|
|
|
|
fail_if(path == NULL);
|
|
|
|
str = eina_value_to_string(path);
|
|
|
|
fail_if(str == NULL);
|
2015-04-05 06:19:55 -07:00
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
if (temp_filename && strcmp(str, temp_filename) == 0)
|
2019-02-23 05:57:19 -08:00
|
|
|
efl_future_then(efl_loop_get(evt->child),
|
|
|
|
efl_loop_job(efl_loop_get(evt->child)),
|
|
|
|
.success = _delayed_quit);
|
2015-04-05 06:19:45 -07:00
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
free(str);
|
|
|
|
eina_value_free(path);
|
|
|
|
}
|
2016-09-29 09:12:09 -07:00
|
|
|
|
2018-12-04 07:14:25 -08:00
|
|
|
static Eina_Bool started_up = EINA_FALSE;
|
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
static Eina_Value
|
|
|
|
_children_get(void *data,
|
|
|
|
const Eina_Value v,
|
|
|
|
const Eina_Future *dead_future EINA_UNUSED)
|
2016-09-29 09:12:09 -07:00
|
|
|
{
|
2018-04-09 11:52:02 -07:00
|
|
|
Efl_Model *filemodel = data;
|
|
|
|
Eo *child = NULL;
|
|
|
|
unsigned int i, len;
|
2016-04-20 13:07:53 -07:00
|
|
|
|
2019-04-02 15:24:03 -07:00
|
|
|
if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR)
|
|
|
|
{
|
|
|
|
Eina_Error err = 0;
|
|
|
|
|
|
|
|
fail_if(!eina_value_error_get(&v, &err));
|
|
|
|
fail_if(err != ECANCELED);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
|
2016-04-20 13:07:53 -07:00
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
|
2015-04-05 06:19:45 -07:00
|
|
|
{
|
2018-04-09 11:52:02 -07:00
|
|
|
Eina_Value *path;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
path = efl_model_property_get(child, "path");
|
|
|
|
fail_if(path == NULL);
|
|
|
|
str = eina_value_to_string(path);
|
|
|
|
fail_if(str == NULL);
|
|
|
|
|
2018-12-04 07:14:25 -08:00
|
|
|
if (started_up && strcmp(temp_filename, str) == 0)
|
2018-04-09 11:52:02 -07:00
|
|
|
{
|
|
|
|
children_deleted = EINA_TRUE;
|
|
|
|
efl_model_child_del(filemodel, child);
|
|
|
|
}
|
|
|
|
free(str);
|
|
|
|
eina_value_free(path);
|
2015-04-05 06:19:45 -07:00
|
|
|
}
|
2018-04-09 11:52:02 -07:00
|
|
|
|
2018-12-04 07:14:25 -08:00
|
|
|
if (!started_up)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
2019-08-23 10:22:11 -07:00
|
|
|
fd = eina_file_mkstemp("prefixXXXXXX.ext", &temp_filename);
|
|
|
|
ck_assert_int_gt(fd, 0);
|
|
|
|
close(fd);
|
2018-12-04 07:14:25 -08:00
|
|
|
}
|
|
|
|
started_up = EINA_TRUE;
|
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
return v;
|
2016-09-29 09:12:09 -07:00
|
|
|
}
|
2016-05-03 14:19:26 -07:00
|
|
|
|
2016-09-29 09:12:09 -07:00
|
|
|
static void
|
|
|
|
_children_added_cb(void *d EINA_UNUSED, const Efl_Event* event)
|
|
|
|
{
|
|
|
|
Efl_Model_Children_Event* evt = event->info;
|
2018-04-09 11:52:02 -07:00
|
|
|
Eina_Future *future;
|
|
|
|
|
|
|
|
future = efl_model_children_slice_get(event->object, evt->index, 1);
|
2018-11-07 06:52:41 -08:00
|
|
|
eina_future_then(future, _children_get, event->object, NULL);
|
2016-04-20 13:07:53 -07:00
|
|
|
}
|
2015-04-05 06:19:45 -07:00
|
|
|
|
efl_model : rename all efl_model based classes.
Summary:
As the result of discussion in T7458,
we need to rename all efl_model based classes with efl_XXX_Model sequence.
I've run few vote for this, see V42, V43
few classes are totally renamed as our consideration of misnaming.
| Efl.Model_Loop | Efl.Loop_Model |
| Efl.Model_Item | Efl.Generic_Model |
| Efl.Model_Container | Efl.Container_Model |
| Efl.Model_Container_Item | Efl.Container_Model_Item |
| Efl.Model_Composite | Efl.Composite_Model |
| Efl.Model_Composite_Boolean | Efl.Boolean_Model |
| Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item |
| Efl.Model_Composite_Selection | Efl.Select_Model |
| Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item |
| Efl.Model_View | Efl.View_Model |
| Eio.Model | Efl.Io.Model |
| Efl.Ui.Model_State | Efl.Ui.State_Model |
| Efl.Ui.Model_Size | Efl.Ui.Size_Model |
| Efl.Ui.Model_Exact | Efl.Ui.Exact_Model |
| Efl.Ui.Model_Average | Efl.Ui.Average_Model |
| Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model |
I worried about Efl.Io.Model changes, cause it is widely used,
but as I tested, there is no issue found yet.
Eldbus.Model also may can changed Efl.Dbus.Model,
but I cannot found any class who using Efl.Dbus namespace,
so I left it future work.
Test Plan:
Run the Make Test,
it works well except Efl test about selection.
there are class inheritance problem exist in select_model,
I reported it and will fix it in another patch.
Reviewers: cedric, felipealmeida, woohyun, Hermet
Reviewed By: cedric
Subscribers: lauromoura
Tags: #efl, #do_not_merge
Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
|
|
|
EFL_START_TEST(efl_io_model_test_test_monitor_add)
|
2015-04-05 06:19:45 -07:00
|
|
|
{
|
|
|
|
Eo *filemodel = NULL;
|
|
|
|
|
2015-10-14 22:47:04 -07:00
|
|
|
tmpdir = eina_environment_tmp_get();
|
2016-02-04 05:51:07 -08:00
|
|
|
|
efl_model : rename all efl_model based classes.
Summary:
As the result of discussion in T7458,
we need to rename all efl_model based classes with efl_XXX_Model sequence.
I've run few vote for this, see V42, V43
few classes are totally renamed as our consideration of misnaming.
| Efl.Model_Loop | Efl.Loop_Model |
| Efl.Model_Item | Efl.Generic_Model |
| Efl.Model_Container | Efl.Container_Model |
| Efl.Model_Container_Item | Efl.Container_Model_Item |
| Efl.Model_Composite | Efl.Composite_Model |
| Efl.Model_Composite_Boolean | Efl.Boolean_Model |
| Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item |
| Efl.Model_Composite_Selection | Efl.Select_Model |
| Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item |
| Efl.Model_View | Efl.View_Model |
| Eio.Model | Efl.Io.Model |
| Efl.Ui.Model_State | Efl.Ui.State_Model |
| Efl.Ui.Model_Size | Efl.Ui.Size_Model |
| Efl.Ui.Model_Exact | Efl.Ui.Exact_Model |
| Efl.Ui.Model_Average | Efl.Ui.Average_Model |
| Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model |
I worried about Efl.Io.Model changes, cause it is widely used,
but as I tested, there is no issue found yet.
Eldbus.Model also may can changed Efl.Dbus.Model,
but I cannot found any class who using Efl.Dbus namespace,
so I left it future work.
Test Plan:
Run the Make Test,
it works well except Efl test about selection.
there are class inheritance problem exist in select_model,
I reported it and will fix it in another patch.
Reviewers: cedric, felipealmeida, woohyun, Hermet
Reviewed By: cedric
Subscribers: lauromoura
Tags: #efl, #do_not_merge
Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
|
|
|
filemodel = efl_add(EFL_IO_MODEL_CLASS,
|
2018-04-09 11:52:02 -07:00
|
|
|
efl_main_loop_get(),
|
efl_model : rename all efl_model based classes.
Summary:
As the result of discussion in T7458,
we need to rename all efl_model based classes with efl_XXX_Model sequence.
I've run few vote for this, see V42, V43
few classes are totally renamed as our consideration of misnaming.
| Efl.Model_Loop | Efl.Loop_Model |
| Efl.Model_Item | Efl.Generic_Model |
| Efl.Model_Container | Efl.Container_Model |
| Efl.Model_Container_Item | Efl.Container_Model_Item |
| Efl.Model_Composite | Efl.Composite_Model |
| Efl.Model_Composite_Boolean | Efl.Boolean_Model |
| Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item |
| Efl.Model_Composite_Selection | Efl.Select_Model |
| Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item |
| Efl.Model_View | Efl.View_Model |
| Eio.Model | Efl.Io.Model |
| Efl.Ui.Model_State | Efl.Ui.State_Model |
| Efl.Ui.Model_Size | Efl.Ui.Size_Model |
| Efl.Ui.Model_Exact | Efl.Ui.Exact_Model |
| Efl.Ui.Model_Average | Efl.Ui.Average_Model |
| Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model |
I worried about Efl.Io.Model changes, cause it is widely used,
but as I tested, there is no issue found yet.
Eldbus.Model also may can changed Efl.Dbus.Model,
but I cannot found any class who using Efl.Dbus namespace,
so I left it future work.
Test Plan:
Run the Make Test,
it works well except Efl test about selection.
there are class inheritance problem exist in select_model,
I reported it and will fix it in another patch.
Reviewers: cedric, felipealmeida, woohyun, Hermet
Reviewed By: cedric
Subscribers: lauromoura
Tags: #efl, #do_not_merge
Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
|
|
|
efl_io_model_path_set(efl_added, tmpdir));
|
2015-04-05 06:19:45 -07:00
|
|
|
fail_if(!filemodel, "ERROR: Cannot init model!\n");
|
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add(filemodel, EFL_MODEL_EVENT_CHILD_ADDED, &_children_added_cb, filemodel);
|
|
|
|
efl_event_callback_add(filemodel, EFL_MODEL_EVENT_CHILD_REMOVED, &_children_removed_cb, NULL);
|
2015-04-05 06:19:45 -07:00
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
2018-04-09 11:52:02 -07:00
|
|
|
efl_del(filemodel);
|
2015-04-05 06:19:45 -07:00
|
|
|
|
2016-04-20 13:07:53 -07:00
|
|
|
fail_if(!children_deleted);
|
2015-04-05 06:19:45 -07:00
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2015-04-05 06:19:45 -07:00
|
|
|
|
|
|
|
void
|
efl_model : rename all efl_model based classes.
Summary:
As the result of discussion in T7458,
we need to rename all efl_model based classes with efl_XXX_Model sequence.
I've run few vote for this, see V42, V43
few classes are totally renamed as our consideration of misnaming.
| Efl.Model_Loop | Efl.Loop_Model |
| Efl.Model_Item | Efl.Generic_Model |
| Efl.Model_Container | Efl.Container_Model |
| Efl.Model_Container_Item | Efl.Container_Model_Item |
| Efl.Model_Composite | Efl.Composite_Model |
| Efl.Model_Composite_Boolean | Efl.Boolean_Model |
| Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item |
| Efl.Model_Composite_Selection | Efl.Select_Model |
| Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item |
| Efl.Model_View | Efl.View_Model |
| Eio.Model | Efl.Io.Model |
| Efl.Ui.Model_State | Efl.Ui.State_Model |
| Efl.Ui.Model_Size | Efl.Ui.Size_Model |
| Efl.Ui.Model_Exact | Efl.Ui.Exact_Model |
| Efl.Ui.Model_Average | Efl.Ui.Average_Model |
| Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model |
I worried about Efl.Io.Model changes, cause it is widely used,
but as I tested, there is no issue found yet.
Eldbus.Model also may can changed Efl.Dbus.Model,
but I cannot found any class who using Efl.Dbus namespace,
so I left it future work.
Test Plan:
Run the Make Test,
it works well except Efl test about selection.
there are class inheritance problem exist in select_model,
I reported it and will fix it in another patch.
Reviewers: cedric, felipealmeida, woohyun, Hermet
Reviewed By: cedric
Subscribers: lauromoura
Tags: #efl, #do_not_merge
Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
|
|
|
efl_io_model_test_monitor_add(TCase *tc)
|
2015-04-05 06:19:45 -07:00
|
|
|
{
|
efl_model : rename all efl_model based classes.
Summary:
As the result of discussion in T7458,
we need to rename all efl_model based classes with efl_XXX_Model sequence.
I've run few vote for this, see V42, V43
few classes are totally renamed as our consideration of misnaming.
| Efl.Model_Loop | Efl.Loop_Model |
| Efl.Model_Item | Efl.Generic_Model |
| Efl.Model_Container | Efl.Container_Model |
| Efl.Model_Container_Item | Efl.Container_Model_Item |
| Efl.Model_Composite | Efl.Composite_Model |
| Efl.Model_Composite_Boolean | Efl.Boolean_Model |
| Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item |
| Efl.Model_Composite_Selection | Efl.Select_Model |
| Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item |
| Efl.Model_View | Efl.View_Model |
| Eio.Model | Efl.Io.Model |
| Efl.Ui.Model_State | Efl.Ui.State_Model |
| Efl.Ui.Model_Size | Efl.Ui.Size_Model |
| Efl.Ui.Model_Exact | Efl.Ui.Exact_Model |
| Efl.Ui.Model_Average | Efl.Ui.Average_Model |
| Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model |
I worried about Efl.Io.Model changes, cause it is widely used,
but as I tested, there is no issue found yet.
Eldbus.Model also may can changed Efl.Dbus.Model,
but I cannot found any class who using Efl.Dbus namespace,
so I left it future work.
Test Plan:
Run the Make Test,
it works well except Efl test about selection.
there are class inheritance problem exist in select_model,
I reported it and will fix it in another patch.
Reviewers: cedric, felipealmeida, woohyun, Hermet
Reviewed By: cedric
Subscribers: lauromoura
Tags: #efl, #do_not_merge
Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
|
|
|
tcase_add_test(tc, efl_io_model_test_test_monitor_add);
|
2015-04-05 06:19:45 -07:00
|
|
|
}
|