public static void event_with_struct_complex_payload() { var obj = new Dummy.TestObject(); Dummy.StructComplex received_struct = default(Dummy.StructComplex); obj.EvtWithStructComplexEvent += (object sender, Dummy.TestObjectEvtWithStructComplexEventArgs e) => { received_struct = e.Arg; }; Dummy.StructComplex sent_struct = StructHelpers.structComplexWithValues(); obj.EmitEventWithStructComplex(sent_struct); Test.AssertEquals(sent_struct.Fobj, received_struct.Fobj); obj.Dispose(); }
public static void event_with_error_payload() { var obj = new Dummy.TestObject(); Eina.Error received_error = 0; obj.EvtWithErrorEvent += (object sender, Dummy.TestObjectEvtWithErrorEventArgs e) => { received_error = e.Arg; }; Eina.Error sent_error = -2001; obj.EmitEventWithError(sent_error); Test.AssertEquals(sent_error, received_error); obj.Dispose(); }
public static void event_with_struct_payload() { var obj = new Dummy.TestObject(); Dummy.StructSimple received_struct = default(Dummy.StructSimple); obj.EvtWithStructEvent += (object sender, Dummy.TestObjectEvtWithStructEventArgs e) => { received_struct = e.Arg; }; Dummy.StructSimple sent_struct = new Dummy.StructSimple(fstring: "Struct Event"); obj.EmitEventWithStruct(sent_struct); Test.AssertEquals(sent_struct.Fstring, received_struct.Fstring); obj.Dispose(); }
private static void do_eo_accessors(IEnumerable <int> accessor, bool shouldMove = false) { var obj = new Dummy.TestObject(); IEnumerable <int> source = shouldMove ? accessor.ToList() : accessor; IEnumerable <int> acc = shouldMove ? obj.CloneAccessorOwn(accessor) : obj.CloneAccessor(accessor); var zipped = acc.Zip(source, (first, second) => new Tuple <int, int>(first, second)); foreach (Tuple <int, int> pair in zipped) { Test.AssertEquals(pair.Item1, pair.Item2); } obj.Dispose(); }
public static void TestEolianEinaValueOutByValue() { var obj = new Dummy.TestObject(); using (Eina.Value v = new Eina.Value(Eina.ValueType.String)) { Eina.Value v_out = null; v.Set("hello!"); obj.SetValue(v); obj.OutValue(out v_out); Test.AssertEquals(v, v_out); Test.AssertEquals(Eina.Ownership.Managed, v_out.Ownership); v_out.Dispose(); } obj.Dispose(); }
// return eina_error public static void eina_error_return() { var obj = new Dummy.TestObject(); Eina.Error expected = 42; obj.SetErrorRet(expected); Eina.Error error = obj.ReturnsError(); Test.AssertEquals(expected, error); expected = 0; obj.SetErrorRet(expected); error = obj.ReturnsError(); Test.AssertEquals(expected, error); obj.Dispose(); }
public static void event_with_bool_payload() { var obj = new Dummy.TestObject(); bool received_bool = false; obj.EvtWithBoolEvent += (object sender, Dummy.TestObjectEvtWithBoolEventArgs e) => { received_bool = e.Arg; }; obj.EmitEventWithBool(true); Test.AssertEquals(true, received_bool); obj.EmitEventWithBool(false); Test.AssertEquals(false, received_bool); obj.Dispose(); }
public static void event_with_object_payload() { var obj = new Dummy.TestObject(); Dummy.TestObject received_obj = null; obj.EvtWithObjEvent += (object sender, Dummy.TestObjectEvtWithObjEventArgs e) => { received_obj = e.Arg; }; var sent_obj = new Dummy.TestObject(); obj.EmitEventWithObj(sent_obj); Test.AssertEquals(sent_obj, received_obj); sent_obj.Dispose(); obj.Dispose(); }
public static void test_add_remove_event() { var obj = new Dummy.TestObject(); bool called = true; EventHandler <Dummy.TestObjectEvtWithIntEventArgs> evtCb = (object sender, Dummy.TestObjectEvtWithIntEventArgs e) => { called = true; }; obj.EvtWithIntEvent += evtCb; obj.EmitEventWithInt(42); Test.Assert(called); called = false; obj.EvtWithIntEvent -= evtCb; obj.EmitEventWithInt(42); Test.Assert(!called); obj.Dispose(); }
public static void set_callback_with_lambda() { setup(); var obj = new Dummy.TestObject(); obj.SetCallback(y => { called = true; return(y + 4); }); Test.Assert(called == false, "set_callback should not call the callback"); int x = obj.CallCallback(37); Test.Assert(called, "call_callback must call a callback"); Test.AssertEquals(37 + 4, x); obj.Dispose(); }
public static void TestEolianEinaValueInOwn() { var obj = new Dummy.TestObject(); using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) { v.Set(2001); Test.AssertEquals(Eina.Ownership.Managed, v.Ownership); obj.SetValuePtrOwn(v); Test.AssertEquals(Eina.Ownership.Unmanaged, v.Ownership); Eina.Value v_received = obj.GetValuePtr(); Test.AssertEquals(Eina.Ownership.Unmanaged, v_received.Ownership); Test.AssertEquals(v, v_received); obj.ClearValue(); } obj.Dispose(); }
public static void basic_eo_accessors() { var obj = new Dummy.TestObject(); Eina.List <int> lst = new Eina.List <int>(); lst.Append(4); lst.Append(3); lst.Append(2); lst.Append(5); Eina.Accessor <int> acc = obj.CloneAccessor(lst.GetAccessor()); var zipped = acc.Zip(lst, (first, second) => new Tuple <int, int>(first, second)); foreach (Tuple <int, int> pair in zipped) { Test.AssertEquals(pair.Item1, pair.Item2); } lst.Dispose(); obj.Dispose(); }
public static void test_async_fulfill() { Efl.Loop loop = Efl.App.AppMain; var obj = new Dummy.TestObject(); Task <Eina.Value> task = obj.GetFutureAsync(); int sentValue = 1337; obj.FulfillPromise(sentValue); loop.Iterate(); Eina.Value v = task.Result; Test.AssertEquals(v.GetValueType(), Eina.ValueType.Int32); int receivedValue; v.Get(out receivedValue); Test.AssertEquals(receivedValue, sentValue); obj.Dispose(); }
public static void TestValueArrayOfObjects() { using (Eina.Value array = new Eina.Value(Eina.ValueType.Array, Eina.ValueType.Object)) { var a = new Dummy.TestObject(); var b = new Dummy.TestObject(); Test.Assert(array.Append(a)); Test.Assert(array.Append(b)); Test.AssertEquals((Efl.Object)array[0], a); Test.AssertEquals((Efl.Object)array[1], b); var c = new Dummy.TestObject(); array[0] = c; array[1] = b; Test.AssertEquals((Efl.Object)array[0], c); Test.AssertEquals((Efl.Object)array[1], b); c.Dispose(); b.Dispose(); a.Dispose(); } }