Ejemplo n.º 1
0
        static bool performAnyTest(XBridgeTest xLBT, TestDataElements data)
        {
            bool bReturn = true;

            bReturn = testAny(null, data.Byte, xLBT) && bReturn;
            bReturn = testAny(null, data.Short, xLBT) && bReturn;
            bReturn = testAny(null, data.UShort, xLBT) && bReturn;
            bReturn = testAny(null, data.Long, xLBT) && bReturn;
            bReturn = testAny(null, data.ULong, xLBT) && bReturn;
            bReturn = testAny(null, data.Hyper, xLBT) && bReturn;
            bReturn = testAny(null, data.UHyper, xLBT) && bReturn;
            bReturn = testAny(null, data.Float, xLBT) && bReturn;
            bReturn = testAny(null, data.Double, xLBT) && bReturn;
            bReturn = testAny(null, data.Enum, xLBT) && bReturn;
            bReturn = testAny(null, data.String, xLBT) && bReturn;
            bReturn = testAny(typeof(XWeak), data.Interface, xLBT) && bReturn;
            bReturn = testAny(null, data, xLBT) && bReturn;

            {
                Any a1 = new Any(true);
                Any a2 = xLBT.transportAny(a1);
                bReturn = compareData(a2, a1) && bReturn;
            }

            {
                Any a1 = new Any('A');
                Any a2 = xLBT.transportAny(a1);
                bReturn = compareData(a2, a1) && bReturn;
            }
            return(bReturn);
        }
Ejemplo n.º 2
0
        public TestDataElements setValues2(
            /*INOUT*/ ref bool io_bool,
            /*INOUT*/ ref char io_char,
            /*INOUT*/ ref byte io_byte,
            /*INOUT*/ ref short io_short,
            /*INOUT*/ ref ushort io_ushort,
            /*INOUT*/ ref int io_long,
            /*INOUT*/ ref uint io_ulong,
            /*INOUT*/ ref long io_hyper,
            /*INOUT*/ ref ulong io_uhyper,
            /*INOUT*/ ref float io_float,
            /*INOUT*/ ref double io_double,
            /*INOUT*/ ref TestEnum io_testEnum,
            /*INOUT*/ ref String io_string,
            /*INOUT*/ ref byte io_byte2,
            /*INOUT*/ ref short io_short2,
            /*INOUT*/ ref Object io_xInterface,
            /*INOUT*/ ref Any io_any,
            /*INOUT*/ ref TestElement[]    io_testElements,
            /*INOUT*/ ref TestDataElements io_testDataElements)
        {
            Debug.WriteLine("##### " + GetType().FullName + ".setValues2:" + io_any);

            _bool             = io_bool;
            _char             = io_char;
            _byte             = io_byte;
            _short            = io_short;
            _ushort           = io_ushort;
            _long             = io_long;
            _ulong            = io_ulong;
            _hyper            = io_hyper;
            _uhyper           = io_uhyper;
            _float            = io_float;
            _double           = io_double;
            _testEnum         = io_testEnum;
            _string           = io_string;
            _byte2            = io_byte2;
            _short2           = io_short2;
            _xInterface       = io_xInterface;
            _any              = io_any;
            _testElements     = (TestElement[])io_testElements.Clone();
            _testDataElements = io_testDataElements;

            TestElement temp = io_testElements[0];

            io_testElements[0] = io_testElements[1];
            io_testElements[1] = temp;

            return(_testDataElements);
        }
Ejemplo n.º 3
0
 static void assign(TestDataElements rData,
                    bool bBool, char cChar, byte nByte,
                    short nShort, ushort nUShort,
                    int nLong, uint nULong,
                    long nHyper, ulong nUHyper,
                    float fFloat, double fDouble,
                    TestEnum eEnum, string rStr,
                    Object xTest,
                    Any rAny,
                    TestElement[] rSequence)
 {
     assign((TestElement)rData,
            bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
            eEnum, rStr, xTest, rAny);
     rData.Sequence = rSequence;
 }
