summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Promises.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/efl_mono/Promises.cs')
-rw-r--r--src/tests/efl_mono/Promises.cs39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/tests/efl_mono/Promises.cs b/src/tests/efl_mono/Promises.cs
index fc0c089..7a7afff 100644
--- a/src/tests/efl_mono/Promises.cs
+++ b/src/tests/efl_mono/Promises.cs
@@ -1,3 +1,18 @@
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;
3 18
@@ -15,6 +30,7 @@ class TestPromises
15 Test.Assert(cleanCalled, "Promise clean callback should have been called."); 30 Test.Assert(cleanCalled, "Promise clean callback should have been called.");
16 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); 31 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
17 Test.AssertRaises<ObjectDisposedException>(future.Cancel); 32 Test.AssertRaises<ObjectDisposedException>(future.Cancel);
33 promise.Dispose();
18 } 34 }
19 35
20 public static void test_simple_resolve() 36 public static void test_simple_resolve()
@@ -40,6 +56,8 @@ class TestPromises
40 56
41 Test.Assert(callbackCalled, "Future callback should have been called."); 57 Test.Assert(callbackCalled, "Future callback should have been called.");
42 Test.AssertEquals(received_value, reference_value); 58 Test.AssertEquals(received_value, reference_value);
59 reference_value.Dispose();
60 promise.Dispose();
43 } 61 }
44 62
45 public static void test_simple_with_object() 63 public static void test_simple_with_object()
@@ -59,12 +77,16 @@ class TestPromises
59 77
60 Eina.Value referenceValue = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32); 78 Eina.Value referenceValue = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Int32);
61 referenceValue.Append(32); 79 referenceValue.Append(32);
62 promise.Resolve(new Eina.Value(referenceValue)); 80 var tmp = new Eina.Value(referenceValue);
81 promise.Resolve(tmp);
63 82
64 loop.Iterate(); 83 loop.Iterate();
65 84
66 Test.Assert(callbackCalled, "Future callback should have been called."); 85 Test.Assert(callbackCalled, "Future callback should have been called.");
67 Test.AssertEquals(receivedValue, referenceValue); 86 Test.AssertEquals(receivedValue, referenceValue);
87 tmp.Dispose();
88 referenceValue.Dispose();
89 promise.Dispose();
68 } 90 }
69 91
70 public static void test_simple_reject() 92 public static void test_simple_reject()
@@ -91,6 +113,7 @@ class TestPromises
91 113
92 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); 114 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
93 Test.AssertRaises<ObjectDisposedException>(future.Cancel); 115 Test.AssertRaises<ObjectDisposedException>(future.Cancel);
116 promise.Dispose();
94 } 117 }
95 118
96 public static void test_simple_future_cancel() 119 public static void test_simple_future_cancel()
@@ -113,6 +136,7 @@ class TestPromises
113 Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called."); 136 Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called.");
114 Test.Assert(callbackCalled, "Future callback should have been called."); 137 Test.Assert(callbackCalled, "Future callback should have been called.");
115 Test.AssertEquals(received_error, Eina.Error.ECANCELED); 138 Test.AssertEquals(received_error, Eina.Error.ECANCELED);
139 promise.Dispose();
116 } 140 }
117 141
118 142
@@ -157,6 +181,8 @@ class TestPromises
157 181
158 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); 182 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
159 Test.AssertRaises<ObjectDisposedException>(future.Cancel); 183 Test.AssertRaises<ObjectDisposedException>(future.Cancel);
184 reference_value.Dispose();
185 promise.Dispose();
160 } 186 }
161 187
162 public static void test_then_chain_array() 188 public static void test_then_chain_array()
@@ -202,6 +228,8 @@ class TestPromises
202 228
203 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); 229 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
204 Test.AssertRaises<ObjectDisposedException>(future.Cancel); 230 Test.AssertRaises<ObjectDisposedException>(future.Cancel);
231 reference_value.Dispose();
232 promise.Dispose();
205 } 233 }
206 234
207 public static void test_cancel_after_resolve() 235 public static void test_cancel_after_resolve()
@@ -229,6 +257,7 @@ class TestPromises
229 257
230 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); }); 258 Test.AssertRaises<ObjectDisposedException>(() => { promise.Resolve(null); });
231 Test.AssertRaises<ObjectDisposedException>(future.Cancel); 259 Test.AssertRaises<ObjectDisposedException>(future.Cancel);
260 promise.Dispose();
232 } 261 }
233 262
234 public static void test_constructor_with_callback() 263 public static void test_constructor_with_callback()
@@ -239,11 +268,12 @@ class TestPromises
239 Efl.Loop loop = Efl.App.AppMain; 268 Efl.Loop loop = Efl.App.AppMain;
240 Eina.Promise promise = new Eina.Promise(); 269 Eina.Promise promise = new Eina.Promise();
241#pragma warning disable 0219 270#pragma warning disable 0219
242 Eina.Future future = new Eina.Future(promise,(Eina.Value value) => { 271 Eina.Future future = new Eina.Future(promise, (Eina.Value value) =>
272 {
243 callbackCalled = true; 273 callbackCalled = true;
244 received_value = value; 274 received_value = value;
245 return value; 275 return value;
246 } ); 276 });
247#pragma warning restore 0219 277#pragma warning restore 0219
248 278
249 Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32); 279 Eina.Value reference_value = new Eina.Value(Eina.ValueType.Int32);
@@ -254,6 +284,9 @@ class TestPromises
254 284
255 Test.Assert(callbackCalled, "Future callback should have been called."); 285 Test.Assert(callbackCalled, "Future callback should have been called.");
256 Test.AssertEquals(received_value, reference_value); 286 Test.AssertEquals(received_value, reference_value);
287 promise.Dispose();
288 loop.Dispose();
289 reference_value.Dispose();
257 } 290 }
258 291
259 public static void test_reject_on_disposal() 292 public static void test_reject_on_disposal()