summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Eo.cs
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-18 10:36:29 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-18 10:40:53 -0300
commit81b94b3e35a3dc49298f2ed1d90575a42fa0cf0f (patch)
tree901a169b7f18f9501ce81b7cae15b5caafad1b15 /src/tests/efl_mono/Eo.cs
parent5befca9a1066716433641bf7d480c6776f4c9ba6 (diff)
csharp: Fix passing acessor with ownership
Summary: When passing an owned acessor from a converted collection we need a way to unpin the passed data when the accessor is freed. This commits adds a thin wrapper around the CArray accessor that unpins the data when freed. Depends on D10900 Reviewers: YOhoho, felipealmeida Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers, jptiz, brunobelo Tags: #efl Maniphest Tasks: T8486 Differential Revision: https://phab.enlightenment.org/D10901
Diffstat (limited to 'src/tests/efl_mono/Eo.cs')
-rw-r--r--src/tests/efl_mono/Eo.cs36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index 586a18cba3..7c580480ad 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -257,18 +257,21 @@ class TestVariables
257 257
258class TestEoAccessors 258class TestEoAccessors
259{ 259{
260 private static void do_eo_accessors(IEnumerable<int> accessor) 260 private static void do_eo_accessors(IEnumerable<int> accessor, bool shouldMove=false)
261 { 261 {
262 var obj = new Dummy.TestObject(); 262 var obj = new Dummy.TestObject();
263 263
264 IEnumerable<int> acc = obj.CloneAccessor(accessor); 264 IEnumerable<int> source = shouldMove ? accessor.ToList() : accessor;
265 265
266 var zipped = acc.Zip(accessor, (first, second) => new Tuple<int, int>(first, second)); 266 IEnumerable<int> acc = shouldMove ? obj.CloneAccessorOwn(accessor) : obj.CloneAccessor(accessor);
267
268 var zipped = acc.Zip(source, (first, second) => new Tuple<int, int>(first, second));
267 269
268 foreach (Tuple<int, int> pair in zipped) 270 foreach (Tuple<int, int> pair in zipped)
269 { 271 {
270 Test.AssertEquals(pair.Item1, pair.Item2); 272 Test.AssertEquals(pair.Item1, pair.Item2);
271 } 273 }
274
272 obj.Dispose(); 275 obj.Dispose();
273 } 276 }
274 277
@@ -280,16 +283,26 @@ class TestEoAccessors
280 lst.Append(2); 283 lst.Append(2);
281 lst.Append(5); 284 lst.Append(5);
282 285
283 // FIXME: Replace the first accessor with the list once Eina.List implements Eina.IList
284 do_eo_accessors(lst.GetAccessor()); 286 do_eo_accessors(lst.GetAccessor());
285 287
286 lst.Dispose(); 288 lst.Dispose();
287 } 289 }
290 public static void eina_eo_accessors_own()
291 {
292 Eina.List<int> lst = new Eina.List<int>();
293 lst.Append(4);
294 lst.Append(3);
295 lst.Append(2);
296 lst.Append(1);
297 Eina.Accessor<int> acc = lst.GetAccessor();
298 do_eo_accessors(acc, shouldMove : true);
299
300 Test.Assert(acc.Own);
301
302 }
288 303
289 public static void managed_eo_accessors() 304 public static void managed_eo_accessors()
290 { 305 {
291 var obj = new Dummy.TestObject();
292
293 List<int> lst = new List<int>(); 306 List<int> lst = new List<int>();
294 lst.Add(-1); 307 lst.Add(-1);
295 lst.Add(1); 308 lst.Add(1);
@@ -298,6 +311,17 @@ class TestEoAccessors
298 311
299 do_eo_accessors(lst); 312 do_eo_accessors(lst);
300 } 313 }
314
315 public static void managed_eo_accessors_own()
316 {
317 List<int> lst = new List<int>();
318 lst.Add(-1);
319 lst.Add(1);
320 lst.Add(4);
321 lst.Add(42);
322
323 do_eo_accessors(lst, shouldMove : true);
324 }
301} 325}
302 326
303class TestEoFinalize 327class TestEoFinalize