efl_mono: Actually test events by passing things by value and structs
Summary: While the test events were declared as by value, the support code passed by reference, which was - wrongly - the only implementation supported in event code. Also added test with Eina_Bool and structs (passed by pointer to events, while not having the ptr modifier explicitly. Depends on D5995 Reviewers: felipealmeida Reviewed By: felipealmeida Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D5996
This commit is contained in:
parent
a413914c18
commit
ff1fda829d
|
@ -62,6 +62,24 @@ class TestEoEvents
|
|||
Test.AssertEquals(-1984, received_int);
|
||||
}
|
||||
|
||||
public static void event_with_bool_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
bool received_bool = false;
|
||||
|
||||
obj.EvtWithBoolEvt += (object sender, test.EvtWithBoolEvt_Args e) => {
|
||||
received_bool = e.arg;
|
||||
};
|
||||
|
||||
obj.EmitEventWithBool(true);
|
||||
|
||||
Test.AssertEquals(true, received_bool);
|
||||
|
||||
obj.EmitEventWithBool(false);
|
||||
|
||||
Test.AssertEquals(false, received_bool);
|
||||
}
|
||||
|
||||
public static void event_with_uint_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
|
@ -75,20 +93,6 @@ class TestEoEvents
|
|||
Test.AssertEquals<uint>(0xbeef, received_uint);
|
||||
}
|
||||
|
||||
public static void event_with_float_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
float received_float= 0;
|
||||
|
||||
obj.EvtWithFloatEvt += (object sender, test.EvtWithFloatEvt_Args e) => {
|
||||
received_float = e.arg;
|
||||
};
|
||||
|
||||
obj.EmitEventWithFloat(3.14f);
|
||||
|
||||
Test.AssertEquals(3.14f, received_float);
|
||||
}
|
||||
|
||||
public static void event_with_object_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
|
@ -104,5 +108,38 @@ class TestEoEvents
|
|||
|
||||
Test.AssertEquals(sent_obj, received_obj);
|
||||
}
|
||||
|
||||
public static void event_with_error_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
eina.Error received_error = 0;
|
||||
|
||||
obj.EvtWithErrorEvt += (object sender, test.EvtWithErrorEvt_Args e) => {
|
||||
received_error = e.arg;
|
||||
};
|
||||
|
||||
eina.Error sent_error = -2001;
|
||||
|
||||
obj.EmitEventWithError(sent_error);
|
||||
|
||||
Test.AssertEquals(sent_error, received_error);
|
||||
}
|
||||
|
||||
public static void event_with_struct_payload()
|
||||
{
|
||||
test.Testing obj = new test.TestingConcrete();
|
||||
test.StructSimple received_struct = default(test.StructSimple);
|
||||
|
||||
obj.EvtWithStructEvt += (object sender, test.EvtWithStructEvt_Args e) => {
|
||||
received_struct = e.arg;
|
||||
};
|
||||
|
||||
test.StructSimple sent_struct = default(test.StructSimple);
|
||||
sent_struct.Fstring = "Struct Event";
|
||||
|
||||
obj.EmitEventWithStruct(sent_struct);
|
||||
|
||||
Test.AssertEquals(sent_struct.Fstring, received_struct.Fstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3719,19 +3719,19 @@ void _test_testing_emit_event_with_string(Eo *obj, EINA_UNUSED Test_Testing_Data
|
|||
free(ptr);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_bool(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Bool data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_BOOL, (void *) (uintptr_t) data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_int(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, int data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_INT, &data);
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_INT, (void *) (uintptr_t) data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_uint(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, unsigned int data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_UINT, &data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_float(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, float data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_FLOAT, &data);
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_UINT, (void *) (uintptr_t) data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_obj(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eo *data)
|
||||
|
@ -3739,6 +3739,17 @@ void _test_testing_emit_event_with_obj(Eo *obj, EINA_UNUSED Test_Testing_Data *p
|
|||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_OBJ, data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_error(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Error data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_ERROR, &data);
|
||||
}
|
||||
|
||||
void _test_testing_emit_event_with_struct(Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Test_StructSimple data)
|
||||
{
|
||||
efl_event_callback_legacy_call(obj, TEST_TESTING_EVENT_EVT_WITH_STRUCT, &data);
|
||||
}
|
||||
|
||||
|
||||
Efl_Object *_test_testing_efl_part_part(EINA_UNUSED const Eo *obj, Test_Testing_Data *pd, const char *name)
|
||||
{
|
||||
if (!strcmp(name, "part1"))
|
||||
|
|
|
@ -1541,6 +1541,11 @@ class Test.Testing (Efl.Object, Efl.Part) {
|
|||
@in data: string;
|
||||
}
|
||||
}
|
||||
emit_event_with_bool {
|
||||
params {
|
||||
@in data: bool;
|
||||
}
|
||||
}
|
||||
emit_event_with_int {
|
||||
params {
|
||||
@in data: int;
|
||||
|
@ -1551,17 +1556,24 @@ class Test.Testing (Efl.Object, Efl.Part) {
|
|||
@in data: uint;
|
||||
}
|
||||
}
|
||||
emit_event_with_float {
|
||||
params {
|
||||
@in data: float;
|
||||
}
|
||||
}
|
||||
emit_event_with_obj {
|
||||
params {
|
||||
@in data: Test.Testing;
|
||||
}
|
||||
}
|
||||
|
||||
emit_event_with_error {
|
||||
params {
|
||||
@in data: Eina.Error;
|
||||
}
|
||||
}
|
||||
|
||||
emit_event_with_struct {
|
||||
params {
|
||||
@in data: Test.StructSimple;
|
||||
}
|
||||
}
|
||||
|
||||
append_to_strbuf {
|
||||
params {
|
||||
@in buf: strbuf;
|
||||
|
@ -1600,9 +1612,11 @@ class Test.Testing (Efl.Object, Efl.Part) {
|
|||
}
|
||||
events {
|
||||
evt,with,string @hot: string;
|
||||
evt,with,bool: bool;
|
||||
evt,with,int @hot: int;
|
||||
evt,with,uint @hot: uint;
|
||||
evt,with,float @hot: float;
|
||||
evt,with,obj @hot: Test.Testing;
|
||||
evt,with,error @hot: Eina.Error;
|
||||
evt,with,struct @hot: Test.StructSimple;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue