示例#1
0
文件: Structs.cs 项目: sav/efl
        // public static void complex_ptr_out()
        // {
        // }

        // public static void complex_ptr_out_own()
        // {
        // }

        public static void complex_return()
        {
            test.ITesting t       = new test.Testing();
            var           complex = t.StructComplexReturn();

            checkStructComplex(complex);
        }
示例#2
0
        public static void replace_callback()
        {
            setup();

            test.ITesting obj = new test.Testing();
            obj.SetCallback(twice);
            Test.Assert(called == false, "set_callback should not call the callback");

            int x = obj.CallCallback(42);

            Test.Assert(called, "call_callback must call a callback");
            Test.AssertEquals(42 * 2, x);

            bool new_called = false;

            obj.SetCallback(y => {
                new_called = true;
                return(y * y);
            });

            Test.Assert(new_called == false, "set_callback should not call the callback");

            x = obj.CallCallback(42);
            Test.Assert(new_called, "call_callback must call a callback");
            Test.AssertEquals(42 * 42, x);
        }
示例#3
0
文件: EoPromises.cs 项目: sav/efl
        public static void test_object_promise_cancel()
        {
            efl.ILoop    loop = efl.App.GetLoopMain();
            test.Testing obj  = new test.Testing();

            eina.Future future = obj.GetFuture();

            bool callbackCalled = false;

            eina.Error receivedError = -1;
            eina.Error sentError     = 120;
            future.Then((eina.Value value) => {
                callbackCalled = true;
                Test.AssertEquals(value.GetValueType(), eina.ValueType.Error);
                value.Get(out receivedError);

                return(value);
            });

            obj.RejectPromise(sentError);

            loop.Iterate();
            Test.Assert(callbackCalled, "Future callback must have been called.");
            Test.AssertEquals(receivedError, sentError);
        }
示例#4
0
文件: EoPromises.cs 项目: sav/efl
        public static void test_async_reject()
        {
            efl.ILoop     loop = efl.App.GetLoopMain();
            test.ITesting obj  = new test.Testing();

            Task <eina.Value> task = obj.GetFutureAsync();

            eina.Error sentError = 1337;
            obj.RejectPromise(sentError);

            loop.Iterate();

            bool raised = false;

            try
            {
                eina.Value v = task.Result;
            }
            catch (AggregateException ae)
            {
                raised = true;
                ae.Handle((x) =>
                {
                    Test.Assert(x is efl.FutureException, "AggregateException must have been TaskCanceledException");
                    efl.FutureException ex = x as efl.FutureException;
                    Test.AssertEquals(ex.Error, sentError);
                    return(true);
                });
            }

            Test.Assert(raised, "AggregateException must have been raised.");
        }
示例#5
0
文件: EoPromises.cs 项目: sav/efl
        public static void test_async_cancel()
        {
            efl.ILoop     loop = efl.App.GetLoopMain();
            test.ITesting obj  = new test.Testing();

            CancellationTokenSource cancelSrc = new CancellationTokenSource();
            Task <eina.Value>       task      = obj.GetFutureAsync(cancelSrc.Token);

            cancelSrc.Cancel();
            loop.Iterate();

            bool raised = false;

            try
            {
                eina.Value v = task.Result;
            }
            catch (AggregateException ae)
            {
                raised = true;
                ae.Handle((x) =>
                {
                    Test.Assert(x is TaskCanceledException, "AggregateException must have been TaskCanceledException");
                    return(true);
                });
            }

            Test.Assert(raised, "AggregateException must have been raised.");
        }
示例#6
0
文件: Structs.cs 项目: sav/efl
        public static void simple_ptr_return_own()
        {
            test.ITesting t      = new test.Testing();
            var           simple = t.StructSimplePtrReturnOwn();

            Test.AssertEquals(simple.Fstring, "Ret Ptr Own");
        }
示例#7
0
文件: EoPromises.cs 项目: sav/efl
        public static void test_object_promise()
        {
            efl.ILoop    loop = efl.App.GetLoopMain();
            test.Testing obj  = new test.Testing();

            eina.Future future = obj.GetFuture();

            bool callbackCalled = false;
            int  receivedValue  = -1;
            int  sentValue      = 1984;

            future.Then((eina.Value value) => {
                callbackCalled = true;
                Test.AssertEquals(value.GetValueType(), eina.ValueType.Int32);
                value.Get(out receivedValue);

                return(value);
            });

            obj.FulfillPromise(sentValue);

            loop.Iterate();
            Test.Assert(callbackCalled, "Future callback must have been called.");
            Test.AssertEquals(receivedValue, sentValue);
        }
