summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-03-19 20:35:36 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2018-03-20 16:50:30 -0300
commitf9586a831b8ba13542f59c9e1143c3d7b276bd51 (patch)
treebf1c81ace60441c4cf4007709ae32580db8ee58d /src/tests/efl_mono
parent9a6dd32cb1e8f5b1bcd23d32fc4b2d5fa425abbd (diff)
downloadefl-f9586a831b8ba13542f59c9e1143c3d7b276bd51.tar.gz
csharp: Add support for efl parts as Properties
Instead of var bg = efl.ui.Background.static_cast(myobj.Part("background")); Now do var bg = myobj.Background; Also a couple helper functions were added.
Diffstat (limited to 'src/tests/efl_mono')
-rw-r--r--src/tests/efl_mono/Parts.cs41
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c26
-rw-r--r--src/tests/efl_mono/test_testing.eo8
3 files changed, 74 insertions, 1 deletions
diff --git a/src/tests/efl_mono/Parts.cs b/src/tests/efl_mono/Parts.cs
new file mode 100644
index 0000000000..b6ed9a882c
--- /dev/null
+++ b/src/tests/efl_mono/Parts.cs
@@ -0,0 +1,41 @@
+#define CODE_ANALYSIS
+
+#pragma warning disable 1591
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+
+namespace TestSuite {
+
+
+[SuppressMessage("Gendarme.Rules.Portability", "DoNotHardcodePathsRule")]
+public static class TestParts
+{
+ public static void basic_part_test()
+ {
+ test.Testing t = new test.TestingConcrete();
+ do_part_test(t);
+ }
+
+ private class Child : test.TestingInherit
+ {
+ public Child() : base(null) {}
+ }
+
+ public static void inherited_part_test() {
+ var t = new Child();
+ do_part_test(t);
+ }
+
+ private static void do_part_test(test.Testing t)
+ {
+ var p1 = t.Part1;
+ var p2 = t.Part2;
+ Test.Assert(p1 is test.Testing);
+ Test.AssertEquals("part1", p1.GetName());
+ Test.Assert(p2 is test.Testing);
+ Test.AssertEquals("part2", p2.GetName());
+ }
+}
+
+}
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 04fd12053f..19fe984022 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -34,6 +34,8 @@
#include "test_numberwrapper.eo.h"
#include "test_testing.eo.h"
+#include <interfaces/efl_part.eo.h>
+
#define EQUAL(a, b) ((a) == (b) ? 1 : (fprintf(stderr, "NOT EQUAL! %s:%i (%s)", __FILE__, __LINE__, __FUNCTION__), fflush(stderr), 0))
#define STR_EQUAL(a, b) (strcmp((a), (b)) == 0 ? 1 : (fprintf(stderr, "NOT EQUAL! %s:%i (%s) '%s' != '%s'", __FILE__, __LINE__, __FUNCTION__, (a), (b)), fflush(stderr), 0))
@@ -46,6 +48,8 @@ typedef struct Test_Testing_Data
Eina_Value *stored_value;
Test_StructSimple stored_struct;
int stored_int;
+ Eo *part1;
+ Eo *part2;
} Test_Testing_Data;
typedef struct Test_Numberwrapper_Data
@@ -3714,6 +3718,28 @@ 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);
}
+Efl_Object *_test_testing_efl_part_part(const Eo *obj, Test_Testing_Data *pd, const char *name)
+{
+ if (!strcmp(name, "part1"))
+ {
+ if (pd->part1 == NULL)
+ {
+ pd->part1 = efl_add(TEST_TESTING_CLASS, obj, efl_name_set(efl_added, "part1"));
+ }
+ return pd->part1;
+ }
+ else if (!strcmp(name, "part2"))
+ {
+ if (pd->part2 == NULL)
+ {
+ pd->part2 = efl_add(TEST_TESTING_CLASS, obj, efl_name_set(efl_added, "part2"));
+ }
+ return pd->part2;
+ }
+ else
+ return NULL;
+}
+
#include "test_testing.eo.c"
#include "test_numberwrapper.eo.c"
diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo
index c2d3edcd2e..90d512e763 100644
--- a/src/tests/efl_mono/test_testing.eo
+++ b/src/tests/efl_mono/test_testing.eo
@@ -81,7 +81,12 @@ function Test.SimpleCb {
return: int;
};
-class Test.Testing (Efl.Object) {
+class Test.Testing (Efl.Object, Efl.Part) {
+
+ parts {
+ part1: Test.Testing; [[ Part number one. ]]
+ part2: Test.Testing; [[ Part number two. ]]
+ }
methods {
return_object {
return: Test.Testing;
@@ -1547,6 +1552,7 @@ class Test.Testing (Efl.Object) {
implements {
class.constructor;
class.destructor;
+ Efl.Part.part;
}
events {
evt,with,string @hot: string;