summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Eo.cs
diff options
context:
space:
mode:
authorBruno da Silva Belo <bruno.belo@expertisesolutions.com.br>2019-11-14 14:26:16 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-14 15:32:42 -0300
commitcd113d7aae746f4bc9c1678e0942aeca64382781 (patch)
tree2a871591d00155ea07a02b56a9b26a6a3acb2477 /src/tests/efl_mono/Eo.cs
parent37b55172b0d46d71f772af8fba17e1fb1b7c6c2c (diff)
csharp: Disposing IDisposable objects.
Summary: ref T8423 Reviewers: lauromoura, felipealmeida, YOhoho Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8423 Differential Revision: https://phab.enlightenment.org/D10644
Diffstat (limited to 'src/tests/efl_mono/Eo.cs')
-rw-r--r--src/tests/efl_mono/Eo.cs40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index e9ddb66fac..dec54ba31a 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -28,6 +28,7 @@ class TestEo
28 var testing = new Dummy.TestObject(); 28 var testing = new Dummy.TestObject();
29 var o1 = testing.ReturnNullObject(); 29 var o1 = testing.ReturnNullObject();
30 Test.Assert(o1 == null); 30 Test.Assert(o1 == null);
31 testing.Dispose();
31 } 32 }
32 33
33 // 34 //
@@ -42,6 +43,7 @@ class TestEo
42 var o2 = o1.ReturnObject(); 43 var o2 = o1.ReturnObject();
43 Test.Assert(o2.NativeHandle != IntPtr.Zero); 44 Test.Assert(o2.NativeHandle != IntPtr.Zero);
44 Test.Assert(o2.NativeHandle == o1.NativeHandle); 45 Test.Assert(o2.NativeHandle == o1.NativeHandle);
46 testing.Dispose();
45 } 47 }
46 /* Commented out as adding the event listener seems to prevent it from being GC'd. 48 /* Commented out as adding the event listener seems to prevent it from being GC'd.
47 public static void destructor_really_frees() 49 public static void destructor_really_frees()
@@ -121,12 +123,12 @@ class TestEoInherit
121 { 123 {
122 Efl.Object loop = new MyObject(); 124 Efl.Object loop = new MyObject();
123 Test.Assert(loop.NativeHandle != System.IntPtr.Zero); 125 Test.Assert(loop.NativeHandle != System.IntPtr.Zero);
126 loop.Dispose();
124 } 127 }
125 128
126 private static WeakReference CreateCollectableInherited() 129 private static WeakReference CreateCollectableInherited()
127 { 130 {
128 var obj = new MyObject(); 131 return new WeakReference(new MyObject());
129 return new WeakReference(obj);
130 } 132 }
131 133
132 public static void inherited_collected() 134 public static void inherited_collected()
@@ -147,6 +149,7 @@ class TestEoNames
147 string name = "Dummy"; 149 string name = "Dummy";
148 obj.SetName(name); 150 obj.SetName(name);
149 Test.AssertEquals(name, obj.GetName()); 151 Test.AssertEquals(name, obj.GetName());
152 obj.Dispose();
150 } 153 }
151} 154}
152 155
@@ -161,6 +164,8 @@ class TestEoParent
161 164
162 var parent_retrieved = child.GetParent() as Dummy.TestObject; 165 var parent_retrieved = child.GetParent() as Dummy.TestObject;
163 Test.AssertEquals(parent, parent_retrieved); 166 Test.AssertEquals(parent, parent_retrieved);
167 child.Dispose();
168 parent.Dispose();
164 } 169 }
165 170
166 public static void parent_inherited_class() 171 public static void parent_inherited_class()
@@ -172,6 +177,8 @@ class TestEoParent
172 177
173 Dummy.Numberwrapper parent_retrieved = child.GetParent() as Dummy.Numberwrapper; 178 Dummy.Numberwrapper parent_retrieved = child.GetParent() as Dummy.Numberwrapper;
174 Test.AssertEquals(parent, parent_retrieved); 179 Test.AssertEquals(parent, parent_retrieved);
180 child.Dispose();
181 parent.Dispose();
175 } 182 }
176 183
177 private class Derived : Dummy.TestObject 184 private class Derived : Dummy.TestObject
@@ -190,6 +197,8 @@ class TestEoParent
190 197
191 var parent_from_cast = child.GetParent() as Derived; 198 var parent_from_cast = child.GetParent() as Derived;
192 Test.AssertEquals(parent, parent_from_cast); 199 Test.AssertEquals(parent, parent_from_cast);
200 child.Dispose();
201 parent.Dispose();
193 } 202 }
194} 203}
195 204
@@ -222,7 +231,7 @@ class TestTypedefs
222 231
223 Test.AssertEquals((Dummy.MyInt)ret, input); 232 Test.AssertEquals((Dummy.MyInt)ret, input);
224 Test.AssertEquals(receiver, input); 233 Test.AssertEquals(receiver, input);
225 234 obj.Dispose();
226 } 235 }
227} 236}
228 237
@@ -262,6 +271,8 @@ class TestEoAccessors
262 { 271 {
263 Test.AssertEquals(pair.Item1, pair.Item2); 272 Test.AssertEquals(pair.Item1, pair.Item2);
264 } 273 }
274 lst.Dispose();
275 obj.Dispose();
265 } 276 }
266} 277}
267 278
@@ -282,6 +293,7 @@ class TestEoFinalize
282 { 293 {
283 Inherit inherit = new Inherit(); 294 Inherit inherit = new Inherit();
284 Test.Assert(inherit.finalizeCalled); 295 Test.Assert(inherit.finalizeCalled);
296 inherit.Dispose();
285 } 297 }
286} 298}
287 299
@@ -315,8 +327,11 @@ class TestEoMultipleChildClasses
315 SecondChild obj2 = new SecondChild(); 327 SecondChild obj2 = new SecondChild();
316 Test.AssertEquals(2, obj2.receivedValue); 328 Test.AssertEquals(2, obj2.receivedValue);
317 329
330 obj.Dispose();
318 obj = new FirstChild(); 331 obj = new FirstChild();
319 Test.AssertEquals(1, obj.receivedValue); 332 Test.AssertEquals(1, obj.receivedValue);
333 obj2.Dispose();
334 obj.Dispose();
320 } 335 }
321} 336}
322 337
@@ -329,12 +344,14 @@ class TestCsharpProperties
329 obj.Name = name; 344 obj.Name = name;
330 345
331 Test.AssertEquals(name, obj.Name); 346 Test.AssertEquals(name, obj.Name);
347 obj.Dispose();
332 } 348 }
333 349
334 public static void test_getter_only() 350 public static void test_getter_only()
335 { 351 {
336 var obj = new Dummy.TestObject(); 352 var obj = new Dummy.TestObject();
337 Test.Assert(!obj.Invalidating); 353 Test.Assert(!obj.Invalidating);
354 obj.Dispose();
338 } 355 }
339 356
340 public static void test_setter_only() 357 public static void test_setter_only()
@@ -344,6 +361,7 @@ class TestCsharpProperties
344 361
345 obj.SetterOnly = val; 362 obj.SetterOnly = val;
346 Test.AssertEquals(val, obj.GetSetterOnly()); 363 Test.AssertEquals(val, obj.GetSetterOnly());
364 obj.Dispose();
347 } 365 }
348 366
349 public static void test_class_property() 367 public static void test_class_property()
@@ -359,6 +377,7 @@ class TestCsharpProperties
359 Dummy.ITestIface iface = new Dummy.TestObject(); 377 Dummy.ITestIface iface = new Dummy.TestObject();
360 iface.IfaceProp = val; 378 iface.IfaceProp = val;
361 Test.AssertEquals(val, iface.IfaceProp); 379 Test.AssertEquals(val, iface.IfaceProp);
380 iface.Dispose();
362 } 381 }
363 382
364 public static void test_csharp_multi_valued_prop() 383 public static void test_csharp_multi_valued_prop()
@@ -367,6 +386,7 @@ class TestCsharpProperties
367 obj.MultiValuedProp = (1, 2); 386 obj.MultiValuedProp = (1, 2);
368 var ret = obj.MultiValuedProp; 387 var ret = obj.MultiValuedProp;
369 Test.AssertEquals(ret, (1, 2)); 388 Test.AssertEquals(ret, (1, 2));
389 obj.Dispose();
370 } 390 }
371} 391}
372 392
@@ -386,6 +406,7 @@ class TestEoGrandChildrenFinalize
386 { 406 {
387 Child obj = new Child(); 407 Child obj = new Child();
388 Test.AssertEquals(42, obj.receivedValue); 408 Test.AssertEquals(42, obj.receivedValue);
409 obj.Dispose();
389 } 410 }
390 411
391 public sealed class GrandChild : Dummy.Child 412 public sealed class GrandChild : Dummy.Child
@@ -409,6 +430,7 @@ class TestEoGrandChildrenFinalize
409 { 430 {
410 GrandChild obj = new GrandChild(); 431 GrandChild obj = new GrandChild();
411 Test.AssertEquals(-42, obj.receivedValue); 432 Test.AssertEquals(-42, obj.receivedValue);
433 obj.Dispose();
412 } 434 }
413} 435}
414 436
@@ -429,7 +451,7 @@ class TestConstructors
429 var obj = new Dummy.Child(null, a, b, iface_prop); 451 var obj = new Dummy.Child(null, a, b, iface_prop);
430#endif 452#endif
431 Test.AssertEquals(iface_prop, obj.IfaceProp); 453 Test.AssertEquals(iface_prop, obj.IfaceProp);
432 454 obj.Dispose();
433#if EFL_BETA 455#if EFL_BETA
434 obj = new Dummy.Child(parent: null, ifaceProp : iface_prop, doubleParamsA : a, doubleParamsB : b, 456 obj = new Dummy.Child(parent: null, ifaceProp : iface_prop, doubleParamsA : a, doubleParamsB : b,
435 obligatoryBetaCtor : beta, 457 obligatoryBetaCtor : beta,
@@ -443,6 +465,7 @@ class TestConstructors
443 Test.Assert(obj.ObligatoryBetaCtorWasCalled); 465 Test.Assert(obj.ObligatoryBetaCtorWasCalled);
444 Test.Assert(obj.OptionalBetaCtorWasCalled); 466 Test.Assert(obj.OptionalBetaCtorWasCalled);
445#endif 467#endif
468 obj.Dispose();
446 } 469 }
447 470
448 public static void test_optional_constructor() 471 public static void test_optional_constructor()
@@ -457,6 +480,7 @@ class TestConstructors
457 var obj = new Dummy.Child(null, a, b); 480 var obj = new Dummy.Child(null, a, b);
458#endif 481#endif
459 Test.Assert(!obj.GetIfaceWasSet()); 482 Test.Assert(!obj.GetIfaceWasSet());
483 obj.Dispose();
460 } 484 }
461} 485}
462 486
@@ -470,6 +494,7 @@ class TestInterfaceConcrete
470 494
471 iface.IfaceProp = 1970; 495 iface.IfaceProp = 1970;
472 Test.AssertEquals(iface.IfaceProp, 1970); 496 Test.AssertEquals(iface.IfaceProp, 1970);
497 obj.Dispose();
473 } 498 }
474} 499}
475 500
@@ -482,6 +507,7 @@ class TestProvider
482 Dummy.Numberwrapper provider = obj.FindProvider(typeof(Dummy.Numberwrapper)) as Dummy.Numberwrapper; 507 Dummy.Numberwrapper provider = obj.FindProvider(typeof(Dummy.Numberwrapper)) as Dummy.Numberwrapper;
483 Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper)); 508 Test.AssertEquals(provider.GetType(), typeof(Dummy.Numberwrapper));
484 Test.AssertEquals(provider.GetNumber(), 1999); 509 Test.AssertEquals(provider.GetNumber(), 1999);
510 obj.Dispose();
485 } 511 }
486 512
487 private class ProviderHolder : Dummy.TestObject 513 private class ProviderHolder : Dummy.TestObject
@@ -526,7 +552,7 @@ class TestProvider
526 provider = obj.CallFindProviderForIface(); 552 provider = obj.CallFindProviderForIface();
527 Test.AssertNotNull(provider, msg : "Provider of ITestIFace must not be null"); 553 Test.AssertNotNull(provider, msg : "Provider of ITestIFace must not be null");
528 Test.AssertEquals(provider.Name, obj.ProviderName, "Provider name does not match expected"); 554 Test.AssertEquals(provider.Name, obj.ProviderName, "Provider name does not match expected");
529 555 obj.Dispose();
530 } 556 }
531} 557}
532 558
@@ -542,6 +568,7 @@ class TestObjectDeletion
542 part.Del(); 568 part.Del();
543 569
544 Test.AssertNull(obj.OnePart); 570 Test.AssertNull(obj.OnePart);
571 obj.Dispose();
545 } 572 }
546} 573}
547 574
@@ -564,12 +591,14 @@ class TestProtectedInterfaceMembers
564 { 591 {
565 var obj = new Dummy.TestObject(); 592 var obj = new Dummy.TestObject();
566 Test.AssertEquals(obj.CallMethodProtected(42), -42); 593 Test.AssertEquals(obj.CallMethodProtected(42), -42);
594 obj.Dispose();
567 } 595 }
568 596
569 public static void test_protected_interface_in_inherited_class_called_from_c() 597 public static void test_protected_interface_in_inherited_class_called_from_c()
570 { 598 {
571 var obj = new MyObject(); 599 var obj = new MyObject();
572 Test.AssertEquals(obj.CallMethodProtected(42), 42 * 42); 600 Test.AssertEquals(obj.CallMethodProtected(42), 42 * 42);
601 obj.Dispose();
573 } 602 }
574 603
575 public static void test_interface_skipped_protected() 604 public static void test_interface_skipped_protected()
@@ -640,6 +669,7 @@ class TestHiddenClasses
640 var hidden = obj.HiddenObject; 669 var hidden = obj.HiddenObject;
641 670
642 Test.AssertEquals(hidden.Name, "hidden_object"); 671 Test.AssertEquals(hidden.Name, "hidden_object");
672 obj.Dispose();
643 } 673 }
644} 674}
645 675