summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Eo.cs
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-11-23 21:53:28 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-04 15:47:50 -0300
commit345336c46dd7ceb04005305c5dc567d402db0dce (patch)
tree9c3dd8c12b7b3f2684512069c0e7d8004699999f /src/tests/efl_mono/Eo.cs
parentd93e9ff286ce1961f530d56b5536881f47104ebd (diff)
efl_mono: Added test files for the C# bindings.
Buildsystem integration will come in a future commit.
Diffstat (limited to 'src/tests/efl_mono/Eo.cs')
-rw-r--r--src/tests/efl_mono/Eo.cs194
1 files changed, 194 insertions, 0 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
new file mode 100644
index 0000000000..60d66821c7
--- /dev/null
+++ b/src/tests/efl_mono/Eo.cs
@@ -0,0 +1,194 @@
1using System;
2
3namespace TestSuite
4{
5
6class TestEo
7{
8 private class Derived : test.TestingInherit
9 {
10 }
11
12 //
13 // Test cases:
14 //
15 public static void return_same_object()
16 {
17 test.Testing testing = new test.TestingConcrete();
18 test.Testing o1 = testing.ReturnObject();
19 Test.Assert(o1.raw_handle != IntPtr.Zero);
20 Test.Assert(o1.raw_handle == testing.raw_handle);
21 test.Testing o2 = o1.ReturnObject();
22 Test.Assert(o2.raw_handle != IntPtr.Zero);
23 Test.Assert(o2.raw_handle == o1.raw_handle);
24 }
25
26 /* Commented out as adding the event listener seems to prevent it from being GC'd.
27 public static void destructor_really_frees()
28 {
29 bool delEventCalled = false;
30 {
31 test.Testing obj = new test.TestingConcrete();
32 obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
33 }
34
35 System.GC.WaitForPendingFinalizers();
36 System.GC.Collect();
37 System.GC.WaitForPendingFinalizers();
38 System.GC.Collect();
39 System.GC.WaitForPendingFinalizers();
40
41 Test.Assert(delEventCalled, "DEL event not called");
42 } */
43
44 public static void dispose_really_frees()
45 {
46 bool delEventCalled = false;
47 {
48 test.Testing obj = new test.TestingConcrete();
49 obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
50 ((IDisposable)obj).Dispose();
51 }
52
53 Test.Assert(delEventCalled, "DEL event not called");
54 }
55
56 /* Commented out as adding the event listener seems to prevent it from being GC'd.
57 public static void derived_destructor_really_frees()
58 {
59 bool delEventCalled = false;
60 {
61 test.Testing obj = new Derived();
62 obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
63 }
64
65 System.GC.WaitForPendingFinalizers();
66 System.GC.Collect();
67 System.GC.WaitForPendingFinalizers();
68 System.GC.Collect();
69 System.GC.WaitForPendingFinalizers();
70
71 Test.Assert(delEventCalled, "DEL event not called");
72 }
73
74 public static void derived_dispose_really_frees()
75 {
76 bool delEventCalled = false;
77 {
78 test.Testing obj = new Derived();
79 obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
80 ((IDisposable)obj).Dispose();
81 }
82
83 Test.Assert(delEventCalled, "DEL event not called");
84 }
85 */
86}
87
88class MyLoop : efl.LoopInherit
89{
90 public MyLoop() : base(null) { }
91}
92
93class TestEoInherit
94{
95 public static void instantiate_inherited()
96 {
97 efl.Loop loop = new MyLoop();
98 Test.Assert(loop.raw_handle != System.IntPtr.Zero);
99 }
100}
101
102class TestEoNames
103{
104 public static void name_getset()
105 {
106 test.Testing obj = new test.TestingConcrete();
107
108 string name = "Dummy";
109 obj.SetName(name);
110 Test.AssertEquals(name, obj.GetName());
111 }
112}
113
114class TestEoConstructingMethods
115{
116 public static void constructing_method()
117 {
118 bool called = false;
119 string name = "Test object";
120 test.Testing obj = new test.TestingConcrete(null, (test.Testing a) => {
121 called = true;
122 Console.WriteLine("callback: obj raw_handle: {0:x}", a.raw_handle);
123 a.SetName(name);
124 });
125
126 Test.Assert(called);
127 Test.AssertEquals(name, obj.GetName());
128 }
129
130 private class Derived : test.TestingInherit
131 {
132 public Derived(test.Testing parent = null,
133 test.TestingInherit.ConstructingMethod cb = null) : base(parent, cb) {
134 }
135 }
136
137 public static void constructing_method_inherit()
138 {
139 bool called = false;
140 string name = "Another test object";
141 Derived obj = new Derived(null, (test.Testing a) => {
142 called = true;
143 a.SetComment(name);
144 });
145
146 Test.Assert(called);
147 Test.AssertEquals(name, obj.GetComment());
148 }
149}
150
151class TestEoParent
152{
153 public static void basic_parent()
154 {
155 test.Testing parent = new test.TestingConcrete(null);
156 test.Testing child = new test.TestingConcrete(parent);
157
158 Test.AssertEquals(parent, child.GetParent());
159
160 test.Testing parent_retrieved = test.TestingConcrete.static_cast(child.GetParent());
161 Test.AssertEquals(parent, parent_retrieved);
162 }
163
164 public static void parent_inherited_class()
165 {
166 test.Numberwrapper parent = new test.NumberwrapperConcrete(null);
167 test.Testing child = new test.TestingConcrete(parent);
168
169 Test.AssertEquals(parent, child.GetParent());
170
171 test.Numberwrapper parent_retrieved = test.NumberwrapperConcrete.static_cast(child.GetParent());
172 Test.AssertEquals(parent, parent_retrieved);
173 }
174
175 private class Derived : test.TestingInherit
176 {
177 public Derived(test.Testing parent = null) : base (parent)
178 {
179 }
180 }
181
182 public static void basic_parent_managed_inherit()
183 {
184 test.Testing parent = new Derived(null);
185 test.Testing child = new Derived(parent);
186
187 Test.AssertEquals(parent, child.GetParent());
188
189 test.Testing parent_from_cast = test.TestingInherit.static_cast(child.GetParent());
190 Test.AssertEquals(parent, parent_from_cast);
191 }
192}
193
194}