示例#8
0
文件: Structs.cs 项目: sav/efl
        public static void simple_return()
        {
            test.ITesting t      = new test.Testing();
            var           simple = t.StructSimpleReturn();

            checkStructSimple(simple);
        }
示例#9
0
文件: Structs.cs 项目: sav/efl
 public static void simple_ptr_out_own()
 {
     test.StructSimple simple;
     test.ITesting     t      = new test.Testing();
     test.StructSimple result = t.StructSimplePtrOutOwn(out simple);
     Test.AssertEquals(result.Fint, simple.Fint);
     Test.AssertEquals(simple.Fstring, "Ptr Out Own");
 }
示例#10
0
 /* The managed call is free to own the returned string */
 public static void return_own_string()
 {
     {
         test.ITesting obj = new test.Testing();
         Test.AssertEquals("own_string", obj.ReturnOwnString());
     }
     System.GC.Collect();
 }
示例#11
0
        public static void name_getset()
        {
            test.ITesting obj = new test.Testing();

            string name = "Dummy";

            obj.SetName(name);
            Test.AssertEquals(name, obj.GetName());
        }
示例#12
0
文件: Structs.cs 项目: sav/efl
        // Complex Structs
        public static void complex_in()
        {
            var complex = structComplexWithValues();

            test.ITesting t = new test.Testing();
            bool          r = t.StructComplexIn(complex);

            Test.Assert(r, "Function returned false");
        }
示例#13
0
文件: Structs.cs 项目: sav/efl
        // As parameters

        public static void simple_in()
        {
            var simple = structSimpleWithValues();

            test.ITesting t = new test.Testing();
            bool          r = t.StructSimpleIn(simple);

            Test.Assert(r, "Function returned false");
        }
示例#14
0
        public static void parent_inherited_class()
        {
            test.INumberwrapper parent = new test.Numberwrapper(null);
            test.ITesting       child  = new test.Testing(parent);

            Test.AssertEquals(parent, child.GetParent());

            test.INumberwrapper parent_retrieved = test.Numberwrapper.static_cast(child.GetParent());
            Test.AssertEquals(parent, parent_retrieved);
        }
示例#15
0
 /* The managed call is still owner of the sent string */
 public static void in_string()
 {
     {
         test.ITesting obj      = new test.Testing();
         String        sent     = "in_string";
         String        returned = obj.InString(sent);
         Test.AssertEquals(sent, returned);
     }
     System.GC.Collect();
 }
示例#16
0
        public static void basic_parent()
        {
            test.Testing parent = new test.TestingConcrete(null);
            test.Testing child  = new test.TestingConcrete(parent);

            Test.AssertEquals(parent, child.GetParent());

            test.Testing parent_retrieved = test.TestingConcrete.static_cast(child.GetParent());
            Test.AssertEquals(parent, parent_retrieved);
        }
示例#17
0
 /* The managed call is the owner of the string in the out parameter */
 public static void out_own_string()
 {
     {
         String        str = String.Empty;
         test.ITesting obj = new test.Testing();
         obj.OutOwnString(out str);
         Test.AssertEquals(str.ToString(), "out_own_string");
     }
     System.GC.Collect();
 }
示例#18
0
        public static void test_eolian()
        {
            test.ITesting obj = new test.Testing();
            eina.Strbuf   buf = new eina.Strbuf();

            obj.AppendToStrbuf(buf, "Appended");
            obj.AppendToStrbuf(buf, " to buf");

            Test.AssertEquals("Appended to buf", buf.Steal());
        }
示例#19
0
文件: Structs.cs 项目: sav/efl
        public static void simple_out()
        {
            var simple = new test.StructSimple();

            test.ITesting t = new test.Testing();
            bool          r = t.StructSimpleOut(out simple);

            Test.Assert(r, "Function returned false");
            checkStructSimple(simple);
        }
示例#20
0
        public static void basic_parent_managed_inherit()
        {
            test.Testing parent = new Derived(null);
            test.Testing child  = new Derived(parent);

            Test.AssertEquals(parent, child.GetParent());

            test.Testing parent_from_cast = test.TestingInherit.static_cast(child.GetParent());
            Test.AssertEquals(parent, parent_from_cast);
        }
示例#21
0
文件: Structs.cs 项目: sav/efl
        // public static void complex_ptr_in()
        // {
        // }

        // public static void complex_ptr_in_own()
        // {
        // }

        public static void complex_out()
        {
            var complex = new test.StructComplex();

            test.ITesting t = new test.Testing();
            bool          r = t.StructComplexOut(out complex);

            Test.Assert(r, "Function returned false");
            checkStructComplex(complex);
        }