Ejemplo n.º 4
0
        public TestDataElements getValues(
            /*OUT*/ out bool o_bool,
            /*OUT*/ out char o_char,
            /*OUT*/ out byte o_byte,
            /*OUT*/ out short o_short,
            /*OUT*/ out ushort o_ushort,
            /*OUT*/ out int o_long,
            /*OUT*/ out uint o_ulong,
            /*OUT*/ out long o_hyper,
            /*OUT*/ out ulong o_uhyper,
            /*OUT*/ out float o_float,
            /*OUT*/ out double o_double,
            /*OUT*/ out TestEnum o_testEnum,
            /*OUT*/ out String o_string,
            /*OUT*/ out byte o_byte2,
            /*OUT*/ out short o_short2,
            /*OUT*/ out Object o_xInterface,
            /*OUT*/ out Any o_any,
            /*OUT*/ out TestElement[]    o_testElements,
            /*OUT*/ out TestDataElements o_testDataElements)
        {
            Debug.WriteLine("##### " + GetType().FullName + ".getValues");

            o_bool             = _bool;
            o_char             = _char;
            o_byte             = _byte;
            o_short            = _short;
            o_ushort           = _ushort;
            o_long             = _long;
            o_ulong            = _ulong;
            o_hyper            = _hyper;
            o_uhyper           = _uhyper;
            o_float            = _float;
            o_double           = _double;
            o_testEnum         = _testEnum;
            o_string           = _string;
            o_byte2            = _byte2;
            o_short2           = _short2;
            o_xInterface       = _xInterface;
            o_any              = _any;
            o_testElements     = _testElements;
            o_testDataElements = _testDataElements;

            return(_testDataElements);
        }
Ejemplo n.º 5
0
//    private int _raiseAttr1;


        public void setValues(
            bool bBool,
            char cChar,
            byte nByte,
            short nShort,
            ushort nUShort,
            int nLong,
            uint nULong,
            long nHyper,
            ulong nUHyper,
            float fFloat,
            double fDouble,
            TestEnum testEnum,
            String str,
            byte nByte2,
            short nShort2,
            Object xInterface,
            Any any,
            TestElement []   testElements,
            TestDataElements testDataElements)
        {
            Debug.WriteLine("##### " + GetType().FullName + ".setValues:" + any);

            _bool             = bBool;
            _char             = cChar;
            _byte             = nByte;
            _short            = nShort;
            _ushort           = nUShort;
            _long             = nLong;
            _ulong            = nULong;
            _hyper            = nHyper;
            _uhyper           = nUHyper;
            _float            = fFloat;
            _double           = fDouble;
            _testEnum         = testEnum;
            _string           = str;
            _byte2            = nByte2;
            _short2           = nShort2;
            _xInterface       = xInterface;
            _any              = any;
            _testElements     = testElements;
            _testDataElements = testDataElements;
        }
Ejemplo n.º 6
0
        static bool raiseException(XBridgeTest xLBT)
        {
            int nCount = 0;

            try
            {
                try
                {
                    try
                    {
                        TestDataElements aRet  = new TestDataElements();
                        TestDataElements aRet2 = new TestDataElements();
                        xLBT.raiseException(
                            5, Constants.STRING_TEST_CONSTANT, xLBT.Interface);
                    }
                    catch (unoidl.com.sun.star.lang.IllegalArgumentException aExc)
                    {
                        if (aExc.ArgumentPosition == 5 &&
                            aExc.Context == xLBT.Interface)
                        {
                            ++nCount;
                        }
                        else
                        {
                            check(false, "### unexpected exception content!");
                        }

                        /** it is certain, that the RuntimeException testing will fail,
                         * if no */
                        xLBT.RuntimeException = 0;
                    }
                }
                catch (unoidl.com.sun.star.uno.RuntimeException rExc)
                {
                    if (rExc.Context == xLBT.Interface)
                    {
                        ++nCount;
                    }
                    else
                    {
                        check(false, "### unexpected exception content!");
                    }

                    /** it is certain, that the RuntimeException testing will fail, if no */
                    unchecked
                    {
                        xLBT.RuntimeException = (int)0xcafebabe;
                    }
                }
            }
            catch (unoidl.com.sun.star.uno.Exception rExc)
            {
                if (rExc.Context == xLBT.Interface)
                {
                    ++nCount;
                }
                else

                {
                    check(false, "### unexpected exception content!");
                }
                return(nCount == 3);
            }
            return(false);
        }
