summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Inheritance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/efl_mono/Inheritance.cs')
-rw-r--r--src/tests/efl_mono/Inheritance.cs31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/tests/efl_mono/Inheritance.cs b/src/tests/efl_mono/Inheritance.cs
index aec34db..852a639 100644
--- a/src/tests/efl_mono/Inheritance.cs
+++ b/src/tests/efl_mono/Inheritance.cs
@@ -1,8 +1,24 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Collections.Generic; 17using System.Collections.Generic;
3using System.Linq; 18using System.Linq;
4using System.Runtime.InteropServices; 19using System.Runtime.InteropServices;
5using System.Runtime.CompilerServices; 20using System.Runtime.CompilerServices;
21using System.Diagnostics.CodeAnalysis;
6 22
7using EinaTestData; 23using EinaTestData;
8using static EinaTestData.BaseData; 24using static EinaTestData.BaseData;
@@ -34,7 +50,7 @@ class TestInheritance
34 return "Hello World"; 50 return "Hello World";
35 } 51 }
36 } 52 }
37 53
38 internal class Inherit3Parent : Dummy.TestObject 54 internal class Inherit3Parent : Dummy.TestObject
39 { 55 {
40 public bool disposed = false; 56 public bool disposed = false;
@@ -80,6 +96,7 @@ class TestInheritance
80 var obj = new Inherit1(); 96 var obj = new Inherit1();
81 int i = Dummy.InheritHelper.ReceiveDummyAndCallIntOut(obj); 97 int i = Dummy.InheritHelper.ReceiveDummyAndCallIntOut(obj);
82 Test.AssertEquals (50, i); 98 Test.AssertEquals (50, i);
99 obj.Dispose();
83 } 100 }
84 101
85 public static void test_inherit_from_iface() 102 public static void test_inherit_from_iface()
@@ -89,8 +106,10 @@ class TestInheritance
89 Test.AssertEquals (50, i); 106 Test.AssertEquals (50, i);
90 string s = Dummy.InheritHelper.ReceiveDummyAndCallInStringshare(obj); 107 string s = Dummy.InheritHelper.ReceiveDummyAndCallInStringshare(obj);
91 Test.AssertEquals ("Hello World", s); 108 Test.AssertEquals ("Hello World", s);
109 obj.Dispose();
92 } 110 }
93 111
112 [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectBeforeLosingScope", Justification = "It is expected to lose scope.")]
94 private static void CreateAndCheckInheritedObjects(out WeakReference parentWRef, out WeakReference childWRef) 113 private static void CreateAndCheckInheritedObjects(out WeakReference parentWRef, out WeakReference childWRef)
95 { 114 {
96 var parent = new Inherit3Parent(); 115 var parent = new Inherit3Parent();
@@ -112,8 +131,8 @@ class TestInheritance
112 Test.AssertEquals(false, parent.disposed); 131 Test.AssertEquals(false, parent.disposed);
113 Test.AssertEquals(false, parent.childDisposed); 132 Test.AssertEquals(false, parent.childDisposed);
114 133
115 parent = null; 134 child.Dispose();
116 child = null; 135 parent.Dispose();
117 } 136 }
118 137
119 public static void test_inherit_lifetime() 138 public static void test_inherit_lifetime()
@@ -123,9 +142,9 @@ class TestInheritance
123 142
124 CreateAndCheckInheritedObjects(out parentWRef, out childWRef); 143 CreateAndCheckInheritedObjects(out parentWRef, out childWRef);
125 144
126 // Two invocations to iterate a the child wasn't being released with a single one 145 // We need some extra iterations of the main loop to allow the async callbacks
127 Test.CollectAndIterate(); 146 // registered from the Dispose method to the main loop to run.
128 Test.CollectAndIterate(); 147 Test.CollectAndIterate(10, 10);
129 148
130 var parent = (Dummy.TestObject) parentWRef.Target; 149 var parent = (Dummy.TestObject) parentWRef.Target;
131 var child = (Dummy.TestObject) childWRef.Target; 150 var child = (Dummy.TestObject) childWRef.Target;