示例#22
0
 //
 // Test cases:
 //
 public static void return_same_object()
 {
     test.Testing testing = new test.TestingConcrete();
     test.Testing o1      = testing.ReturnObject();
     Test.Assert(o1.raw_handle != IntPtr.Zero);
     Test.Assert(o1.raw_handle == testing.raw_handle);
     test.Testing o2 = o1.ReturnObject();
     Test.Assert(o2.raw_handle != IntPtr.Zero);
     Test.Assert(o2.raw_handle == o1.raw_handle);
 }
示例#23
0
 /* The managed call is *not* the owner of the string put in the out argument */
 public static void out_string()
 {
     {
         String        str = String.Empty;
         test.ITesting obj = new test.Testing();
         obj.OutString(out str);
         Test.AssertEquals("out_string", str);
     }
     System.GC.Collect();
 }
示例#24
0
文件: Structs.cs 项目: sav/efl
        public static void simple_ptr_in_own()
        {
            var simple   = structSimpleWithValues();
            int original = simple.Fint;

            simple.Fmstring = "Struct Ptr In Own";
            test.ITesting     t      = new test.Testing();
            test.StructSimple result = t.StructSimplePtrInOwn(ref simple);
            Test.AssertEquals(-original, result.Fint);
            Test.AssertEquals("nwO nI rtP tcurtS", result.Fmstring);
        }
示例#25
0
文件: Structs.cs 项目: sav/efl
        public static void simple_ptr_in()
        {
            var simple   = structSimpleWithValues();
            int original = simple.Fint;

            simple.Fmstring = "Struct Ptr In";
            test.ITesting t = new test.Testing();
            Test.Assert(t.StructSimplePtrIn(ref simple));
            Test.AssertEquals(-original, simple.Fint);
            Test.AssertEquals("nI rtP tcurtS", simple.Fmstring);
        }
示例#26
0
        public static void basic_typedef_test()
        {
            test.ITesting obj   = new test.Testing();
            test.MyInt    input = 1900;
            test.MyInt    receiver;

            int ret = obj.BypassTypedef(input, out receiver);

            Test.AssertEquals((test.MyInt)ret, input);
            Test.AssertEquals(receiver, input);
        }
示例#27
0
        public static void simple_out()
        {
            int original = 1984;
            int received;

            test.ITesting t = new test.Testing();

            t.IntOut(original, out received);

            Test.AssertEquals(-original, received);
        }
示例#28
0
文件: Errors.cs 项目: sav/efl
        public static void eina_error_event_raise_exception()
        {
            // An event whose managed delegate generates an exception
            // must set an eina_error so it can be reported back to
            // the managed code
            test.ITesting obj      = new test.Testing();
            Listener      listener = new Listener();

            obj.EvtWithIntEvt += listener.callback;

            Test.AssertRaises <efl.EflException>(() => { obj.EmitEventWithInt(2); });
        }
示例#29
0
        /* Commented out as adding the event listener seems to prevent it from being GC'd.
         * public static void destructor_really_frees()
         * {
         * bool delEventCalled = false;
         * {
         *     test.ITesting obj = new test.Testing();
         *     obj.DEL += (object sender, EventArgs e) => { delEventCalled = true; };
         * }
         *
         * System.GC.WaitForPendingFinalizers();
         * System.GC.Collect();
         * System.GC.WaitForPendingFinalizers();
         * System.GC.Collect();
         * System.GC.WaitForPendingFinalizers();
         *
         * Test.Assert(delEventCalled, "DEL event not called");
         * } */

        public static void dispose_really_frees()
        {
            bool delEventCalled = false;

            {
                test.ITesting obj = new test.Testing();
                obj.DelEvt += (object sender, EventArgs e) => { delEventCalled = true; };
                ((IDisposable)obj).Dispose();
            }

            Test.Assert(delEventCalled, "DEL event not called");
        }
示例#30
0
文件: Events.cs 项目: sav/efl
        public static void event_with_uint_payload()
        {
            test.ITesting obj           = new test.Testing();
            uint          received_uint = 0;

            obj.EvtWithUintEvt += (object sender, EvtWithUintEvt_Args e) => {
                received_uint = e.arg;
            };

            obj.EmitEventWithUint(0xbeef);

            Test.AssertEquals <uint>(0xbeef, received_uint);
        }