Ejemplo n.º 7
0
        bool performTest(XBridgeTest xLBT)
        {
            check(xLBT != null, "### no test interface!");
            bool bRet = true;

            if (xLBT == null)
            {
                return(false);
            }

            // this data is never ever granted access to by calls other than equals(), assign()!
            TestDataElements aData = new TestDataElements(); // test against this data

            Object xI = new WeakBase();

            Any aAny = new Any(typeof(Object), xI);

            assign((TestElement)aData,
                   true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
                   0x123456789abcdef0, 0xfedcba9876543210,
                   17.0815f, 3.1415926359, TestEnum.LOLA,
                   Constants.STRING_TEST_CONSTANT, xI,
                   aAny);

            bRet = check(aData.Any.Value == xI, "### unexpected any!") && bRet;
            bRet = check(!(aData.Any.Value != xI), "### unexpected any!") && bRet;

            aData.Sequence    = new TestElement[2];
            aData.Sequence[0] = new TestElement(
                aData.Bool, aData.Char, aData.Byte, aData.Short,
                aData.UShort, aData.Long, aData.ULong,
                aData.Hyper, aData.UHyper, aData.Float,
                aData.Double, aData.Enum, aData.String,
                aData.Interface, aData.Any);       //(TestElement) aData;
            aData.Sequence[1] = new TestElement(); //is empty

            // aData complete

            // this is a manually copy of aData for first setting...
            TestDataElements aSetData = new TestDataElements();
            Any aAnySet = new Any(typeof(Object), xI);

            assign((TestElement)aSetData,
                   aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
                   aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
                   aData.Enum, aData.String, xI,
                   aAnySet);

            aSetData.Sequence    = new TestElement[2];
            aSetData.Sequence[0] = new TestElement(
                aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short,
                aSetData.UShort, aSetData.Long, aSetData.ULong,
                aSetData.Hyper, aSetData.UHyper, aSetData.Float,
                aSetData.Double, aSetData.Enum, aSetData.String,
                aSetData.Interface, aSetData.Any);    //TestElement) aSetData;
            aSetData.Sequence[1] = new TestElement(); // empty struct

            xLBT.setValues(
                aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
                aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
                aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData);

            {
                TestDataElements aRet  = new TestDataElements();
                TestDataElements aRet2 = new TestDataElements();
                xLBT.getValues(
                    out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short, out aRet.UShort,
                    out aRet.Long, out aRet.ULong, out aRet.Hyper, out aRet.UHyper,
                    out aRet.Float, out aRet.Double, out aRet.Enum, out aRet.String,
                    out aRet.Interface, out aRet.Any, out aRet.Sequence, out aRet2);

                bRet = check(compareData(aData, aRet) && compareData(aData, aRet2), "getValues test") && bRet;

                // set last retrieved values
                TestDataElements aSV2ret = xLBT.setValues2(
                    ref aRet.Bool, ref aRet.Char, ref aRet.Byte, ref aRet.Short, ref aRet.UShort,
                    ref aRet.Long, ref aRet.ULong, ref aRet.Hyper, ref aRet.UHyper, ref aRet.Float,
                    ref aRet.Double, ref aRet.Enum, ref aRet.String, ref aRet.Interface, ref aRet.Any,
                    ref aRet.Sequence, ref aRet2);

                // check inout sequence order
                // => inout sequence parameter was switched by test objects
                TestElement temp = aRet.Sequence[0];
                aRet.Sequence[0] = aRet.Sequence[1];
                aRet.Sequence[1] = temp;

                bRet = check(
                    compareData(aData, aSV2ret) && compareData(aData, aRet2),
                    "getValues2 test") && bRet;
            }
            {
                TestDataElements aRet   = new TestDataElements();
                TestDataElements aRet2  = new TestDataElements();
                TestDataElements aGVret = xLBT.getValues(
                    out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short,
                    out aRet.UShort, out aRet.Long, out aRet.ULong, out aRet.Hyper,
                    out aRet.UHyper, out aRet.Float, out aRet.Double, out aRet.Enum,
                    out aRet.String, out aRet.Interface, out aRet.Any, out aRet.Sequence,
                    out aRet2);

                bRet = check(compareData(aData, aRet) && compareData(aData, aRet2) && compareData(aData, aGVret), "getValues test") && bRet;

                // set last retrieved values
                xLBT.Bool      = aRet.Bool;
                xLBT.Char      = aRet.Char;
                xLBT.Byte      = aRet.Byte;
                xLBT.Short     = aRet.Short;
                xLBT.UShort    = aRet.UShort;
                xLBT.Long      = aRet.Long;
                xLBT.ULong     = aRet.ULong;
                xLBT.Hyper     = aRet.Hyper;
                xLBT.UHyper    = aRet.UHyper;
                xLBT.Float     = aRet.Float;
                xLBT.Double    = aRet.Double;
                xLBT.Enum      = aRet.Enum;
                xLBT.String    = aRet.String;
                xLBT.Interface = aRet.Interface;
                xLBT.Any       = aRet.Any;
                xLBT.Sequence  = aRet.Sequence;
                xLBT.Struct    = aRet2;
            }
            {
                TestDataElements aRet  = new TestDataElements();
                TestDataElements aRet2 = new TestDataElements();
                aRet.Hyper     = xLBT.Hyper;
                aRet.UHyper    = xLBT.UHyper;
                aRet.Float     = xLBT.Float;
                aRet.Double    = xLBT.Double;
                aRet.Byte      = xLBT.Byte;
                aRet.Char      = xLBT.Char;
                aRet.Bool      = xLBT.Bool;
                aRet.Short     = xLBT.Short;
                aRet.UShort    = xLBT.UShort;
                aRet.Long      = xLBT.Long;
                aRet.ULong     = xLBT.ULong;
                aRet.Enum      = xLBT.Enum;
                aRet.String    = xLBT.String;
                aRet.Interface = xLBT.Interface;
                aRet.Any       = xLBT.Any;
                aRet.Sequence  = xLBT.Sequence;
                aRet2          = xLBT.Struct;

                bRet = check(compareData(aData, aRet) && compareData(aData, aRet2), "struct comparison test") && bRet;

                bRet = check(performSequenceTest(xLBT), "sequence test") && bRet;

                // any test
                bRet = check(performAnyTest(xLBT, aData), "any test") && bRet;

                // sequence of call test
                bRet = check(performSequenceOfCallTest(xLBT), "sequence of call test") && bRet;

                // recursive call test
                bRet = check(performRecursiveCallTest(xLBT), "recursive test") && bRet;

                bRet = (compareData(aData, aRet) && compareData(aData, aRet2)) && bRet;

                // check setting of null reference
                xLBT.Interface = null;
                aRet.Interface = xLBT.Interface;
                bRet           = (aRet.Interface == null) && bRet;
            }
            // Test extended attributes that raise exceptions:
            try {
                int i = xLBT.RaiseAttr1;
                bRet &= check(false, "getRaiseAttr1 did not throw");
            } catch (RuntimeException)
            {
            }
            catch (System.Exception) {
                bRet &= check(false, "getRaiseAttr1 threw wrong type");
            }
            try {
                xLBT.RaiseAttr1 = 0;
                bRet           &= check(false, "setRaiseAttr1 did not throw");
            } catch (IllegalArgumentException) {
            } catch (System.Exception) {
                bRet &= check(false, "setRaiseAttr1 threw wrong type");
            }
            try {
                int i = xLBT.RaiseAttr2;
                bRet &= check(false, "getRaiseAttr2 did not throw");
            } catch (IllegalArgumentException) {
            } catch (System.Exception) {
                bRet &= check(false, "getRaiseAttr2 threw wrong type");
            }

            // Test instantiated polymorphic struct types:
            {
                TestPolyStruct poly = new TestPolyStruct(true);
                bRet &= check(
                    (bool)xLBT.transportPolyBoolean(poly).member,
                    "transportPolyBoolean");
                poly = new TestPolyStruct(12345L);
                xLBT.transportPolyHyper(ref poly);
                bRet &= check((long)poly.member == 12345L, "transportPolyUnsignedHyper");

                Any[] seq = { new Any(33), new Any("ABC") };
                poly = new TestPolyStruct(seq);
                TestPolyStruct poly2;
                xLBT.transportPolySequence(poly, out poly2);
                try {
                    Any[] ar = (Any[])poly2.member;
                    bRet &= check(
                        ar.Length == 2, "transportPolySequence, length");

                    int v0;
                    v0    = (int)ar[0].Value;
                    bRet &= check(v0 == 33, "transportPolySequence, element 0");

                    string v1 = (string)ar[1].Value;
                    bRet &= check(
                        v1.Equals("ABC"),
                        "transportPolySequence, element 1");
                } catch (InvalidCastException)
                {
                    bRet &= check(false, "transportPolySequence");
                }

                try {
                    //When the test object is a cli object then them member is null
                    //otherwise the bridge has provided a default value.
                    TestPolyStruct s = xLBT.getNullPolyLong();
                    if (s.member != null)
                    {
                        bRet &= check(((int)s.member) == 0, "getNullPolyLong");
                    }

                    s = xLBT.getNullPolyString();
                    if (s.member != null)
                    {
                        bRet &= check(((string)s.member).Length == 0,
                                      "getNullPolyString");
                    }
                    s = xLBT.getNullPolyType();
                    if (s.member != null)
                    {
                        bRet &= check(((Type)s.member) == typeof(void),
                                      "getNullPolyType");
                    }
                    s = xLBT.getNullPolyAny();
                    if (s.member != null)
                    {
                        Any nullAny = (Any)s.member;
                        //???
                        bRet &= check(nullAny.Type == typeof(void),
                                      "getNullPolyAny");
                    }
                    s = xLBT.getNullPolySequence();
                    if (s.member != null)
                    {
                        bRet &= check(((bool[])s.member).Length == 0,
                                      "getNullPolySequence");
                    }
                    s = xLBT.getNullPolyEnum();
                    if (s.member != null)
                    {
                        bRet &= check(((TestEnum)s.member) == TestEnum.TEST,
                                      "getNullPolyEnum");
                    }
                    s = xLBT.getNullPolyStruct();
                    if (s.member != null)
                    {
                        bRet &= check(((TestStruct)s.member).member == 0,
                                      "getNullPolyStruct");
                    }
                    s     = xLBT.getNullPolyInterface();
                    bRet &= check(s.member == null, "getNullPolyInterface");

                    s     = xLBT.getNullPolyBadEnum();
                    bRet &= check(((TestBadEnum)s.member) == TestBadEnum.M, "getNullPolyBadEnum");
                } catch (InvalidCastException)
                {
                    bRet &= check(false, "getNullPolyXXX, InvalidCastException");
                }
            }

            XBridgeTest2 xBT2 = xLBT as XBridgeTest2;

            if (xBT2 != null)
            {
                try {
                    xBT2.testConstructorsService(m_xContext);
                } catch (BadConstructorArguments) {
                    bRet = false;
                }
            }

            return(bRet);
        }
