forked from enlightenment/efl
eldbus: migrate tests to use new Efl.Model API.
This commit is contained in:
parent
37374c8da6
commit
702bcd7de9
|
@ -14,57 +14,68 @@
|
|||
#include "eldbus_test_eldbus_model.h"
|
||||
#include "eldbus_suite.h"
|
||||
|
||||
static void
|
||||
_future_then_quit_cb(void *data , Efl_Event const *event)
|
||||
{
|
||||
Efl_Future_Event_Success* info = event->info;
|
||||
*(void**)data = info->value;
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static void
|
||||
_future_then_quit_u_cb(void *data , Efl_Event const *event)
|
||||
static Eina_Value
|
||||
_future_then_quit_u_cb(void *data,
|
||||
const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
unsigned *lhs = data;
|
||||
unsigned *rhs = ((Efl_Future_Event_Success*)event->info)->value;;
|
||||
*lhs = *rhs;
|
||||
unsigned r = 0;
|
||||
|
||||
eina_value_uint_get(&v, &r);
|
||||
|
||||
*lhs = r;
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_future_then_cp(void *data , Efl_Event const *event)
|
||||
static Eina_Value
|
||||
_future_then_cp(void *data ,
|
||||
const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Eina_Value* value = ((Efl_Future_Event_Success*)event->info)->value;
|
||||
eina_value_copy(value, data);
|
||||
Eina_Value *value = data;
|
||||
|
||||
eina_value_copy(&v, value);
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_future_check_err(void *data EINA_UNUSED, Efl_Event const *value EINA_UNUSED)
|
||||
static Eina_Value
|
||||
_future_check_err(void *data,
|
||||
const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
ck_assert_msg(0, "Future Expected Error:\n");
|
||||
Eina_Error *expected_error = data;
|
||||
Eina_Error got = 0;
|
||||
|
||||
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
|
||||
|
||||
eina_value_error_get(&v, &got);
|
||||
|
||||
if (expected_error)
|
||||
ck_assert_int_eq(got, *expected_error);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_error_then_ok(void* data, Efl_Event const* event)
|
||||
static Eina_Value
|
||||
_future_then_quit_cb(void* data,
|
||||
const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Efl_Future_Event_Failure* info = event->info;
|
||||
Eina_Error const** expected_error = (Eina_Error const**)data;
|
||||
Eina_Value **value = data;
|
||||
|
||||
if (*expected_error)
|
||||
ck_assert_int_eq(info->error, **expected_error);
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
*value = eina_value_dup(&v);
|
||||
|
||||
static void
|
||||
_error_then_cb(void* data EINA_UNUSED, Efl_Event const* event)
|
||||
{
|
||||
Efl_Future_Event_Failure* info = event->info;
|
||||
ck_assert_msg(0,"Future ERROR: %s\n", eina_error_msg_get(info->error));
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -74,27 +85,27 @@ _efl_event_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
|||
efl_event_callback_stop(event->object);
|
||||
}
|
||||
|
||||
void *
|
||||
efl_model_future_then(Efl_Future *future)
|
||||
Eina_Value *
|
||||
efl_model_future_then(Eina_Future *future)
|
||||
{
|
||||
void *data = NULL;
|
||||
efl_future_then(future, &_future_then_quit_cb, &_error_then_cb, NULL, &data);
|
||||
Eina_Value *data = NULL;
|
||||
eina_future_then(future, &_future_then_quit_cb, &data);
|
||||
ecore_main_loop_begin();
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
check_efl_model_future_error(Efl_Future *future, Eina_Error *err)
|
||||
check_efl_model_future_error(Eina_Future *future, Eina_Error *err)
|
||||
{
|
||||
efl_future_then(future, &_future_check_err, &_error_then_ok, NULL, &err);
|
||||
eina_future_then(future, &_future_check_err, err);
|
||||
ecore_main_loop_begin();
|
||||
}
|
||||
|
||||
int
|
||||
efl_model_future_then_u(Efl_Future *future)
|
||||
efl_model_future_then_u(Eina_Future *future)
|
||||
{
|
||||
unsigned i = -1;
|
||||
efl_future_then(future, &_future_then_quit_u_cb, &_error_then_cb, NULL, &i);
|
||||
eina_future_then(future, &_future_then_quit_u_cb, &i);
|
||||
ecore_main_loop_begin();
|
||||
return i;
|
||||
}
|
||||
|
@ -110,21 +121,24 @@ efl_model_wait_for_event(Eo *obj, const Efl_Event_Description* event)
|
|||
Efl_Model *
|
||||
efl_model_nth_child_get(Efl_Model *efl_model, unsigned int n)
|
||||
{
|
||||
Eina_Accessor *accessor;
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
Eina_Value *array;
|
||||
Eo *child = NULL;
|
||||
unsigned int len, i;
|
||||
|
||||
future = efl_model_children_slice_get(efl_model, n, 1);
|
||||
efl_ref(future);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
Eo *child = NULL;
|
||||
array = efl_model_future_then(future);
|
||||
fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ARRAY);
|
||||
|
||||
EINA_VALUE_ARRAY_FOREACH(array, len, i, child)
|
||||
;
|
||||
|
||||
child = efl_ref(child);
|
||||
eina_value_free(array);
|
||||
|
||||
fail_if(!child);
|
||||
|
||||
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||
efl_unref(future);
|
||||
ck_assert(ret);
|
||||
ck_assert_ptr_ne(NULL, child);
|
||||
return child;
|
||||
}
|
||||
|
||||
|
@ -137,12 +151,11 @@ efl_model_first_child_get(Efl_Model *efl_model)
|
|||
void
|
||||
check_property(Eo *object, const char *property_name, const char *expected_value)
|
||||
{
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(object, property_name);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
Eina_Value *value = efl_model_future_then(future);
|
||||
Eina_Value *value;
|
||||
char *actual_value;
|
||||
eina_value_get(value, &actual_value);
|
||||
|
||||
value = efl_model_property_get(object, property_name);
|
||||
actual_value = eina_value_to_string(value);
|
||||
if (!actual_value)
|
||||
ck_assert_ptr_eq(expected_value, actual_value);
|
||||
else
|
||||
|
@ -151,12 +164,14 @@ check_property(Eo *object, const char *property_name, const char *expected_value
|
|||
ck_assert_msg(is_property_equal, "'%s' != '%s'", expected_value, actual_value);
|
||||
free(actual_value);
|
||||
}
|
||||
eina_value_free(value);
|
||||
}
|
||||
|
||||
Eo *
|
||||
create_connection(void)
|
||||
{
|
||||
Eo *connection = efl_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, efl_main_loop_get(), eldbus_model_connection_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE));
|
||||
Eo *connection = efl_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, efl_main_loop_get(),
|
||||
eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE));
|
||||
ck_assert_ptr_ne(NULL, connection);
|
||||
return connection;
|
||||
}
|
||||
|
@ -164,7 +179,10 @@ create_connection(void)
|
|||
Eo *
|
||||
create_object(void)
|
||||
{
|
||||
Eo *object = efl_add_ref(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, ELDBUS_FDO_BUS, ELDBUS_FDO_PATH));
|
||||
Eo *object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
|
||||
eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
|
||||
eldbus_model_object_bus_set(efl_added, ELDBUS_FDO_BUS),
|
||||
eldbus_model_object_path_set(efl_added, ELDBUS_FDO_PATH));
|
||||
ck_assert_ptr_ne(NULL, object);
|
||||
return object;
|
||||
}
|
||||
|
@ -173,9 +191,8 @@ void
|
|||
check_efl_model_children_count_eq(Efl_Model *efl_model, unsigned int expected_children_count)
|
||||
{
|
||||
unsigned int actual_children_count;
|
||||
Efl_Future *future;
|
||||
future = efl_model_children_count_get(efl_model);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
|
||||
actual_children_count = efl_model_children_count_get(efl_model);
|
||||
ck_assert_int_eq(expected_children_count, actual_children_count);
|
||||
}
|
||||
|
||||
|
@ -183,9 +200,8 @@ void
|
|||
check_efl_model_children_count_ge(Efl_Model *efl_model, unsigned int minimum_children_count)
|
||||
{
|
||||
unsigned int actual_children_count;
|
||||
Efl_Future *future;
|
||||
future = efl_model_children_count_get(efl_model);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
|
||||
actual_children_count = efl_model_children_count_get(efl_model);
|
||||
ck_assert_int_ge(actual_children_count, minimum_children_count);
|
||||
}
|
||||
|
||||
|
@ -193,72 +209,60 @@ void
|
|||
check_efl_model_children_slice_get(Efl_Model *efl_model)
|
||||
{
|
||||
unsigned count;
|
||||
Efl_Future *future;
|
||||
Eina_Accessor *accessor;
|
||||
Eina_Future *future;
|
||||
Eina_Value *array;
|
||||
Eo *first_child = NULL;
|
||||
Eo *last_child = NULL;
|
||||
Eo *nonexistent_child = NULL;
|
||||
Eo *child = NULL;
|
||||
|
||||
future = efl_model_children_count_get(efl_model);
|
||||
count = efl_model_future_then_u(future);
|
||||
count = efl_model_children_count_get(efl_model);
|
||||
ck_assert_msg((int)count > 0, "There must be at least 1 child to test");
|
||||
|
||||
// Test slice all
|
||||
future = efl_model_children_slice_get(efl_model, 0, 0);
|
||||
efl_ref(future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
future = efl_model_children_slice_get(efl_model, 0, count);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ARRAY);
|
||||
|
||||
// Get first child
|
||||
Eo *first_child = NULL;
|
||||
Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&first_child);
|
||||
ck_assert(ret);
|
||||
eina_value_array_get(array, 0, &first_child);
|
||||
ck_assert_ptr_ne(NULL, first_child);
|
||||
|
||||
// get last child
|
||||
Eo *last_child = NULL;
|
||||
ret = eina_accessor_data_get(accessor, count - 1, (void**)&last_child);
|
||||
ck_assert(ret);
|
||||
eina_value_array_get(array, count - 1, &last_child);
|
||||
ck_assert_ptr_ne(NULL, last_child);
|
||||
|
||||
// Test nonexistent child
|
||||
Eo *nonexistent_child = NULL;
|
||||
ret = eina_accessor_data_get(accessor, count, (void**)&nonexistent_child);
|
||||
ck_assert(!ret);
|
||||
eina_value_array_get(array, count, &nonexistent_child);
|
||||
ck_assert_ptr_eq(NULL, nonexistent_child);
|
||||
efl_unref(future);
|
||||
eina_value_free(array);
|
||||
|
||||
// Test slice first child
|
||||
Eo *child = NULL;
|
||||
future = efl_model_children_slice_get(efl_model, 0, 1);
|
||||
efl_ref(future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||
ck_assert(ret);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
eina_value_array_get(array, 0, &child);
|
||||
ck_assert_ptr_ne(NULL, child);
|
||||
ret = eina_accessor_data_get(accessor, 1, (void**)&child);
|
||||
ck_assert(!ret);
|
||||
eina_value_array_get(array, 1, &child);
|
||||
ck_assert_ptr_eq(first_child, child);
|
||||
efl_unref(future);
|
||||
eina_value_free(array);
|
||||
|
||||
// Test slice last child
|
||||
future = efl_model_children_slice_get(efl_model, count - 1, 1);
|
||||
efl_ref(future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
ret = eina_accessor_data_get(accessor, 0, (void**)&child);
|
||||
ck_assert(ret);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
eina_value_array_get(array, 0, &child);
|
||||
ck_assert_ptr_ne(NULL, child);
|
||||
ret = eina_accessor_data_get(accessor, 1, (void**)&child);
|
||||
ck_assert(!ret);
|
||||
eina_value_array_get(array, 1, &child);
|
||||
ck_assert_ptr_eq(last_child, child);
|
||||
efl_unref(future);
|
||||
|
||||
// Test slice nonexistent element
|
||||
future = efl_model_children_slice_get(efl_model, count, 1);
|
||||
efl_ref(future);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_eq(NULL, accessor);
|
||||
efl_unref(future);
|
||||
array = efl_model_future_then(future);
|
||||
fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_free(array);
|
||||
}
|
||||
|
||||
EFL_START_TEST(smoke)
|
||||
|
@ -277,29 +281,58 @@ EFL_START_TEST(object)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Value
|
||||
_leave(void *data EINA_UNUSED, const Eina_Value v,
|
||||
const Eina_Future *dead EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
return v;
|
||||
}
|
||||
static void
|
||||
_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
Eina_Future *f;
|
||||
f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
|
||||
eina_future_then(f, _leave, NULL);
|
||||
}
|
||||
|
||||
static Eina_Future *
|
||||
_async_slice_get(Efl_Model *model)
|
||||
{
|
||||
efl_event_callback_add(model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
if (!efl_model_children_count_get(model))
|
||||
ecore_main_loop_begin();
|
||||
|
||||
efl_event_callback_del(model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
|
||||
return efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
|
||||
}
|
||||
|
||||
EFL_START_TEST(proxy)
|
||||
{
|
||||
Eo *root = create_object();
|
||||
Eina_Future *future = NULL;
|
||||
Eina_Value *array = NULL;
|
||||
Eo *proxy = NULL;
|
||||
Eo *root;
|
||||
unsigned int i, len;
|
||||
|
||||
Eina_Accessor *accessor = NULL;
|
||||
Efl_Future *future = NULL;
|
||||
future = efl_model_children_slice_get(root, 0, 0);
|
||||
efl_ref(future);
|
||||
root = create_object();
|
||||
|
||||
future = _async_slice_get(root);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
|
||||
unsigned int i;
|
||||
Eo *proxy;
|
||||
EINA_ACCESSOR_FOREACH(accessor, i, proxy)
|
||||
EINA_VALUE_ARRAY_FOREACH(array, len, i, proxy)
|
||||
{
|
||||
ck_assert_ptr_ne(NULL, proxy);
|
||||
//efl_model_load_and_wait_for_load_status(proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||
//efl_model_load_and_wait_for_load_status(proxy, EFL_MODEL_LOAD_STATUS_LOADED);
|
||||
}
|
||||
efl_unref(future);
|
||||
|
||||
efl_unref(root);
|
||||
eina_value_free(array);
|
||||
|
||||
efl_del(root);
|
||||
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
@ -315,19 +348,19 @@ eldbus_test_eldbus_model(TCase *tc)
|
|||
Eldbus_Model_Proxy *
|
||||
eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name)
|
||||
{
|
||||
Eina_Accessor *accessor;
|
||||
Efl_Future *future = NULL;
|
||||
future = efl_model_children_slice_get(object, 0, 0);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
efl_ref(future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
|
||||
Eina_Future *future = NULL;
|
||||
Eo *proxy = NULL;
|
||||
unsigned int i;
|
||||
EINA_ACCESSOR_FOREACH(accessor, i, proxy)
|
||||
Eina_Value *array;
|
||||
unsigned int len, i;
|
||||
|
||||
future = _async_slice_get(object);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
|
||||
EINA_VALUE_ARRAY_FOREACH(array, len, i, proxy)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = eldbus_model_proxy_name_get(proxy);
|
||||
ck_assert_ptr_ne(NULL, name);
|
||||
if (strcmp(name, interface_name) == 0)
|
||||
|
@ -336,29 +369,30 @@ eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *inte
|
|||
proxy = NULL;
|
||||
|
||||
end:
|
||||
efl_unref(future);
|
||||
eina_value_free(array);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
static Eldbus_Model_Arguments *
|
||||
_eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name, const Efl_Class *klass)
|
||||
{
|
||||
Eina_Accessor *accessor;
|
||||
Efl_Future *future = NULL;
|
||||
future = efl_model_children_slice_get(proxy, 0, 0);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
efl_ref(future);
|
||||
accessor = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, accessor);
|
||||
|
||||
Eina_Future *future = NULL;
|
||||
Eo *child = NULL;
|
||||
unsigned int i;
|
||||
EINA_ACCESSOR_FOREACH(accessor, i, child)
|
||||
Eina_Value *array;
|
||||
unsigned int len, i;
|
||||
|
||||
future = _async_slice_get(proxy);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
array = efl_model_future_then(future);
|
||||
ck_assert_ptr_ne(NULL, array);
|
||||
|
||||
EINA_VALUE_ARRAY_FOREACH(array, len, i, child)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if (!efl_isa(child, klass))
|
||||
continue;
|
||||
|
||||
const char *name;
|
||||
name = eldbus_model_arguments_arg_name_get(child);
|
||||
ck_assert_ptr_ne(NULL, name);
|
||||
if (strcmp(name, method_name) == 0)
|
||||
|
@ -367,7 +401,7 @@ _eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *me
|
|||
child = NULL;
|
||||
|
||||
end:
|
||||
efl_unref(future);
|
||||
eina_value_free(array);
|
||||
return child;
|
||||
}
|
||||
|
||||
|
@ -386,41 +420,39 @@ eldbus_model_signal_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *signal
|
|||
void
|
||||
check_efl_model_property_int_eq(Efl_Model *efl_model, const char *property, int expected_value)
|
||||
{
|
||||
Eina_Value property_value;
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(efl_model, property);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
const Eina_Value_Type *property_type;
|
||||
Eina_Value *property_value;
|
||||
int actual_value = 0;
|
||||
|
||||
efl_future_then(future, &_future_then_cp, &_error_then_cb, NULL, &property_value);
|
||||
ecore_main_loop_begin();
|
||||
|
||||
const Eina_Value_Type *property_type = eina_value_type_get(&property_value);
|
||||
property_value = efl_model_property_get(efl_model, property);
|
||||
property_type = eina_value_type_get(property_value);
|
||||
ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type);
|
||||
|
||||
int actual_value = 0;
|
||||
eina_value_get(&property_value, &actual_value);
|
||||
eina_value_get(property_value, &actual_value);
|
||||
ck_assert_int_eq(expected_value, actual_value);
|
||||
eina_value_flush(&property_value);
|
||||
eina_value_free(property_value);
|
||||
}
|
||||
|
||||
void
|
||||
check_efl_model_property_int_set(Efl_Model *efl_model, const char *property, int value)
|
||||
{
|
||||
Eina_Value eina_value, value_ret;
|
||||
Efl_Future *future;
|
||||
Eina_Value eina_value = EINA_VALUE_EMPTY, value_ret = EINA_VALUE_EMPTY;
|
||||
Eina_Future *future;
|
||||
const Eina_Value_Type *property_type;
|
||||
|
||||
eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT);
|
||||
eina_value_set(&eina_value, value);
|
||||
future = efl_model_property_set(efl_model, property, &eina_value);
|
||||
|
||||
efl_future_then(future, &_future_then_cp, &_error_then_cb, NULL, &value_ret);
|
||||
eina_future_then(future, &_future_then_cp, &value_ret);
|
||||
ecore_main_loop_begin();
|
||||
|
||||
const Eina_Value_Type *property_type = eina_value_type_get(&value_ret);
|
||||
property_type = eina_value_type_get(&value_ret);
|
||||
ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type);
|
||||
|
||||
int actual_value;
|
||||
eina_value_get(&value_ret, &actual_value);
|
||||
ck_assert_int_eq(value, actual_value);
|
||||
eina_value_flush(&eina_value);
|
||||
eina_value_flush(&value_ret);
|
||||
}
|
||||
|
|
|
@ -19,11 +19,10 @@ void check_efl_model_children_count_ge(Efl_Model *obj, unsigned int minimum_chil
|
|||
void check_efl_model_children_slice_get(Efl_Model *efl_model);
|
||||
void check_efl_model_property_int_eq(Efl_Model *obj, const char *property, int expected_value);
|
||||
void check_efl_model_property_int_set(Efl_Model *obj, const char *property, int value);
|
||||
void check_efl_model_future_error(Efl_Future *future, Eina_Error *err);
|
||||
void check_efl_model_future_error(Eina_Future *future, Eina_Error *err);
|
||||
|
||||
|
||||
void *efl_model_future_then(Efl_Future *future);
|
||||
int efl_model_future_then_u(Efl_Future *future);
|
||||
Eina_Value *efl_model_future_then(Eina_Future *future);
|
||||
int efl_model_future_then_u(Eina_Future *future);
|
||||
|
||||
Eldbus_Model_Proxy *eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name);
|
||||
Eldbus_Model_Method *eldbus_model_method_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name);
|
||||
|
|
|
@ -41,40 +41,88 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(property_get)
|
||||
{
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(connection, UNIQUE_NAME_PROPERTY);
|
||||
efl_model_future_then(future);
|
||||
Eina_Value *v;
|
||||
|
||||
v = efl_model_property_get(connection, UNIQUE_NAME_PROPERTY);
|
||||
fail_if(v == NULL);
|
||||
|
||||
// Nonexistent property must raise ERROR
|
||||
future = NULL;
|
||||
future = efl_model_property_get(connection, "nonexistent");
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
v = efl_model_property_get(connection, "nonexistent");
|
||||
fail_if(v == NULL);
|
||||
fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
|
||||
/* fail_if(v != NULL || eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR); */
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Value
|
||||
_failed_property_set(void *data, const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Eina_Value *expected = data;
|
||||
|
||||
fail_if(eina_value_type_get(expected) != eina_value_type_get(&v));
|
||||
|
||||
if (eina_value_type_get(expected) == EINA_VALUE_TYPE_ERROR)
|
||||
{
|
||||
Eina_Error exerr = 0, goterr = 0;
|
||||
|
||||
eina_value_error_get(expected, &exerr);
|
||||
eina_value_error_get(&v, &goterr);
|
||||
|
||||
fail_if(exerr != goterr);
|
||||
}
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
Eina_Value value;
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
|
||||
// Nonexistent property must raise ERROR
|
||||
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||
eina_value_set(&value, 1);
|
||||
future = efl_model_property_set(connection, "nonexistent", &value);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
eina_future_then(future, _failed_property_set, eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND));
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
// UNIQUE_NAME_PROPERTY is read-only
|
||||
future = efl_model_property_set(connection, UNIQUE_NAME_PROPERTY, &value);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY);
|
||||
eina_future_then(future, _failed_property_set, eina_value_error_new(EFL_MODEL_ERROR_READ_ONLY));
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_value_flush(&value);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Value
|
||||
_leave(void *data EINA_UNUSED, const Eina_Value v,
|
||||
const Eina_Future *dead EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
return v;
|
||||
}
|
||||
static void
|
||||
_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
Eina_Future *f;
|
||||
f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
|
||||
eina_future_then(f, _leave, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_test_children_count(Eo *efl_model)
|
||||
{
|
||||
// At least this connection <unique_name> and 'org.freedesktop.DBus' must exist
|
||||
efl_event_callback_add(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
if (!efl_model_children_count_get(efl_model))
|
||||
ecore_main_loop_begin();
|
||||
efl_event_callback_del(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
|
||||
check_efl_model_children_count_ge(efl_model, 2);
|
||||
}
|
||||
|
||||
|
@ -86,6 +134,11 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(children_slice_get)
|
||||
{
|
||||
efl_event_callback_add(connection, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
if (!efl_model_children_count_get(connection))
|
||||
ecore_main_loop_begin();
|
||||
efl_event_callback_del(connection, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
|
||||
check_efl_model_children_slice_get(connection);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
@ -101,17 +154,15 @@ EFL_END_TEST
|
|||
EFL_START_TEST(child_del)
|
||||
{
|
||||
unsigned int expected_children_count = 0;
|
||||
Efl_Future *future;
|
||||
future = efl_model_children_count_get(connection);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
expected_children_count = efl_model_future_then_u(future);
|
||||
unsigned int actual_children_count = 0;
|
||||
Eo *child;
|
||||
|
||||
Eo *child = efl_model_first_child_get(connection);
|
||||
expected_children_count = efl_model_children_count_get(connection);
|
||||
|
||||
child = efl_model_first_child_get(connection);
|
||||
efl_model_child_del(connection, child);
|
||||
|
||||
unsigned int actual_children_count = 0;
|
||||
future = efl_model_children_count_get(connection);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
actual_children_count = efl_model_children_count_get(connection);
|
||||
|
||||
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ _setup(void)
|
|||
{
|
||||
fake_server = fake_server_start(&fake_server_data);
|
||||
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH));
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
|
||||
eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
|
||||
eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
|
||||
eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
|
||||
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||
|
||||
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||
|
@ -60,26 +63,59 @@ EFL_END_TEST
|
|||
EFL_START_TEST(property_get)
|
||||
{
|
||||
// Input only property returns error
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(method, ARGUMENT_A);
|
||||
check_efl_model_future_error(future, NULL);
|
||||
Eina_Value *v;
|
||||
Eina_Value i = EINA_VALUE_EMPTY;
|
||||
int iv = -1;
|
||||
|
||||
future = efl_model_property_get(method, ARGUMENT_RESULT);
|
||||
efl_model_future_then(future);
|
||||
v = efl_model_property_get(method, ARGUMENT_A);
|
||||
fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_free(v);
|
||||
|
||||
v = efl_model_property_get(method, ARGUMENT_RESULT);
|
||||
eina_value_setup(&i, EINA_VALUE_TYPE_INT);
|
||||
fail_if(eina_value_convert(v, &i) != EINA_TRUE);
|
||||
fail_if(eina_value_int_get(&i, &iv) != EINA_TRUE);
|
||||
fail_if(iv != 0);
|
||||
eina_value_flush(&i);
|
||||
eina_value_free(v);
|
||||
|
||||
// Nonexistent property returns error
|
||||
future = efl_model_property_get(method, "nonexistent");
|
||||
check_efl_model_future_error(future, NULL);
|
||||
v = efl_model_property_get(method, "nonexistent");
|
||||
fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_free(v);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Value
|
||||
_expected_error(void *data,
|
||||
const Eina_Value v,
|
||||
const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
|
||||
|
||||
if (data)
|
||||
{
|
||||
Eina_Error *expected = data;
|
||||
Eina_Error error;
|
||||
|
||||
eina_value_error_get(&v, &error);
|
||||
|
||||
fail_if(*expected != error);
|
||||
}
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
// Output argument returns error
|
||||
Efl_Future *future;
|
||||
Eina_Value dummy = {0};
|
||||
Eina_Future *future;
|
||||
Eina_Value dummy = EINA_VALUE_EMPTY;
|
||||
|
||||
future = efl_model_property_set(method, ARGUMENT_RESULT, &dummy);
|
||||
check_efl_model_future_error(future, NULL);
|
||||
eina_future_then(future, _expected_error, NULL);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
|
@ -97,9 +133,12 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(children_slice_get)
|
||||
{
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
|
||||
future = efl_model_children_slice_get(method, 1, 1);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED);
|
||||
eina_future_then(future, _expected_error, &EFL_MODEL_ERROR_NOT_SUPPORTED);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
|
|
|
@ -41,31 +41,58 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(property_get)
|
||||
{
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(object, UNIQUE_NAME_PROPERTY);
|
||||
efl_model_future_then(future);
|
||||
Eina_Value *v;
|
||||
|
||||
v = efl_model_property_get(object, UNIQUE_NAME_PROPERTY);
|
||||
fail_if(v == NULL);
|
||||
fail_if(eina_value_type_get(v) == EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_free(v);
|
||||
|
||||
// Nonexistent property must raise ERROR
|
||||
future = NULL;
|
||||
future = efl_model_property_get(object, "nonexistent");
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
v = efl_model_property_get(object, "nonexistent");
|
||||
fail_if(v == NULL);
|
||||
fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_free(v);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Value
|
||||
_expect_error(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Eina_Error *expected = data;
|
||||
Eina_Error result = 0;
|
||||
|
||||
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
|
||||
|
||||
if (!expected) return v;
|
||||
|
||||
eina_value_error_get(&v, &result);
|
||||
fail_if(result != *expected);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
Eina_Value value;
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
Eina_Value value = EINA_VALUE_EMPTY;
|
||||
|
||||
// Nonexistent property must raise ERROR
|
||||
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||
eina_value_set(&value, 1);
|
||||
|
||||
future = efl_model_property_set(object, "nonexistent", &value);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
eina_future_then(future, _expect_error, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
// UNIQUE_NAME_PROPERTY is read-only
|
||||
future = efl_model_property_set(object, UNIQUE_NAME_PROPERTY, &value);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY);
|
||||
eina_future_then(future, _expect_error, &EFL_MODEL_ERROR_READ_ONLY);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
eina_value_flush(&value);
|
||||
}
|
||||
|
@ -78,14 +105,42 @@ _test_children_count(Eo *efl_model)
|
|||
check_efl_model_children_count_ge(efl_model, 2);
|
||||
}
|
||||
|
||||
static Eina_Value
|
||||
_leave(void *data EINA_UNUSED, const Eina_Value v,
|
||||
const Eina_Future *dead EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
Eina_Future *f;
|
||||
|
||||
f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
|
||||
eina_future_then(f, _leave, NULL);
|
||||
}
|
||||
|
||||
EFL_START_TEST(children_count)
|
||||
{
|
||||
efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
efl_model_children_count_get(object);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
_test_children_count(object);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(children_slice_get)
|
||||
{
|
||||
efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
efl_model_children_count_get(object);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
check_efl_model_children_slice_get(object);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
@ -98,23 +153,52 @@ EFL_START_TEST(child_add)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static void
|
||||
_children_wait(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
}
|
||||
|
||||
static Eina_Value
|
||||
_one_child(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
|
||||
{
|
||||
Eo **child = data;
|
||||
|
||||
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
|
||||
fail_if(eina_value_array_count(&v) != 1);
|
||||
eina_value_array_get(&v, 0, &child);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
EFL_START_TEST(child_del)
|
||||
{
|
||||
Eina_Future *future;
|
||||
Eo *child = NULL;
|
||||
unsigned int expected_children_count = 0;
|
||||
Efl_Future *future;
|
||||
future = efl_model_children_count_get(object);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
expected_children_count = efl_model_future_then_u(future);
|
||||
ck_assert_msg(expected_children_count, "There must be at least 1 child to test");
|
||||
unsigned int actual_children_count = 0;
|
||||
|
||||
Eo *child = efl_model_first_child_get(object);
|
||||
efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _children_wait, NULL);
|
||||
expected_children_count = efl_model_children_count_get(object);
|
||||
|
||||
if (!expected_children_count)
|
||||
{
|
||||
ecore_main_loop_begin();
|
||||
expected_children_count = efl_model_children_count_get(object);
|
||||
}
|
||||
|
||||
fail_if(expected_children_count == 0);
|
||||
|
||||
future = efl_model_children_slice_get(object, 0, 1);
|
||||
eina_future_then(future, _one_child, &child);
|
||||
ecore_main_loop_begin();
|
||||
|
||||
fail_if(!child);
|
||||
efl_model_child_del(object, child);
|
||||
|
||||
future = NULL;
|
||||
unsigned int actual_children_count = 0;
|
||||
future = efl_model_children_count_get(object);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
actual_children_count = efl_model_children_count_get(object);
|
||||
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
|
|
@ -14,11 +14,34 @@
|
|||
static Eo *dbus_object1 = NULL;
|
||||
static Eo *dbus_proxy = NULL;
|
||||
|
||||
static Eina_Value
|
||||
_leave(void *data EINA_UNUSED, const Eina_Value v,
|
||||
const Eina_Future *dead EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
Eina_Future *f;
|
||||
|
||||
f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
|
||||
eina_future_then(f, _leave, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_setup(void)
|
||||
{
|
||||
dbus_object1 = create_object();
|
||||
|
||||
efl_event_callback_add(dbus_object1, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
efl_model_children_count_get(dbus_object1);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
dbus_proxy = eldbus_model_proxy_from_object_get(dbus_object1, ELDBUS_FDO_INTERFACE);
|
||||
ck_assert_ptr_ne(NULL, dbus_proxy);
|
||||
}
|
||||
|
@ -46,16 +69,23 @@ EFL_END_TEST
|
|||
EFL_START_TEST(property_get)
|
||||
{
|
||||
// Nonexistent property must return ERROR
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(dbus_proxy, "nonexistent");
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
Eina_Value *value;
|
||||
Eina_Error err = 0;
|
||||
|
||||
value = efl_model_property_get(dbus_proxy, "nonexistent");
|
||||
|
||||
fail_if(eina_value_type_get(value) != EINA_VALUE_TYPE_ERROR);
|
||||
eina_value_error_get(value, &err);
|
||||
fail_if(err != EFL_MODEL_ERROR_NOT_FOUND);
|
||||
|
||||
eina_value_free(value);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
Eina_Value value;
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
|
||||
// Nonexistent property must return ERROR
|
||||
eina_value_setup(&value, EINA_VALUE_TYPE_INT);
|
||||
|
@ -69,6 +99,11 @@ EFL_END_TEST
|
|||
static void
|
||||
_test_dbus_proxy_children_count(Eo *efl_model)
|
||||
{
|
||||
efl_event_callback_add(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
efl_model_children_count_get(efl_model);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
// 'org.freedesktop.DBus::AddMatch' and 'org.freedesktop.DBus::ListNames' at least
|
||||
check_efl_model_children_count_ge(efl_model, 2);
|
||||
}
|
||||
|
@ -81,6 +116,11 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(children_slice_get)
|
||||
{
|
||||
efl_event_callback_add(dbus_proxy, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
|
||||
efl_model_children_count_get(dbus_proxy);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
check_efl_model_children_slice_get(dbus_proxy);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
@ -95,18 +135,18 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(child_del)
|
||||
{
|
||||
Eina_Future *future;
|
||||
Eo *child;
|
||||
unsigned int expected_children_count = 0;
|
||||
Efl_Future *future;
|
||||
future = efl_model_children_count_get(dbus_proxy);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
expected_children_count = efl_model_future_then_u(future);
|
||||
unsigned int actual_children_count = 0;
|
||||
|
||||
Eo *child = efl_model_first_child_get(dbus_proxy);
|
||||
expected_children_count = efl_model_children_count_get(dbus_proxy);
|
||||
ck_assert_ptr_ne(NULL, future);
|
||||
|
||||
child = efl_model_first_child_get(dbus_proxy);
|
||||
efl_model_child_del(dbus_proxy, child);
|
||||
|
||||
unsigned int actual_children_count = 0;
|
||||
future = efl_model_children_count_get(dbus_proxy);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
actual_children_count = efl_model_children_count_get(dbus_proxy);
|
||||
|
||||
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,10 @@ _setup(void)
|
|||
{
|
||||
fake_server = fake_server_start(&fake_server_data);
|
||||
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH));
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
|
||||
eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
|
||||
eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
|
||||
eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
|
||||
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||
|
||||
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||
|
@ -58,22 +61,29 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(property_get)
|
||||
{
|
||||
Eina_Value *value;
|
||||
Eina_Error err;
|
||||
|
||||
// Signal properties always have output direction
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(pong_signal, ARGUMENT_A);
|
||||
efl_model_future_then(future);
|
||||
value = efl_model_property_get(pong_signal, ARGUMENT_A);
|
||||
fail_if(value == NULL);
|
||||
|
||||
// Nonexistent property must return ERROR
|
||||
future = efl_model_property_get(pong_signal, "nonexistent");
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND);
|
||||
value = efl_model_property_get(pong_signal, "nonexistent");
|
||||
fail_if(value == NULL);
|
||||
fail_if(eina_value_type_get(value) != EINA_VALUE_TYPE_ERROR);
|
||||
|
||||
eina_value_error_get(value, &err);
|
||||
fail_if(err != EFL_MODEL_ERROR_NOT_FOUND);
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
// Signals have output arguments only. All returns error
|
||||
Efl_Future *future;
|
||||
Eina_Value dummy = {0};
|
||||
Eina_Value dummy = EINA_VALUE_EMPTY;
|
||||
Eina_Future *future;
|
||||
|
||||
future = efl_model_property_set(pong_signal, ARGUMENT_A, &dummy);
|
||||
check_efl_model_future_error(future, NULL);
|
||||
}
|
||||
|
@ -93,7 +103,8 @@ EFL_END_TEST
|
|||
|
||||
EFL_START_TEST(children_slice_get)
|
||||
{
|
||||
Efl_Future *future;
|
||||
Eina_Future *future;
|
||||
|
||||
future = efl_model_children_slice_get(pong_signal, 1, 1);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,10 @@ _setup(void)
|
|||
};
|
||||
fake_server = fake_server_start(&fake_server_data);
|
||||
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH));
|
||||
fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
|
||||
eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
|
||||
eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
|
||||
eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
|
||||
ck_assert_ptr_ne(NULL, fake_server_object);
|
||||
|
||||
fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
|
||||
|
@ -50,7 +53,8 @@ EFL_START_TEST(properties_get)
|
|||
const Eina_Array *properties = efl_model_properties_get(fake_server_proxy);
|
||||
ck_assert_ptr_ne(NULL, properties);
|
||||
|
||||
const unsigned int expected_properties_count = 3; // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
|
||||
// FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
|
||||
const unsigned int expected_properties_count = 3;
|
||||
const unsigned int actual_properties_count = eina_array_count(properties);
|
||||
ck_assert_int_eq(expected_properties_count, actual_properties_count);
|
||||
|
||||
|
@ -58,15 +62,43 @@ EFL_START_TEST(properties_get)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static Eina_Future *f = NULL;
|
||||
|
||||
static Eina_Value
|
||||
_leave(void *data EINA_UNUSED, const Eina_Value v,
|
||||
const Eina_Future *dead EINA_UNUSED)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
f = NULL;
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
_property_ready(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||
{
|
||||
if (f) return ;
|
||||
f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
|
||||
eina_future_then(f, _leave, NULL);
|
||||
}
|
||||
|
||||
EFL_START_TEST(property_get)
|
||||
{
|
||||
Eina_Value *value;
|
||||
|
||||
efl_event_callback_add(fake_server_proxy, EFL_MODEL_EVENT_PROPERTIES_CHANGED, _property_ready, NULL);
|
||||
value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY);
|
||||
eina_value_free(value);
|
||||
value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY);
|
||||
eina_value_free(value);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE);
|
||||
check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE);
|
||||
|
||||
// Write-only property returns error
|
||||
Efl_Future *future;
|
||||
future = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY);
|
||||
(void)future;
|
||||
value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY);
|
||||
eina_value_free(value);
|
||||
//ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
|
||||
|
||||
_teardown();
|
||||
|
@ -89,12 +121,13 @@ _check_property_set(const char *property_name, int expected_property_value, int
|
|||
|
||||
EFL_START_TEST(property_set)
|
||||
{
|
||||
Eina_Future *future;
|
||||
Eina_Value dummy = EINA_VALUE_EMPTY;
|
||||
|
||||
_check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property);
|
||||
_check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property);
|
||||
|
||||
// Read-only property returns error
|
||||
Efl_Future *future;
|
||||
Eina_Value dummy = {0};
|
||||
future = efl_model_property_set(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, &dummy);
|
||||
check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY);
|
||||
|
||||
|
@ -155,20 +188,18 @@ EFL_END_TEST
|
|||
EFL_START_TEST(child_del)
|
||||
{
|
||||
// Tests that it is not possible to delete children
|
||||
Efl_Future *future;
|
||||
Eo *child;
|
||||
unsigned int expected_children_count = 0;
|
||||
future = efl_model_children_count_get(fake_server_proxy);
|
||||
expected_children_count = efl_model_future_then_u(future);
|
||||
unsigned int actual_children_count = 0;
|
||||
|
||||
expected_children_count = efl_model_children_count_get(fake_server_proxy);
|
||||
ck_assert_msg(expected_children_count, "There must be at least 1 child to test");
|
||||
|
||||
// efl_model_child_del always returns ERROR
|
||||
Eo *child = efl_model_first_child_get(fake_server_proxy);
|
||||
child = efl_model_first_child_get(fake_server_proxy);
|
||||
efl_model_child_del(fake_server_proxy, child);
|
||||
|
||||
unsigned int actual_children_count = 0;
|
||||
future = efl_model_children_count_get(fake_server_proxy);
|
||||
actual_children_count = efl_model_future_then_u(future);
|
||||
|
||||
actual_children_count = efl_model_children_count_get(fake_server_proxy);
|
||||
ck_assert_int_le(expected_children_count, actual_children_count);
|
||||
|
||||
_teardown();
|
||||
|
|
Loading…
Reference in New Issue