コード例 #1
0
        public static void event_with_double_payload()
        {
            var    obj             = new Dummy.TestObject();
            double received_double = 0;
            double reference       = float.MaxValue + 42;

            obj.EvtWithDoubleEvent += (object sender, Dummy.TestObjectEvtWithDoubleEventArgs e) => {
                received_double = e.arg;
            };

            obj.EmitEventWithDouble(reference);

            Test.AssertAlmostEquals(reference, received_double);
            obj.Dispose();
        }
コード例 #2
0
ファイル: Events.cs プロジェクト: cederom/efl
        // For events named line focus_geometry,changed
        public static void test_event_naming()
        {
            var obj         = new Dummy.TestObject();
            var test_called = false;

            EventHandler cb = (object sender, EventArgs e) => {
                test_called = true;
            };

            obj.EvtWithUnderEvt += cb;

            obj.EmitEventWithUnder();

            Test.Assert(test_called);
        }
コード例 #3
0
ファイル: Events.cs プロジェクト: AmarokPL/efl
        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);
        }
コード例 #4
0
        public static void TestEolianEinaValueInReturn()
        {
            var obj = new Dummy.TestObject();

            using (Eina.Value v = new Eina.Value(Eina.ValueType.Int32)) {
                v.Set(42);
                obj.SetValuePtr(v);
                Test.AssertEquals(Eina.Ownership.Managed, v.Ownership);

                Eina.Value v_received = obj.GetValuePtrOwn();
                Test.AssertEquals(Eina.Ownership.Managed, v_received.Ownership);
                Test.AssertEquals(v, v_received);
                v_received.Dispose();
            }
            obj.Dispose();
        }
コード例 #5
0
ファイル: Events.cs プロジェクト: AmarokPL/efl
        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);
        }
コード例 #6
0
ファイル: Events.cs プロジェクト: AmarokPL/efl
        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);
        }
コード例 #7
0
        // 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);
        }
コード例 #8
0
        public static void TestObjectContainerFromToObject()
        {
            var initialBag = new Eina.Array <Efl.Object>();
            var tmp1       = new Dummy.TestObject();
            var tmp2       = new Dummy.TestObject();
            var tmp3       = new Dummy.TestObject();

            initialBag.Push(tmp1);
            initialBag.Push(tmp2);
            initialBag.Push(tmp3);

            var source = new ComplexHolder {
                BagOfObjects = initialBag
            };
            var prop = source.GetType().GetProperty("BagOfObjects");
            var v    = new Eina.Value(prop.GetValue(source));

            Test.AssertEquals(prop.GetValue(source), initialBag);

            Test.AssertEquals(v.GetValueType(), Eina.ValueType.Array);
            Test.AssertEquals(v.GetValueSubType(), Eina.ValueType.Object);

            Test.AssertEquals(v[0], initialBag[0]);
            Test.AssertEquals(v[1], initialBag[1]);
            Test.AssertEquals(v[2], initialBag[2]);

            var first  = new Dummy.TestObject();
            var second = new Dummy.TestObject();
            var third  = new Dummy.TestObject();

            v[0] = first;
            v[1] = second;
            v[2] = third;

            prop.SetValue(source, v.Unwrap());

            IEnumerable <Efl.Object> newVal = prop.GetValue(source) as IEnumerable <Efl.Object>;
            var toCheck = newVal.ToList();

            Test.AssertEquals(toCheck[0], first);
            Test.AssertEquals(toCheck[1], second);
            Test.AssertEquals(toCheck[2], third);
            tmp3.Dispose();
            tmp2.Dispose();
            tmp1.Dispose();
            v.Dispose();
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        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();
        }
コード例 #11
0
ファイル: Events.cs プロジェクト: AmarokPL/efl
        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);
        }
コード例 #12
0
ファイル: Eo.cs プロジェクト: Ali-Alzyoud/efl-1
        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();
        }
コード例 #13
0
ファイル: ValueEolian.cs プロジェクト: AmarokPL/efl
        public static void TestEolianEinaValueImplicitOperators()
        {
            var obj     = new Dummy.TestObject();
            int payload = 1999;

            obj.SetValue(payload);

            var expected = new Eina.Value(1999);
            var received = new Eina.Value(Eina.ValueType.String);

            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Int32, received.GetValueType());

            int i = received;

            Test.AssertEquals(i, 1999);

            expected = new Eina.Value("Hallo");
            obj.SetValue("Hallo");

            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.String, received.GetValueType());

            string s = received;

            Test.AssertEquals(s, "Hallo");

            // Casting
            expected = new Eina.Value((double)15);
            obj.SetValue((double)15);

            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Double, received.GetValueType());

            // Check for 0
            // This is a special value, since C# can silently convert it to an enum
            // leading to collisions with Eina.ValueType
            expected = new Eina.Value(0);
            obj.SetValue(0);
            obj.OutValue(out received);
            Test.AssertEquals(expected, received);
            Test.AssertEquals(Eina.ValueType.Int32, received.GetValueType());
        }
コード例 #14
0
ファイル: Events.cs プロジェクト: AmarokPL/efl
        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);
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: ValueEolian.cs プロジェクト: AmarokPL/efl
        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();
            }
        }
コード例 #18
0
ファイル: Value.cs プロジェクト: AmarokPL/efl
        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);
            }
        }
コード例 #19
0
ファイル: EoPromises.cs プロジェクト: zmike/efl-tmp
        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);
        }
コード例 #20
0
        public static void func_pointer_marshalling()
        {
            var  obj    = new Dummy.TestObject();
            bool called = false;

            Eina.Strbuf buf      = new Eina.Strbuf();
            string      argument = "Some String";

            Eina.Value v = new Eina.Value(Eina.ValueType.String);
            v.Set(argument);
            string reference = new string(argument.ToCharArray().Reverse().ToArray());

            obj.CallFormatCb(buf, v, (Eina.Strbuf ibuf, Eina.Value val) => {
                called     = true;
                string str = null;
                val.Get(out str);
                buf.Append(new string(str.ToCharArray().Reverse().ToArray()));
            });

            Test.Assert(called, "Callback was not called");
            Test.AssertEquals(reference, buf.Steal());
        }
コード例 #21
0
ファイル: Eo.cs プロジェクト: Ali-Alzyoud/efl-1
 public Derived(Dummy.TestObject parent = null) : base(parent)
 {
 }
コード例 #22
0
ファイル: Eo.cs プロジェクト: AmarokPL/efl
        public static void test_protected_interface_in_generated_class_called_from_c()
        {
            var obj = new Dummy.TestObject();

            Test.AssertEquals(obj.CallMethodProtected(42), -42);
        }
コード例 #23
0
        public static void test_csharp_multi_keyed_multi_valued_prop()
        {
            var obj = new Dummy.TestObject();

            obj.MultiKeyedMultiValuedProp[(100, 101)] = (1, 2);
コード例 #24
0
ファイル: Eo.cs プロジェクト: Ali-Alzyoud/efl-1
 public ProviderHolder() : base(null)
 {
     this.provider           = new Dummy.TestObject(this);
     this.provider.Name      = ProviderHolder.ProviderName;
     this.provider.IfaceProp = 1997;
 }
コード例 #25
0
ファイル: Parts.cs プロジェクト: zmike/efl-tmp
        public static void basic_part_test()
        {
            var t = new Dummy.TestObject();

            do_part_test(t);
        }
コード例 #26
0
        public static void test_getter_only()
        {
            var obj = new Dummy.TestObject();

            Test.Assert(!obj.Invalidating);
        }