Ejemplo n.º 8
0
        public TestDataElements setValues2(
        /*INOUT*/ref bool          io_bool,
        /*INOUT*/ref char             io_char,
        /*INOUT*/ref byte             io_byte,
        /*INOUT*/ref short            io_short,
        /*INOUT*/ref ushort            io_ushort,
        /*INOUT*/ref int              io_long,
        /*INOUT*/ref uint              io_ulong,
        /*INOUT*/ref long             io_hyper,
        /*INOUT*/ref ulong             io_uhyper,
        /*INOUT*/ref float            io_float,
        /*INOUT*/ref double           io_double,
        /*INOUT*/ref TestEnum         io_testEnum,
        /*INOUT*/ref String           io_string,
        /*INOUT*/ref Object           io_xInterface,
        /*INOUT*/ref Any           io_any,
        /*INOUT*/ref TestElement[]    io_testElements,
        /*INOUT*/ref TestDataElements io_testDataElements )
        {
            Debug.WriteLine( "##### " + GetType().FullName + ".setValues2:" + io_any );

            _bool             = io_bool;
            _char             = io_char;
            _byte             = io_byte;
            _short            = io_short;
            _ushort           = io_ushort;
            _long             = io_long;
            _ulong            = io_ulong;
            _hyper            = io_hyper;
            _uhyper           = io_uhyper;
            _float            = io_float;
            _double           = io_double;
            _testEnum         = io_testEnum;
            _string           = io_string;
            _xInterface       = io_xInterface;
            _any              = io_any;
            _testElements     = (TestElement[]) io_testElements.Clone();
            _testDataElements = io_testDataElements;

            TestElement temp = io_testElements[ 0 ];
            io_testElements[ 0 ] = io_testElements[ 1 ];
            io_testElements[ 1 ] = temp;

            return _testDataElements;
        }
