diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-03-14 19:57:53 -0300 |
---|---|---|
committer | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-03-15 18:23:10 -0300 |
commit | e63b657e8ba9b6cad4feeac59f186915c56db09f (patch) | |
tree | 6a42358355e9f4b142b0ba5497d1d1446897fe81 | |
parent | 26c63a5770727c85932eb6f3dce723ad902abff6 (diff) | |
download | efl-e63b657e8ba9b6cad4feeac59f186915c56db09f.tar.gz |
csharp: Add test for interface event implementation.
-rw-r--r-- | src/tests/efl_mono/Events.cs | 32 | ||||
-rw-r--r-- | src/tests/efl_mono/dummy_test_object.eo | 14 | ||||
-rw-r--r-- | src/tests/efl_mono/libefl_mono_native_test.c | 33 |
3 files changed, 78 insertions, 1 deletions
diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs index 2d6dedb8e9..4a6032c691 100644 --- a/src/tests/efl_mono/Events.cs +++ b/src/tests/efl_mono/Events.cs @@ -274,4 +274,36 @@ class TestEventNaming } } + +class TestImplementedEvent +{ + private class IfaceImplement : Efl.Object, Dummy.TestIface + { + public IfaceImplement() : base(null) { } + + // Methods from TestIface + public event EventHandler ConflictedEvt; + public event EventHandler NonconflictedEvt; + + public void EmitTestConflicted() { } + public void EmitNonconflicted() { } + + public int GetIfaceProp() { return 0; } + public void SetIfaceProp(int x) { } + public int IfaceProp { + get { return GetIfaceProp(); } + set { SetIfaceProp(value); } + } + } + + public static void test_interface_events_implementation() + { + var obj = new Dummy.TestObject(); + var provider = new IfaceImplement(); + obj.SetIfaceProvider(provider); + provider.EmitNonconflicted(); + Test.Assert(obj.GetProviderCallbackCalled()); + } + +} } diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo index 0d6ced8e62..4c469b5c93 100644 --- a/src/tests/efl_mono/dummy_test_object.eo +++ b/src/tests/efl_mono/dummy_test_object.eo @@ -1388,6 +1388,20 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface, Dummy.An get_setter_only { return: int; } + + set_iface_provider { + params { + @in provider: Dummy.Test_Iface; + } + } + + @property provider_callback_called { + get {} + set {} + values { + prop: bool; + } + } } implements { class.constructor; diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c index b02abdefd4..115e82c8b6 100644 --- a/src/tests/efl_mono/libefl_mono_native_test.c +++ b/src/tests/efl_mono/libefl_mono_native_test.c @@ -46,9 +46,9 @@ #endif #include "dummy_numberwrapper.eo.h" +#include "dummy_test_iface.eo.h" #include "dummy_test_object.eo.h" #include "dummy_child.eo.h" -#include "dummy_test_iface.eo.h" #include "dummy_another_iface.eo.h" #include "dummy_inherit_iface.eo.h" #include "dummy_inherit_helper.eo.h" @@ -74,6 +74,7 @@ typedef struct Dummy_Test_Object_Data int iface_prop; Eo *provider; Eo *iface_provider; + Eina_Bool provider_callback_called; } Dummy_Test_Object_Data; typedef struct Dummy_Numberwrapper_Data @@ -3940,6 +3941,36 @@ Eo * _dummy_test_object_efl_object_provider_find(EINA_UNUSED const Eo *obj, Dumm return efl_provider_find(efl_super(obj, DUMMY_TEST_OBJECT_CLASS), klass); } +void _provider_callback_called_cb(void *data, const Efl_Event *event EINA_UNUSED) +{ + Eo *obj = data; + dummy_test_object_provider_callback_called_set(obj, EINA_TRUE); +} + +void _dummy_test_object_set_iface_provider(Eo *obj, Dummy_Test_Object_Data *pd, Eo *provider) +{ + if (pd->iface_provider) + { + efl_parent_set(pd->iface_provider, NULL); + efl_unref(pd->iface_provider); + pd->iface_provider = NULL; + } + pd->iface_provider = provider; + efl_parent_set(provider, obj); + dummy_test_object_provider_callback_called_set(obj, EINA_FALSE); + efl_event_callback_add(provider, DUMMY_TEST_IFACE_EVENT_NONCONFLICTED, _provider_callback_called_cb, obj); +} + +void _dummy_test_object_provider_callback_called_set(EINA_UNUSED Eo *obj, Dummy_Test_Object_Data *pd, Eina_Bool prop) +{ + pd->provider_callback_called = prop; +} + +Eina_Bool _dummy_test_object_provider_callback_called_get(const Eo *obj, Dummy_Test_Object_Data *pd) +{ + return pd->provider_callback_called; +} + /// Dummy.Child static Efl_Object * |