summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-14 17:19:12 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-14 17:19:12 -0300
commit87e5fc4c6a32f008ff0c8d30854f352587ff7e6c (patch)
treee3cc7f965ff92a370959522216c1424e80a315ed /src/tests/efl_mono
parent66a26a378bb380350f4e6a26e42f95e43e206194 (diff)
csharp: Remove test dependency on internal funcs
Summary: This will help cleaninup the EFL# API. Test Plan: run test suite Reviewers: YOhoho, felipealmeida, segfaultxavi, woohyun, brunobelo Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10365
Diffstat (limited to 'src/tests/efl_mono')
-rw-r--r--src/tests/efl_mono/Eina.cs2
-rw-r--r--src/tests/efl_mono/Eldbus.cs108
-rw-r--r--src/tests/efl_mono/Inheritance.cs6
3 files changed, 34 insertions, 82 deletions
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 5a9b94e..0c6212a 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -323,7 +323,7 @@ class TestEinaSlice
323 var binbuf = new Eina.Binbuf(base_seq); 323 var binbuf = new Eina.Binbuf(base_seq);
324 Test.Assert(binbuf.Handle != IntPtr.Zero); 324 Test.Assert(binbuf.Handle != IntPtr.Zero);
325 325
326 Eina.Slice slc = Eina.Binbuf.eina_binbuf_slice_get(binbuf.Handle); 326 Eina.Slice slc = binbuf.GetSlice();
327 327
328 Test.Assert(slc.GetBytes().SequenceEqual(base_seq)); 328 Test.Assert(slc.GetBytes().SequenceEqual(base_seq));
329 Test.Assert(base_seq.Length == (int)(slc.Len)); 329 Test.Assert(base_seq.Length == (int)(slc.Len));
diff --git a/src/tests/efl_mono/Eldbus.cs b/src/tests/efl_mono/Eldbus.cs
index 0c63a86..de1b142 100644
--- a/src/tests/efl_mono/Eldbus.cs
+++ b/src/tests/efl_mono/Eldbus.cs
@@ -16,31 +16,6 @@ public static class EldbusTestUtil
16 public const string DBusPath = "/org/freedesktop/DBus"; 16 public const string DBusPath = "/org/freedesktop/DBus";
17 17
18 [return: MarshalAs(UnmanagedType.U1)] public delegate bool Ecore_Task_Cb(IntPtr data); 18 [return: MarshalAs(UnmanagedType.U1)] public delegate bool Ecore_Task_Cb(IntPtr data);
19
20 public static Ecore_Task_Cb GetEcoreLoopClose()
21 {
22 if (_ecore_loop_close == null)
23 _ecore_loop_close = new Ecore_Task_Cb(_ecore_loop_close_impl);
24 return _ecore_loop_close;
25 }
26
27 [DllImport(efl.Libs.Ecore)] public static extern IntPtr
28 ecore_timer_add(double _in, Ecore_Task_Cb func, IntPtr data);
29 [DllImport(efl.Libs.Ecore)] public static extern IntPtr
30 ecore_timer_del(IntPtr timer);
31
32 [DllImport(efl.Libs.Ecore)] public static extern void
33 ecore_main_loop_begin();
34 [DllImport(efl.Libs.Ecore)] public static extern void
35 ecore_main_loop_quit();
36
37
38 static private bool _ecore_loop_close_impl(IntPtr data)
39 {
40 ecore_main_loop_quit();
41 return false;
42 }
43 static private Ecore_Task_Cb _ecore_loop_close = null;
44} 19}
45 20
46namespace TestSuite 21namespace TestSuite
@@ -84,6 +59,7 @@ class TestEldbusObject
84{ 59{
85 public static void utc_eldbus_object_send_info_get_p() 60 public static void utc_eldbus_object_send_info_get_p()
86 { 61 {
62 var app = Efl.App.AppMain;
87 var conn = new eldbus.Connection(eldbus.Connection.Type.Session); 63 var conn = new eldbus.Connection(eldbus.Connection.Type.Session);
88 64
89 var obj = new eldbus.Object(conn, DBusBus, DBusPath); 65 var obj = new eldbus.Object(conn, DBusBus, DBusPath);
@@ -105,7 +81,6 @@ class TestEldbusObject
105 connectionFromObj.Dispose(); 81 connectionFromObj.Dispose();
106 } 82 }
107 83
108 IntPtr timeout = IntPtr.Zero;
109 int messageCapture = 0; 84 int messageCapture = 0;
110 bool isSuccess = false; 85 bool isSuccess = false;
111 86
@@ -113,12 +88,6 @@ class TestEldbusObject
113 { 88 {
114 try 89 try
115 { 90 {
116 if (timeout != IntPtr.Zero)
117 {
118 ecore_timer_del(timeout);
119 timeout = IntPtr.Zero;
120 }
121
122 string errname; 91 string errname;
123 string errmsg; 92 string errmsg;
124 93
@@ -137,7 +106,7 @@ class TestEldbusObject
137 } 106 }
138 finally 107 finally
139 { 108 {
140 ecore_main_loop_quit(); 109 app.Quit(0);
141 } 110 }
142 }; 111 };
143 112
@@ -148,15 +117,18 @@ class TestEldbusObject
148 117
149 AssertEquals(pending.GetMethod(), methodName); 118 AssertEquals(pending.GetMethod(), methodName);
150 119
151 timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero); 120 var timer = new Efl.LoopTimer(app, 2.0);
152 Assert(timeout != IntPtr.Zero); 121 timer.TimerTickEvent += (object sender, EventArgs e) => {
122 app.Quit(0);
123 };
153 124
154 messageCapture = 5; 125 messageCapture = 5;
155 126
156 ecore_main_loop_begin(); 127 app.Begin();
157 128
158 Assert(isSuccess, $"Method {methodName} is not call"); 129 Assert(isSuccess, $"Method {methodName} is not call");
159 130
131 timer.Dispose();
160 message.Dispose(); 132 message.Dispose();
161 obj.Dispose(); 133 obj.Dispose();
162 conn.Dispose(); 134 conn.Dispose();
@@ -164,11 +136,11 @@ class TestEldbusObject
164 136
165 public static void utc_eldbus_introspect_p() 137 public static void utc_eldbus_introspect_p()
166 { 138 {
139 var app = Efl.App.AppMain;
167 var conn = new eldbus.Connection(eldbus.Connection.Type.Session); 140 var conn = new eldbus.Connection(eldbus.Connection.Type.Session);
168 141
169 var obj = new eldbus.Object(conn, DBusBus, DBusPath); 142 var obj = new eldbus.Object(conn, DBusBus, DBusPath);
170 143
171 IntPtr timeout = IntPtr.Zero;
172 int messageCapture = 0; 144 int messageCapture = 0;
173 bool isSuccess = false; 145 bool isSuccess = false;
174 146
@@ -176,12 +148,6 @@ class TestEldbusObject
176 { 148 {
177 try 149 try
178 { 150 {
179 if (timeout != IntPtr.Zero)
180 {
181 ecore_timer_del(timeout);
182 timeout = IntPtr.Zero;
183 }
184
185 string errname; 151 string errname;
186 string errmsg; 152 string errmsg;
187 153
@@ -200,7 +166,7 @@ class TestEldbusObject
200 } 166 }
201 finally 167 finally
202 { 168 {
203 ecore_main_loop_quit(); 169 app.Quit(0);
204 } 170 }
205 }; 171 };
206 172
@@ -208,15 +174,18 @@ class TestEldbusObject
208 174
209 AssertEquals(pending.GetMethod(), "Introspect"); 175 AssertEquals(pending.GetMethod(), "Introspect");
210 176
211 timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero); 177 var timer = new Efl.LoopTimer(app, 2.0);
212 Assert(timeout != IntPtr.Zero); 178 timer.TimerTickEvent += (object sender, EventArgs e) => {
179 app.Quit(0);
180 };
213 181
214 messageCapture = 5; 182 messageCapture = 5;
215 183
216 ecore_main_loop_begin(); 184 app.Begin();
217 185
218 Assert(isSuccess, "Method Introspect is not call"); 186 Assert(isSuccess, "Method Introspect is not call");
219 187
188 timer.Dispose();
220 obj.Dispose(); 189 obj.Dispose();
221 conn.Dispose(); 190 conn.Dispose();
222 } 191 }
@@ -224,7 +193,6 @@ class TestEldbusObject
224 193
225class TestEldbusMessage 194class TestEldbusMessage
226{ 195{
227 private static IntPtr timeout = IntPtr.Zero;
228 private static bool isSuccess = false; 196 private static bool isSuccess = false;
229 197
230 198
@@ -232,19 +200,23 @@ class TestEldbusMessage
232 { 200 {
233 isSuccess = false; 201 isSuccess = false;
234 202
203 var app = Efl.App.AppMain;
235 var conn = new eldbus.Connection(eldbus.Connection.Type.Session); 204 var conn = new eldbus.Connection(eldbus.Connection.Type.Session);
236 205
237 eldbus.Pending pending = conn.ActivatableList(messageCb); 206 eldbus.Pending pending = conn.ActivatableList(messageCb);
238 207
239 AssertEquals(pending.GetMethod(), "ListActivatableNames"); 208 AssertEquals(pending.GetMethod(), "ListActivatableNames");
240 209
241 timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero); 210 var timer = new Efl.LoopTimer(app, 2.0);
242 Assert(timeout != IntPtr.Zero); 211 timer.TimerTickEvent += (object sender, EventArgs e) => {
212 app.Quit(0);
213 };
243 214
244 ecore_main_loop_begin(); 215 app.Begin();
245 216
246 Assert(isSuccess, "Method ListActivatableNames is not call"); 217 Assert(isSuccess, "Method ListActivatableNames is not call");
247 218
219 timer.Dispose();
248 conn.Dispose(); 220 conn.Dispose();
249 } 221 }
250 222
@@ -254,12 +226,6 @@ class TestEldbusMessage
254 { 226 {
255 try 227 try
256 { 228 {
257 if (timeout != IntPtr.Zero)
258 {
259 ecore_timer_del(timeout);
260 timeout = IntPtr.Zero;
261 }
262
263 string errname, errmsg; 229 string errname, errmsg;
264 if (msg.GetError(out errname, out errmsg)) 230 if (msg.GetError(out errname, out errmsg))
265 { 231 {
@@ -293,7 +259,7 @@ class TestEldbusMessage
293 } 259 }
294 finally 260 finally
295 { 261 {
296 ecore_main_loop_quit(); 262 Efl.App.AppMain.Quit(0);
297 } 263 }
298 }; 264 };
299 265
@@ -304,6 +270,7 @@ class TestEldbusMessage
304 { 270 {
305 isSuccess = false; 271 isSuccess = false;
306 272
273 var app = Efl.App.AppMain;
307 var conn = new eldbus.Connection(eldbus.Connection.Type.Session); 274 var conn = new eldbus.Connection(eldbus.Connection.Type.Session);
308 275
309 string methodName = "GetId"; 276 string methodName = "GetId";
@@ -322,12 +289,6 @@ class TestEldbusMessage
322 { 289 {
323 try 290 try
324 { 291 {
325 if (timeout != IntPtr.Zero)
326 {
327 ecore_timer_del(timeout);
328 timeout = IntPtr.Zero;
329 }
330
331 string errname, errmsg; 292 string errname, errmsg;
332 if (!m.GetError(out errname, out errmsg)) 293 if (!m.GetError(out errname, out errmsg))
333 { 294 {
@@ -347,7 +308,7 @@ class TestEldbusMessage
347 } 308 }
348 finally 309 finally
349 { 310 {
350 ecore_main_loop_quit(); 311 app.Quit(0);
351 } 312 }
352 }; 313 };
353 314
@@ -356,13 +317,16 @@ class TestEldbusMessage
356 317
357 AssertEquals(pending.GetMethod(), methodName); 318 AssertEquals(pending.GetMethod(), methodName);
358 319
359 timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero); 320 var timer = new Efl.LoopTimer(app, 2.0);
360 Assert(timeout != IntPtr.Zero); 321 timer.TimerTickEvent += (object sender, EventArgs e) => {
322 app.Quit(0);
323 };
361 324
362 ecore_main_loop_begin(); 325 app.Begin();
363 326
364 Assert(isSuccess, $"Method {methodName} is not call"); 327 Assert(isSuccess, $"Method {methodName} is not call");
365 328
329 timer.Dispose();
366 msg.Dispose(); 330 msg.Dispose();
367 conn.Dispose(); 331 conn.Dispose();
368 } 332 }
@@ -392,12 +356,6 @@ class TestEldbusMessage
392 { 356 {
393 try 357 try
394 { 358 {
395 if (timeout != IntPtr.Zero)
396 {
397 ecore_timer_del(timeout);
398 timeout = IntPtr.Zero;
399 }
400
401 string errname, errmsg; 359 string errname, errmsg;
402 if (msg.GetError(out errname, out errmsg)) 360 if (msg.GetError(out errname, out errmsg))
403 { 361 {
@@ -431,7 +389,7 @@ class TestEldbusMessage
431 } 389 }
432 finally 390 finally
433 { 391 {
434 ecore_main_loop_quit(); 392 Efl.App.AppMain.Quit(0);
435 } 393 }
436 }; 394 };
437 ActivatableList(activatableListResponseCb); 395 ActivatableList(activatableListResponseCb);
diff --git a/src/tests/efl_mono/Inheritance.cs b/src/tests/efl_mono/Inheritance.cs
index 26f51c5..aec34db 100644
--- a/src/tests/efl_mono/Inheritance.cs
+++ b/src/tests/efl_mono/Inheritance.cs
@@ -99,9 +99,6 @@ class TestInheritance
99 parentWRef = new WeakReference(parent); 99 parentWRef = new WeakReference(parent);
100 childWRef = new WeakReference(child); 100 childWRef = new WeakReference(child);
101 101
102 Console.WriteLine($"Parent [{parent.ToString()}] has {Efl.Eo.Globals.efl_ref_count(parent.NativeHandle)} refs");
103 Console.WriteLine($"Child [{child.ToString()}] has {Efl.Eo.Globals.efl_ref_count(child.NativeHandle)} refs");
104
105 child = null; 102 child = null;
106 103
107 System.GC.Collect(System.GC.MaxGeneration, GCCollectionMode.Forced, true, true); 104 System.GC.Collect(System.GC.MaxGeneration, GCCollectionMode.Forced, true, true);
@@ -115,9 +112,6 @@ class TestInheritance
115 Test.AssertEquals(false, parent.disposed); 112 Test.AssertEquals(false, parent.disposed);
116 Test.AssertEquals(false, parent.childDisposed); 113 Test.AssertEquals(false, parent.childDisposed);
117 114
118 Console.WriteLine($"Parent [{parent.ToString()}] has {Efl.Eo.Globals.efl_ref_count(parent.NativeHandle)} refs");
119 Console.WriteLine($"Child [{child.ToString()}] has {Efl.Eo.Globals.efl_ref_count(child.NativeHandle)} refs");
120
121 parent = null; 115 parent = null;
122 child = null; 116 child = null;
123 } 117 }