Ejemplo n.º 9
0
        //    private int _raiseAttr1;
        public void setValues(
        bool          bBool,
        char             cChar,
        byte             nByte,
        short            nShort,
        ushort            nUShort,
        int              nLong,
        uint              nULong,
        long             nHyper,
        ulong             nUHyper,
        float            fFloat,
        double           fDouble,
        TestEnum         testEnum,
        String           str,
        Object           xInterface,
        Any              any,
        TestElement []      testElements,
        TestDataElements testDataElements )
        {
            Debug.WriteLine( "##### " + GetType().FullName + ".setValues:" + any );

            _bool             = bBool;
            _char             = cChar;
            _byte             = nByte;
            _short            = nShort;
            _ushort           = nUShort;
            _long             = nLong;
            _ulong            = nULong;
            _hyper            = nHyper;
            _uhyper           = nUHyper;
            _float            = fFloat;
            _double           = fDouble;
            _testEnum         = testEnum;
            _string           = str;
            _xInterface       = xInterface;
            _any              = any;
            _testElements     = testElements;
            _testDataElements = testDataElements;
        }
Ejemplo n.º 10
0
        public TestDataElements getValues(
        /*OUT*/out bool          o_bool,
        /*OUT*/out char             o_char,
        /*OUT*/out byte             o_byte,
        /*OUT*/out short            o_short,
        /*OUT*/out ushort            o_ushort,
        /*OUT*/out int              o_long,
        /*OUT*/out uint              o_ulong,
        /*OUT*/out long             o_hyper,
        /*OUT*/out ulong             o_uhyper,
        /*OUT*/out float            o_float,
        /*OUT*/out double           o_double,
        /*OUT*/out TestEnum         o_testEnum,
        /*OUT*/out String           o_string,
        /*OUT*/out Object           o_xInterface,
        /*OUT*/out Any           o_any,
        /*OUT*/out TestElement[]    o_testElements,
        /*OUT*/out TestDataElements o_testDataElements )
        {
            Debug.WriteLine( "##### " + GetType().FullName + ".getValues" );

            o_bool             = _bool;
            o_char             = _char;
            o_byte             = _byte;
            o_short            = _short;
            o_ushort           = _ushort;
            o_long             = _long;
            o_ulong            = _ulong;
            o_hyper            = _hyper;
            o_uhyper           = _uhyper;
            o_float            = _float;
            o_double           = _double;
            o_testEnum         = _testEnum;
            o_string           = _string;
            o_xInterface       = _xInterface;
            o_any              = _any;
            o_testElements     = _testElements;
            o_testDataElements = _testDataElements;

            return _testDataElements;
        }
