summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-08-05 10:17:52 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-08-05 10:18:18 -0400
commit40def3eac914138189163a895527705a1ffefcfd (patch)
treee77fc891713de50ca312b080474260d34d7d36df /src/tests
parent7c72f101532d61b00cd483b89ef86830526a82ba (diff)
efl-mono: Add Model manual implementation to C# and MVVM factories
Summary: Depends on D9273, D9270 Test Plan: Run added testcases. Reviewers: cedric, bu5hm4n, zmike, SanghyeonLee, felipealmeida, segfaultxavi Reviewed By: cedric Subscribers: cedric Tags: #expertise_solutions, #efl_language_bindings Differential Revision: https://phab.enlightenment.org/D8080
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl_mono/Main.cs2
-rw-r--r--src/tests/efl_mono/Model.cs83
-rw-r--r--src/tests/efl_mono/meson.build3
3 files changed, 86 insertions, 2 deletions
diff --git a/src/tests/efl_mono/Main.cs b/src/tests/efl_mono/Main.cs
index f154f935eb..06add7edd2 100644
--- a/src/tests/efl_mono/Main.cs
+++ b/src/tests/efl_mono/Main.cs
@@ -15,7 +15,7 @@ class TestMain
15 15
16 static int Main(string[] args) 16 static int Main(string[] args)
17 { 17 {
18 Efl.All.Init(); 18 Efl.All.Init(Efl.Csharp.Components.Ui);
19 19
20 bool pass = true; 20 bool pass = true;
21 21
diff --git a/src/tests/efl_mono/Model.cs b/src/tests/efl_mono/Model.cs
new file mode 100644
index 0000000000..a43d9da51c
--- /dev/null
+++ b/src/tests/efl_mono/Model.cs
@@ -0,0 +1,83 @@
1#define CODE_ANALYSIS
2
3using System;
4using System.Threading.Tasks;
5using System.Diagnostics.CodeAnalysis;
6
7#if EFL_BETA
8
9namespace TestSuite {
10
11[SuppressMessage("Gendarme.Rules.Portability", "DoNotHardcodePathsRule")]
12public class TestModel {
13
14 public class VeggieViewModel
15 {
16 public string Name { get; set; }
17 public string Type { get; set; }
18 public string Image { get; set; }
19 }
20
21 private static Efl.UserModel<VeggieViewModel> CreateModel(Efl.Loop loop)
22 {
23 Efl.UserModel<VeggieViewModel> veggies = new Efl.UserModel<VeggieViewModel>(loop);
24 veggies.Add (new VeggieViewModel{ Name="Tomato", Type="Fruit", Image="tomato.png"});
25 veggies.Add (new VeggieViewModel{ Name="Romaine Lettuce", Type="Vegetable", Image="lettuce.png"});
26 veggies.Add (new VeggieViewModel{ Name="Zucchini", Type="Vegetable", Image="zucchini.png"});
27
28 return veggies;
29 }
30
31 public static void reflection_test ()
32 {
33 Efl.Loop loop = Efl.App.AppMain;
34
35 var veggies = CreateModel(loop);
36 }
37
38 internal static async Task EasyModelExtractionAsync (Efl.Loop loop)
39 {
40 var veggies = CreateModel(loop);
41
42 var model = new Efl.GenericModel<VeggieViewModel>(veggies, loop);
43 Test.AssertEquals(3, (int)model.GetChildrenCount());
44
45 VeggieViewModel r2 = await model.GetAtAsync(1);
46 Test.AssertEquals(r2.Name, "Romaine Lettuce");
47
48 VeggieViewModel r = await model.GetAtAsync(0);
49 Test.AssertEquals(r.Name, "Tomato");
50
51 loop.End();
52 }
53
54 public static void easy_model_extraction ()
55 {
56 Efl.Loop loop = Efl.App.AppMain;
57 Task task = EasyModelExtractionAsync(loop);
58
59 loop.Begin();
60
61 task.Wait();
62 }
63
64 public static void factory_test ()
65 {
66 string propertyBound = null;
67 bool callbackCalled = false;
68 var factory = new Efl.Ui.ItemFactory<Efl.Ui.Button>();
69 factory.PropertyBoundEvt += (object sender, Efl.Ui.IPropertyBindPropertyBoundEvt_Args args) => {
70 propertyBound = args.arg;
71 callbackCalled = true;
72 };
73
74 factory.Style().Bind("first name");
75
76 Test.Assert(callbackCalled, "Property bound callback must have been called.");
77 Test.AssertEquals(propertyBound, "style");
78 }
79}
80
81}
82
83#endif
diff --git a/src/tests/efl_mono/meson.build b/src/tests/efl_mono/meson.build
index e464cdd2a8..445c823caa 100644
--- a/src/tests/efl_mono/meson.build
+++ b/src/tests/efl_mono/meson.build
@@ -72,6 +72,7 @@ efl_mono_src = [
72 'Events.cs', 72 'Events.cs',
73 'FunctionPointers.cs', 73 'FunctionPointers.cs',
74 'FunctionPointerMarshalling.cs', 74 'FunctionPointerMarshalling.cs',
75 'Model.cs',
75 'Parts.cs', 76 'Parts.cs',
76 'Promises.cs', 77 'Promises.cs',
77 'Strbuf.cs', 78 'Strbuf.cs',
@@ -111,7 +112,7 @@ custom_target('copy_efl_mono_lib_dll',
111 command : [copy_prog, '@INPUT@', '@OUTPUT@']) 112 command : [copy_prog, '@INPUT@', '@OUTPUT@'])
112endif 113endif
113 114
114config_libs = ['eina', 'ecore', 'eo', 'efl', 'evas', 'eldbus', 'elementary'] 115config_libs = ['eina', 'ecore', 'eo', 'efl', 'evas', 'eldbus', 'elementary', 'efl_mono']
115load_lib = efl_mono_test_suite_path + ':' 116load_lib = efl_mono_test_suite_path + ':'
116 117
117foreach config : config_libs 118foreach config : config_libs