Ejemplo n.º 11
0
        bool performTest(XBridgeTest xLBT)
        {
            check( xLBT != null, "### no test interface!" );
            bool bRet = true;
            if (xLBT == null)
            return false;

            // this data is never ever granted access to by calls other than equals(), assign()!
            TestDataElements aData = new TestDataElements(); // test against this data

            Object xI= new WeakBase();

            Any aAny = new Any( typeof(Object), xI);
            assign( (TestElement)aData,
            true, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98,
            0x123456789abcdef0, 0xfedcba9876543210,
            17.0815f, 3.1415926359, TestEnum.LOLA,
            Constants.STRING_TEST_CONSTANT, xI,
            aAny);

            bRet = check( aData.Any.Value == xI, "### unexpected any!" ) && bRet;
            bRet = check( !(aData.Any.Value != xI), "### unexpected any!" ) && bRet;

            aData.Sequence = new TestElement[2];
            aData.Sequence[0] = new TestElement(
            aData.Bool, aData.Char, aData.Byte, aData.Short,
            aData.UShort, aData.Long, aData.ULong,
            aData.Hyper, aData.UHyper, aData.Float,
            aData.Double, aData.Enum, aData.String,
            aData.Interface, aData.Any); //(TestElement) aData;
            aData.Sequence[1] = new TestElement(); //is empty

            // aData complete

            // this is a manually copy of aData for first setting...
            TestDataElements aSetData = new TestDataElements();
            Any aAnySet= new Any(typeof(Object), xI);
            assign( (TestElement)aSetData,
            aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort,
            aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double,
            aData.Enum, aData.String, xI,
            aAnySet);

            aSetData.Sequence = new TestElement[2];
            aSetData.Sequence[0] = new TestElement(
            aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short,
            aSetData.UShort, aSetData.Long, aSetData.ULong,
            aSetData.Hyper, aSetData.UHyper, aSetData.Float,
            aSetData.Double, aSetData.Enum, aSetData.String,
            aSetData.Interface, aSetData.Any); //TestElement) aSetData;
            aSetData.Sequence[1] = new TestElement(); // empty struct

            xLBT.setValues(
            aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort,
            aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double,
            aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData );

            {
            TestDataElements aRet = new TestDataElements();
            TestDataElements aRet2 = new TestDataElements();
            xLBT.getValues(
            out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short, out aRet.UShort,
            out aRet.Long, out aRet.ULong, out aRet.Hyper, out aRet.UHyper,
            out aRet.Float, out aRet.Double, out aRet.Enum, out aRet.String,
            out aRet.Interface, out aRet.Any, out aRet.Sequence, out aRet2 );

            bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "getValues test") && bRet;

            // set last retrieved values
            TestDataElements aSV2ret = xLBT.setValues2(
            ref aRet.Bool, ref aRet.Char, ref aRet.Byte, ref aRet.Short, ref aRet.UShort,
            ref aRet.Long, ref aRet.ULong, ref aRet.Hyper, ref aRet.UHyper, ref aRet.Float,
            ref aRet.Double, ref aRet.Enum, ref aRet.String, ref aRet.Interface, ref aRet.Any,
            ref aRet.Sequence, ref aRet2 );

            // check inout sequence order
            // => inout sequence parameter was switched by test objects
            TestElement temp = aRet.Sequence[ 0 ];
            aRet.Sequence[ 0 ] = aRet.Sequence[ 1 ];
            aRet.Sequence[ 1 ] = temp;

            bRet = check(
            compareData( aData, aSV2ret ) && compareData( aData, aRet2 ),
            "getValues2 test") && bRet;
            }
            {
            TestDataElements aRet = new TestDataElements();
            TestDataElements aRet2 = new TestDataElements();
            TestDataElements aGVret = xLBT.getValues(
            out aRet.Bool, out aRet.Char, out aRet.Byte, out aRet.Short,
            out aRet.UShort, out aRet.Long, out aRet.ULong, out aRet.Hyper,
            out aRet.UHyper, out aRet.Float, out aRet.Double, out aRet.Enum,
            out aRet.String, out aRet.Interface, out aRet.Any, out aRet.Sequence,
            out aRet2 );

            bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) && compareData( aData, aGVret ), "getValues test" ) && bRet;

            // set last retrieved values
            xLBT.Bool = aRet.Bool;
            xLBT.Char = aRet.Char;
            xLBT.Byte = aRet.Byte;
            xLBT.Short = aRet.Short;
            xLBT.UShort = aRet.UShort;
            xLBT.Long = aRet.Long;
            xLBT.ULong = aRet.ULong;
            xLBT.Hyper = aRet.Hyper;
            xLBT.UHyper = aRet.UHyper;
            xLBT.Float = aRet.Float;
            xLBT.Double = aRet.Double;
            xLBT.Enum = aRet.Enum;
            xLBT.String = aRet.String;
            xLBT.Interface = aRet.Interface;
            xLBT.Any = aRet.Any;
            xLBT.Sequence = aRet.Sequence;
            xLBT.Struct = aRet2;
            }
            {
            TestDataElements aRet = new TestDataElements();
            TestDataElements aRet2 = new TestDataElements();
            aRet.Hyper = xLBT.Hyper;
            aRet.UHyper = xLBT.UHyper;
            aRet.Float = xLBT.Float;
            aRet.Double = xLBT.Double;
            aRet.Byte = xLBT.Byte;
            aRet.Char = xLBT.Char;
            aRet.Bool = xLBT.Bool;
            aRet.Short = xLBT.Short;
            aRet.UShort = xLBT.UShort;
            aRet.Long = xLBT.Long;
            aRet.ULong = xLBT.ULong;
            aRet.Enum = xLBT.Enum;
            aRet.String = xLBT.String;
            aRet.Interface = xLBT.Interface;
            aRet.Any = xLBT.Any;
            aRet.Sequence = xLBT.Sequence;
            aRet2 = xLBT.Struct;

            bRet = check( compareData( aData, aRet ) && compareData( aData, aRet2 ) , "struct comparison test") && bRet;

            bRet = check(performSequenceTest(xLBT), "sequence test") && bRet;

            // any test
            bRet = check( performAnyTest( xLBT , aData ) , "any test" ) && bRet;

            // sequence of call test
            bRet = check( performSequenceOfCallTest( xLBT ) , "sequence of call test" ) && bRet;

            // recursive call test
            bRet = check( performRecursiveCallTest( xLBT ) , "recursive test" ) && bRet;

            bRet = (compareData( aData, aRet ) && compareData( aData, aRet2 )) && bRet ;

            // check setting of null reference
            xLBT.Interface = null;
            aRet.Interface = xLBT.Interface;
            bRet = (aRet.Interface == null) && bRet;

            }
            // Test extended attributes that raise exceptions:
            try {
            int i = xLBT.RaiseAttr1;
            bRet &= check(false, "getRaiseAttr1 did not throw");
            } catch (RuntimeException )
            {
            }
            catch (System.Exception) {
            bRet &= check(false, "getRaiseAttr1 threw wrong type");
            }
            try {
            xLBT.RaiseAttr1 = 0;
            bRet &= check(false, "setRaiseAttr1 did not throw");
            } catch (IllegalArgumentException) {
            } catch (System.Exception) {
            bRet &= check(false, "setRaiseAttr1 threw wrong type");
            }
            try {
            int i = xLBT.RaiseAttr2;
            bRet &= check(false, "getRaiseAttr2 did not throw");
            } catch (IllegalArgumentException ) {
            } catch (System.Exception) {
            bRet &= check(false, "getRaiseAttr2 threw wrong type");
            }

               // Test instantiated polymorphic struct types:
            {
            TestPolyStruct poly = new TestPolyStruct(true);
            bRet &= check(
            (bool) xLBT.transportPolyBoolean(poly).member,
            "transportPolyBoolean");
            poly = new TestPolyStruct(12345L);
            xLBT.transportPolyHyper(ref poly);
            bRet &= check((long)poly.member == 12345L, "transportPolyUnsignedHyper");

            Any[] seq = {  new Any(33), new Any("ABC")};
            poly = new TestPolyStruct(seq);
            TestPolyStruct poly2;
            xLBT.transportPolySequence(poly, out poly2);
            try {
            Any[] ar = (Any[]) poly2.member;
            bRet &= check(
            ar.Length == 2, "transportPolySequence, length");

            int v0;
            v0 = (int) ar[0].Value;
            bRet &= check(v0 == 33, "transportPolySequence, element 0");

            string v1 = (string) ar[1].Value;
            bRet &= check(
            v1.Equals("ABC"),
            "transportPolySequence, element 1");
            } catch (InvalidCastException )
            {
            bRet &= check(false, "transportPolySequence");
            }

            try {
            //When the test object is a cli object then them member is null
            //otherwise the bridge has provided a default value.
            TestPolyStruct s =  xLBT.getNullPolyLong();
            if (s.member != null)
                bRet &= check(((int) s.member) == 0, "getNullPolyLong");

            s = xLBT.getNullPolyString();
            if (s.member != null)
                bRet &= check(((string) s.member).Length == 0,
                              "getNullPolyString");
            s = xLBT.getNullPolyType();
            if (s.member != null)
                bRet &= check(((Type) s.member) == typeof(void),
                              "getNullPolyType");
            s = xLBT.getNullPolyAny();
            if (s.member != null)
            {
                Any nullAny = (Any) s.member;
                //???
                bRet &= check(nullAny.Type == typeof(void),
                    "getNullPolyAny");
            }
            s = xLBT.getNullPolySequence();
            if (s.member != null)
                bRet &= check(((bool[]) s.member).Length == 0,
                              "getNullPolySequence");
            s = xLBT.getNullPolyEnum();
            if (s.member != null)
                bRet &= check(((TestEnum) s.member) == TestEnum.TEST,
                              "getNullPolyEnum");
            s = xLBT.getNullPolyStruct();
            if (s.member != null)
                bRet &= check(((TestStruct) s.member).member == 0,
                              "getNullPolyStruct");
            s = xLBT.getNullPolyInterface();
                bRet &= check(s.member == null, "getNullPolyInterface");

            s = xLBT.getNullPolyBadEnum();
            bRet &= check(((TestBadEnum)s.member) == TestBadEnum.M, "getNullPolyBadEnum");

            } catch(InvalidCastException)
            {
            bRet &= check(false, "getNullPolyXXX, InvalidCastException");
            }

            }

            XBridgeTest2 xBT2 = xLBT as XBridgeTest2;
            if (xBT2 != null) {
            try {
            xBT2.testConstructorsService(m_xContext);
            } catch (BadConstructorArguments) {
            bRet = false;
            }
            }

            return bRet;
        }
Ejemplo n.º 12
0
        static bool raiseException(XBridgeTest xLBT )
        {
            int nCount = 0;
            try
            {
            try
            {
            try
            {
                TestDataElements aRet = new TestDataElements();
                TestDataElements aRet2 = new TestDataElements();
                xLBT.raiseException(
                    5, Constants.STRING_TEST_CONSTANT, xLBT.Interface );
            }
            catch (unoidl.com.sun.star.lang.IllegalArgumentException aExc)
            {
                if (aExc.ArgumentPosition == 5 &&
                    aExc.Context == xLBT.Interface)
                {
                    ++nCount;
                }
                else
                {
                    check( false, "### unexpected exception content!" );
                }

                /** it is certain, that the RuntimeException testing will fail,
                    if no */
                xLBT.RuntimeException = 0;
            }
            }
            catch (unoidl.com.sun.star.uno.RuntimeException rExc)
            {
            if (rExc.Context == xLBT.Interface )
            {
                ++nCount;
            }
            else
            {
                check( false, "### unexpected exception content!" );
            }

            /** it is certain, that the RuntimeException testing will fail, if no */
            unchecked
             {
                 xLBT.RuntimeException = (int) 0xcafebabe;
             }
            }
            }
            catch (unoidl.com.sun.star.uno.Exception  rExc)
            {
            if (rExc.Context == xLBT.Interface)
            {
            ++nCount;
            }
            else

            {
            check( false, "### unexpected exception content!" );
            }
            return (nCount == 3);
            }
            return false;
        }
Ejemplo n.º 13
0
        static bool performAnyTest(XBridgeTest xLBT,  TestDataElements data)
        {
            bool bReturn = true;
            bReturn = testAny( null, data.Byte ,xLBT ) && bReturn;
            bReturn = testAny( null, data.Short,xLBT ) && bReturn;
            bReturn = testAny(  null, data.UShort,xLBT ) && bReturn;
            bReturn = testAny(  null, data.Long,xLBT ) && bReturn;
            bReturn = testAny(  null, data.ULong,xLBT ) && bReturn;
            bReturn = testAny(  null, data.Hyper,xLBT ) && bReturn;
            bReturn = testAny(  null,data.UHyper,xLBT ) && bReturn;
            bReturn = testAny( null, data.Float,xLBT ) && bReturn;
            bReturn = testAny( null, data.Double,xLBT ) && bReturn;
            bReturn = testAny( null, data.Enum,xLBT ) && bReturn;
            bReturn = testAny( null, data.String,xLBT ) && bReturn;
            bReturn = testAny(typeof(XWeak), data.Interface,xLBT ) && bReturn;
            bReturn = testAny(null, data, xLBT ) && bReturn;

            {
            Any a1= new Any(true);
            Any a2 = xLBT.transportAny( a1 );
            bReturn = compareData(a2, a1) && bReturn;
            }

            {
            Any a1= new Any('A');
            Any a2 = xLBT.transportAny(a1);
            bReturn = compareData(a2, a1) && bReturn;
            }
            return bReturn;
        }
Ejemplo n.º 14
0
        static void assign( TestDataElements rData,
					bool bBool, char cChar, byte nByte,
					short nShort, ushort nUShort,
					int nLong, uint nULong,
					long nHyper, ulong nUHyper,
					float fFloat, double fDouble,
					TestEnum eEnum, string rStr,
					Object xTest,
					Any rAny,
					TestElement[] rSequence)
        {
            assign( (TestElement) rData,
            bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble,
            eEnum, rStr, xTest, rAny );
            rData.Sequence = rSequence;
        }