diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:56:59 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-01-28 20:56:59 +0100 |
commit | 0618b588eadef3ca06adddfaabb9058f7fd8561f (patch) | |
tree | 9e9f67205cd5b72f1031721273e1534a3a1e5b0f /testtools/source/bridgetest/pyuno | |
parent | 25f9289027ffa4c50a9477e65fb65731454e5deb (diff) |
replace obsolete "master" branch with README that points at new repoHEADmaster-deletedmaster
Diffstat (limited to 'testtools/source/bridgetest/pyuno')
-rw-r--r-- | testtools/source/bridgetest/pyuno/core.py | 367 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/impl.py | 196 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/importer.py | 78 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/main.py | 49 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/makefile.mk | 124 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/pyuno | 2 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/samplecomponent.py | 154 | ||||
-rw-r--r-- | testtools/source/bridgetest/pyuno/testcomp.py | 40 |
8 files changed, 0 insertions, 1010 deletions
diff --git a/testtools/source/bridgetest/pyuno/core.py b/testtools/source/bridgetest/pyuno/core.py deleted file mode 100644 index 7199b5d86..000000000 --- a/testtools/source/bridgetest/pyuno/core.py +++ /dev/null @@ -1,367 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -import pyuno -import uno -import unittest -import exceptions -import types - -def suite(ctx): - suite = unittest.TestSuite() - suite.addTest(TestCase("testErrors",ctx)) - suite.addTest(TestCase("testBaseTypes",ctx)) - suite.addTest(TestCase("testOutparam",ctx)) - suite.addTest(TestCase("testStruct",ctx)) - suite.addTest(TestCase("testType",ctx)) - suite.addTest(TestCase("testEnum",ctx)) - suite.addTest(TestCase("testBool",ctx)) - suite.addTest(TestCase("testChar",ctx)) - suite.addTest(TestCase("testUnicode",ctx)) - suite.addTest(TestCase("testConstant",ctx)) - suite.addTest(TestCase("testExceptions",ctx)) - suite.addTest(TestCase("testInterface",ctx)) - suite.addTest(TestCase("testByteSequence",ctx)) - suite.addTest(TestCase("testInvoke",ctx)) - return suite - -def equalsEps( a,b,eps ): - if a - eps <= b and a+eps >= b: - return 1 - return 0 - -def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\ - nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ): - rData.Bool = bBool; - rData.Char = cChar; - rData.Byte = nByte; - rData.Short = nShort; - rData.UShort = nUShort; - rData.Long = nLong; - rData.ULong = nULong; - rData.Hyper = nHyper; - rData.UHyper = nUHyper; - rData.Float = fFloat; - rData.Double = fDouble; - rData.Enum = eEnum; - rData.String = rStr; - rData.Interface = xTest; - rData.Any = rAny; - - -class PythonTransporter: - def __init__( self ): - pass - - def transportAny( self, arg ): - return arg - -class TestCase( unittest.TestCase): - - def __init__(self,method,ctx): - unittest.TestCase.__init__(self,method) - self.ctx = ctx - - def setUp(self): - # the testcomponent from the testtools project - self.tobj = self.ctx.ServiceManager.createInstanceWithContext( - 'com.sun.star.test.bridge.CppTestObject' , self.ctx ) - - self.tobj.Bool = 1 - self.tobj.Char = 'h' - self.tobj.Byte = 43 - self.tobj.Short = -42 - self.tobj.UShort = 44 - self.tobj.Long = 42 - self.tobj.ULong = 41 - self.tobj.Hyper = 46 - self.tobj.UHyper = 47 - self.tobj.Float = 4.3 - self.tobj.Double = 4.2 - self.tobj.Enum = 4 - self.tobj.String = "yabadabadoo" - self.tobj.Interface = self.ctx - self.tobj.Any = self.tobj.String - mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" ) - assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo") - self.tobj.Struct = mystruct - - self.testElement = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" ) - self.testElement.String = "foo" - self.testElement2 = uno.createUnoStruct( "test.testtools.bridgetest.TestElement" ) - self.testElement2.String = "42" - self.tobj.Sequence = (self.testElement,self.testElement2) - - def testBaseTypes(self): - self.failUnless( 42 == self.tobj.Long , "Long attribute" ) - self.failUnless( 41 == self.tobj.ULong , "ULong attribute" ) - self.failUnless( 43 == self.tobj.Byte , "Byte attribute" ) - self.failUnless( 44 == self.tobj.UShort , "UShort attribute" ) - self.failUnless( -42 == self.tobj.Short , "Short attribute" ) - self.failUnless( 46 == self.tobj.Hyper , "Hyper attribute" ) - self.failUnless( 47 == self.tobj.UHyper , "UHyper attribute" ) - self.failUnless( self.tobj.Bool , "Bool attribute2" ) - self.failUnless( "yabadabadoo" == self.tobj.String , "String attribute" ) - self.failUnless( self.tobj.Sequence[0] == self.testElement , "Sequence test") - self.failUnless( self.tobj.Sequence[1] == self.testElement2 , "Sequence2 test") - self.failUnless( equalsEps( 4.3,self.tobj.Float,0.0001) , "float test" ) - self.failUnless( 4.2 == self.tobj.Double , "double test" ) - self.failUnless( self.ctx == self.tobj.Interface , - "object identity test with C++ object" ) - self.failUnless( not self.ctx == self.tobj , "object not identical test " ) - self.failUnless( 42 == self.tobj.transportAny( 42 ), "transportAny long" ) - self.failUnless( "woo, this is python" == self.tobj.transportAny( "woo, this is python" ), \ - "string roundtrip via any test" ) - - def testEnum( self ): - e1 = uno.Enum( "com.sun.star.uno.TypeClass" , "LONG" ) - e2 = uno.Enum( "com.sun.star.uno.TypeClass" , "LONG" ) - e3 = uno.Enum( "com.sun.star.uno.TypeClass" , "UNSIGNED_LONG" ) - e4 = uno.Enum( "test.testtools.bridgetest.TestEnum" , "TWO" ) - self.failUnless( e1 == e2 , "equal enum test" ) - self.failUnless( not (e1 == e3) , "different enums test" ) - self.failUnless( self.tobj.transportAny( e3 ) == e3, "enum roundtrip test" ) - self.tobj.Enum = e4 - self.failUnless( e4 == self.tobj.Enum , "enum assignment failed" ) - - def testType(self ): - t1 = uno.getTypeByName( "com.sun.star.lang.XComponent" ) - t2 = uno.getTypeByName( "com.sun.star.lang.XComponent" ) - t3 = uno.getTypeByName( "com.sun.star.lang.EventObject" ) - self.failUnless( t1.typeClass == \ - uno.Enum( "com.sun.star.uno.TypeClass", "INTERFACE" ), "typeclass of type test" ) - self.failUnless( t3.typeClass == \ - uno.Enum( "com.sun.star.uno.TypeClass", "STRUCT" ), "typeclass of type test") - self.failUnless( t1 == t2 , "equal type test" ) - self.failUnless( t1 == t2 , "equal type test" ) - self.failUnless( t1 == self.tobj.transportAny( t1 ), "type rountrip test" ) - - def testBool( self ): - self.failUnless( uno.Bool(1) , "uno.Bool true test" ) - self.failUnless( not uno.Bool(0) , "uno.Bool false test" ) - self.failUnless( uno.Bool( "true") , "uno.Bool true1 test" ) - self.failUnless( not uno.Bool( "false") , "uno.Bool true1 test" ) - - self.tobj.Bool = uno.Bool(1) - self.failUnless( self.tobj.Bool , "bool true attribute test" ) - self.tobj.Bool = uno.Bool(0) - self.failUnless( not self.tobj.Bool , "bool true attribute test" ) - - # new boolean semantic - self.failUnless( id( self.tobj.transportAny( True ) ) == id(True) , "boolean preserve test") - self.failUnless( id( self.tobj.transportAny( False ) ) == id(False) , "boolean preserve test" ) - self.failUnless( id( self.tobj.transportAny(1) ) != id( True ), "boolean preserve test" ) - self.failUnless( id( self.tobj.transportAny(0) ) != id( False ), "boolean preserve test" ) - - def testChar( self ): - self.tobj.Char = uno.Char( u'h' ) - self.failUnless( self.tobj.Char == uno.Char( u'h' ), "char type test" ) - self.failUnless( isinstance( self.tobj.transportAny( uno.Char(u'h') ),uno.Char),"char preserve test" ) - - def testStruct( self ): - mystruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData" ) - assign( mystruct, 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo") - self.tobj.Struct = mystruct - aSecondStruct = self.tobj.Struct - - self.failUnless( self.tobj.Struct == mystruct, "struct roundtrip for equality test" ) - self.failUnless( aSecondStruct == mystruct, "struct roundtrip for equality test2" ) - aSecondStruct.Short = 720 - self.failUnless( not aSecondStruct == mystruct , "different structs equality test" ) - self.failUnless( not self.ctx == mystruct , "object is not equal to struct test" ) - self.failUnless( mystruct == self.tobj.transportAny( mystruct ), "struct roundtrip with any test" ) - my2ndstruct = uno.createUnoStruct( "test.testtools.bridgetest.TestData", \ - 1, 'h', 43, -42,44,42,41,46,47,4.3,4.2,4,"yabadabadoo",self.ctx,"yabadabadoo",()) - self.failUnless( my2ndstruct == mystruct, "struct non-default ctor test" ) - def testUnicode( self ): - uni = u'\0148' - self.tobj.String = uni - self.failUnless( uni == self.tobj.String ) - - - self.tobj.String = u'dubidu' - self.failUnless( u'dubidu' == self.tobj.String , "unicode comparison test") - self.failUnless( 'dubidu' == self.tobj.String , "unicode vs. string comparison test" ) - - def testConstant( self ): - self.failUnless( uno.getConstantByName( "com.sun.star.beans.PropertyConcept.ATTRIBUTES" ) == 4,\ - "constant retrieval test" ) - - def testExceptions( self ): - unoExc = uno.getClass( "com.sun.star.uno.Exception" ) - ioExc = uno.getClass( "com.sun.star.io.IOException" ) - dispExc = uno.getClass( "com.sun.star.lang.DisposedException" ) - wasHere = 0 - try: - raise ioExc( "huhuh" , self.tobj ) - except unoExc , instance: - wasHere = 1 - self.failUnless( wasHere , "exceptiont test 1" ) - - wasHere = 0 - try: - raise ioExc - except ioExc: - wasHere = 1 - else: - self.failUnless( wasHere, "exception test 2" ) - - wasHere = 0 - try: - raise dispExc - except ioExc: - pass - except unoExc: - wasHere = 1 - self.failUnless(wasHere, "exception test 3") - - illegalArg = uno.getClass( "com.sun.star.lang.IllegalArgumentException" ) - wasHere = 0 - try: - self.tobj.raiseException( 1 , "foo" , self.tobj ) - self.failUnless( 0 , "exception test 5a" ) - except ioExc: - self.failUnless( 0 , "exception test 5b" ) - except illegalArg, i: - self.failUnless( 1 == i.ArgumentPosition , "exception member test" ) - self.failUnless( "foo" == i.Message , "exception member test 2 " ) - wasHere = 1 - else: - self.failUnless( 0, "except test 5c" ) - self.failUnless( wasHere, "illegal argument exception test failed" ) - - def testInterface(self): - clazz = uno.getClass( "com.sun.star.lang.XComponent" ) - self.failUnless( "com.sun.star.lang.XComponent" == clazz.__pyunointerface__ ) - self.failUnless( issubclass( clazz, uno.getClass( "com.sun.star.uno.XInterface" ) ) ) - self.tobj.Interface = None - - - def testOutparam( self): - # outparameter - struct, mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat, \ - mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.getValues( \ - None,None,None,None,None,None,None,None,None,None, \ - None,None,None,None,None,None,None) - self.failUnless(struct == self.tobj.Struct, "outparam 1 test") - self.failUnless(self.tobj.Bool, "outparam 2 test") - self.failUnless(mychar == self.tobj.Char, "outparam 3 test") - self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test") - self.failUnless(myshort == self.tobj.Short, "outparam 5 test") - self.failUnless(myushort == self.tobj.UShort, "outparam 6 test") - self.failUnless(mylong == self.tobj.Long, "outparam 7 test") - self.failUnless(myulong == self.tobj.ULong, "outparam 8 test") - self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test") - self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test") - self.failUnless(myfloat == self.tobj.Float, "outparam 11 test") - self.failUnless(mydouble == self.tobj.Double, "outparam 12 test") - self.failUnless(myenum == self.tobj.Enum, "outparam 13 test") - self.failUnless(mystring == self.tobj.String, "outparam 14 test") - self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test") - self.failUnless(myany == self.tobj.Any, "outparam 16 test") - self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test") - self.failUnless(my2ndstruct == struct, "outparam 18 test") - -# should work, debug on windows, why not -# struct, mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\ -# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct = self.tobj.setValues2( \ -# mybool,mychar,mybyte,myshort,myushort,mylong,myulong,myhyper,myuhyper,myfloat,\ -# mydouble,myenum,mystring,myinterface,myany,myseq,my2ndstruct) -# self.failUnless(struct == self.tobj.Struct, "outparam 1 test") -# self.failUnless( mybool and self.tobj.Bool, "outparam 2 test") -# self.failUnless(mychar == self.tobj.Char, "outparam 3 test") -# self.failUnless(mybyte == self.tobj.Byte, "outparam 4 test") -# self.failUnless(myshort == self.tobj.Short, "outparam 5 test") -# self.failUnless(myushort == self.tobj.UShort, "outparam 6 test") -# self.failUnless(mylong == self.tobj.Long, "outparam 7 test") -# self.failUnless(myulong == self.tobj.ULong, "outparam 8 test") -# self.failUnless(myhyper == self.tobj.Hyper, "outparam 9 test") -# self.failUnless(myuhyper == self.tobj.UHyper, "outparam 10 test") -# self.failUnless(myfloat == self.tobj.Float, "outparam 11 test") -# self.failUnless(mydouble == self.tobj.Double, "outparam 12 test") -# self.failUnless(myenum == self.tobj.Enum, "outparam 13 test") -# self.failUnless(mystring == self.tobj.String, "outparam 14 test") -# self.failUnless(myinterface == self.tobj.Interface, "outparam 15 test") -# self.failUnless(myany == self.tobj.Any, "outparam 16 test") -# self.failUnless(myseq == self.tobj.Sequence, "outparam 17 test") -# self.failUnless(my2ndstruct == struct, "outparam 18 test") - - def testErrors( self ): - - wasHere = 0 - try: - self.tobj.a = 5 - self.fail("attribute a shouldn't exist") - except AttributeError: - wasHere = 1 - except IllegalArgumentException: - wasHere = 1 - self.failUnless( wasHere, "wrong attribute test" ) - - IllegalArgumentException = uno.getClass("com.sun.star.lang.IllegalArgumentException" ) - RuntimeException = uno.getClass("com.sun.star.uno.RuntimeException" ) - -# TODO: Remove this once it is done -# wrong number of arguments bug !? - self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny, 42, 43 ) - self.failUnlessRaises( IllegalArgumentException, self.tobj.transportAny ) - self.failUnlessRaises( RuntimeException, uno.getClass, "a.b" ) - self.failUnlessRaises( RuntimeException, uno.getClass, "com.sun.star.uno.TypeClass" ) - - self.failUnlessRaises( RuntimeException, uno.Enum, "a" , "b" ) - self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.TypeClass" , "b" ) - self.failUnlessRaises( RuntimeException, uno.Enum, "com.sun.star.uno.XInterface" , "b" ) - - tcInterface =uno.Enum( "com.sun.star.uno.TypeClass" , "INTERFACE" ) - self.failUnlessRaises( RuntimeException, uno.Type, "a", tcInterface ) - self.failUnlessRaises( RuntimeException, uno.Type, "com.sun.star.uno.Exception", tcInterface ) - - self.failUnlessRaises( (RuntimeException,exceptions.RuntimeError), uno.getTypeByName, "a" ) - - self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "a" ) - self.failUnlessRaises( (RuntimeException), uno.getConstantByName, "com.sun.star.uno.XInterface" ) - - def testByteSequence( self ): - s = uno.ByteSequence( "ab" ) - self.failUnless( s == uno.ByteSequence( "ab" ) ) - self.failUnless( uno.ByteSequence( "abc" ) == s + uno.ByteSequence( "c" ) ) - self.failUnless( uno.ByteSequence( "abc" ) == s + "c" ) - self.failUnless( s + "c" == "abc" ) - self.failUnless( s == uno.ByteSequence( s ) ) - self.failUnless( s[0] == 'a' ) - self.failUnless( s[1] == 'b' ) - - - def testInvoke( self ): - self.failUnless( 5 == uno.invoke( self.tobj , "transportAny" , (uno.Any("byte", 5),) ) ) - self.failUnless( 5 == uno.invoke( - PythonTransporter(), "transportAny" , (uno.Any( "byte", 5 ),) ) ) - t = uno.getTypeByName( "long" ) - mystruct = uno.createUnoStruct( - "com.sun.star.beans.PropertyValue", "foo",0,uno.Any(t,2),0 ) - mystruct.Value = uno.Any(t, 1) - - diff --git a/testtools/source/bridgetest/pyuno/impl.py b/testtools/source/bridgetest/pyuno/impl.py deleted file mode 100644 index 1b37921aa..000000000 --- a/testtools/source/bridgetest/pyuno/impl.py +++ /dev/null @@ -1,196 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -"tests bridging python implementations of UNO objects" -import unittest -import uno -import unohelper -import os -import sys - -from com.sun.star.io import XOutputStream, XInputStream, typeOfXOutputStream, typeOfXInputStream -from com.sun.star.lang import XTypeProvider, typeOfXTypeProvider, XEventListener -from com.sun.star.uno import XCurrentContext - -class SequenceOutputStream( unohelper.Base, XOutputStream ): - def __init__( self ): - self.s = uno.ByteSequence("") - self.closed = 0 - - def closeOutput(self): - self.closed = 1 - - def writeBytes( self, seq ): - self.s = self.s + seq - - def flush( self ): - pass - - def getSequence( self ): - return self.s - - -class SequenceInputStream( XInputStream, unohelper.Base ): - def __init__( self, seq ): - self.s = seq - self.nIndex = 0 - self.closed = 0 - - def closeInput( self): - self.closed = 1 - self.s = None - - def skipBytes( self, nByteCount ): - if( nByteCount + self.nIndex > len(self.s) ): - nByteCount = len(self.s) - self.nIndex - self.nIndex += nByteCount - - def readBytes( self, retSeq, nByteCount ): - nRet = 0 - if( self.nIndex + nByteCount > len(self.s) ): - nRet = len(self.s) - self.nIndex - else: - nRet = nByteCount - retSeq = uno.ByteSequence(self.s.value[self.nIndex : self.nIndex + nRet ]) - self.nIndex = self.nIndex + nRet - return nRet, retSeq - - def readSomeBytes( self, retSeq , nByteCount ): - #as we never block ! - return readBytes( retSeq, nByteCount ) - - def available( self ): - return len( self.s ) - self.nIndex - -class SequenceInputStream2( SequenceInputStream ): - def __init__( self, seq ): - SequenceInputStream.__init__( self, seq ) - -class TestCase(unittest.TestCase): - def __init__(self,method,ctx): - unittest.TestCase.__init__(self,method) - self.ctx = ctx - - def setUp(self): - self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \ - "com.sun.star.test.bridge.CppTestObject",self.ctx) - self.pipe = self.ctx.ServiceManager.createInstanceWithContext( \ - "com.sun.star.io.Pipe" , self.ctx ) - - def testStandard( self ): - dataOut = self.ctx.ServiceManager.createInstanceWithContext( \ - "com.sun.star.io.DataOutputStream", self.ctx ) - streamOut = SequenceOutputStream() - dataOut.setOutputStream( streamOut ) - dataOut.writeShort( 42 ) - dataOut.writeLong( 43 ) - dataOut.closeOutput() - - dataInput = self.ctx.ServiceManager.createInstanceWithContext( \ - "com.sun.star.io.DataInputStream", self.ctx ) - - dataInput.setInputStream( SequenceInputStream2( streamOut.getSequence() ) ) - - self.failUnless( 42 == dataInput.readShort() ) - self.failUnless( 43 == dataInput.readLong() ) - self.failUnless( self.tobj.transportAny( streamOut ) == streamOut ) - - -class NullDevice: - def write( self, string ): - pass - - -class EventListener( unohelper.Base, XEventListener ): - def __init__( self ): - self.disposingCalled = False - - def disposing( self , eventObject ): - self.disposingCalled = True - -class TestHelperCase( unittest.TestCase ): - - def __init__(self,method): - unittest.TestCase.__init__(self,method) - - def testUrlHelper( self ): - systemPath = os.getcwd() - if systemPath.startswith( "/" ): - self.failUnless( "/tmp" == unohelper.fileUrlToSystemPath( "file:///tmp" ) ) - self.failUnless( "file:///tmp" == unohelper.systemPathToFileUrl( "/tmp" )) - else: - self.failUnless( "c:\\temp" == unohelper.fileUrlToSystemPath( "file:///c:/temp" ) ) - self.failUnless( "file:///c:/temp" == unohelper.systemPathToFileUrl( "c:\\temp" ) ) - - systemPath = unohelper.systemPathToFileUrl( systemPath ) - self.failUnless( systemPath + "/a" == unohelper.absolutize( systemPath, "a" ) ) - def testInspect( self ): - dev = NullDevice() -# dev = sys.stdout - unohelper.inspect( uno.getComponentContext() , dev ) - unohelper.inspect( uno.getComponentContext().ServiceManager , dev ) - unohelper.inspect( uno.getTypeByName( "com.sun.star.lang.XComponent" ) , dev ) - - def testListener( self ): - smgr = uno.getComponentContext().ServiceManager.createInstance( - "com.sun.star.lang.ServiceManager" ) - - # check, whether listeners - listener = EventListener() - smgr.addEventListener( listener ) - smgr.dispose() - self.failUnless( listener.disposingCalled ) - - # check, whether listeners can be removed - smgr = uno.getComponentContext().ServiceManager.createInstance( - "com.sun.star.lang.ServiceManager" ) - listener = EventListener() - smgr.addEventListener( listener ) - smgr.removeEventListener( listener ) - smgr.dispose() - self.failUnless( not listener.disposingCalled ) - - def testCurrentContext( self ): - oldContext = uno.getCurrentContext() - try: - uno.setCurrentContext( - unohelper.CurrentContext( oldContext,{"My42":42}) ) - self.failUnless( 42 == uno.getCurrentContext().getValueByName( "My42" ) ) - self.failUnless( None == uno.getCurrentContext().getValueByName( "My43" ) ) - finally: - uno.setCurrentContext( oldContext ) - - - -def suite( ctx ): - suite = unittest.TestSuite() - suite.addTest(TestCase("testStandard",ctx)) - suite.addTest(TestHelperCase( "testUrlHelper" )) - suite.addTest(TestHelperCase( "testInspect" )) - suite.addTest(TestHelperCase( "testListener" ) ) - suite.addTest(TestHelperCase( "testCurrentContext" ) ) - return suite - diff --git a/testtools/source/bridgetest/pyuno/importer.py b/testtools/source/bridgetest/pyuno/importer.py deleted file mode 100644 index 540cbb12a..000000000 --- a/testtools/source/bridgetest/pyuno/importer.py +++ /dev/null @@ -1,78 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -import unittest -import uno -import unohelper - -from com.sun.star.lang import EventObject,IllegalArgumentException,typeOfIllegalArgumentException -from test.testtools.bridgetest.TestEnum import TWO -from com.sun.star.uno.TypeClass import UNSIGNED_LONG,EXCEPTION -class ImporterTestCase(unittest.TestCase): - def __init__(self,method,ctx): - unittest.TestCase.__init__(self,method) - self.ctx = ctx - - def setUp(self): - self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \ - "com.sun.star.test.bridge.CppTestObject",self.ctx) - - def testStandard( self ): - self.failUnless( IllegalArgumentException != None, "none-test" ) - self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj) - - self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" ) - self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) ) - self.failUnless( typeOfIllegalArgumentException == - uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) ) - - # should not throw an exception - e = EventObject() - e.Source = self.ctx - e = EventObject( self.ctx ) - e = EventObject( e ) - - def testDynamicComponentRegistration( self ): - ctx = uno.getComponentContext() - self.failUnless( - not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()), - "precondition for dynamic component registration test is not fulfilled" ) - self.failUnless( - not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()), - "precondition for dynamic component registration test is not fulfilled" ) - unohelper.addComponentsToContext( - ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" ) - self.failUnless( - ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) ) - self.failUnless( - ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames())) - -def suite( ctx ): - suite = unittest.TestSuite() - suite.addTest(ImporterTestCase("testStandard",ctx)) - suite.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx)) - return suite - diff --git a/testtools/source/bridgetest/pyuno/main.py b/testtools/source/bridgetest/pyuno/main.py deleted file mode 100644 index 835109f1f..000000000 --- a/testtools/source/bridgetest/pyuno/main.py +++ /dev/null @@ -1,49 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -import uno -import unohelper -import importer -import unittest -import core -import impl -import os -import sys - -ctx = uno.getComponentContext() -# needed for the tests -unohelper.addComponentsToContext(ctx,ctx,(os.environ["FOO"]+"/cppobj.uno",os.environ["FOO"]+"/bridgetest.uno","streams.uno","bootstrap.uno"),"com.sun.star.loader.SharedLibrary") - -unohelper.addComponentsToContext(ctx,ctx,("vnd.openoffice.pymodule:samplecomponent",),"com.sun.star.loader.Python") - -runner = unittest.TextTestRunner(sys.stderr,1,2) - -suite = unittest.TestSuite() -suite.addTest(importer.suite(ctx)) -suite.addTest(core.suite(ctx)) -suite.addTest(impl.suite(ctx)) - -runner.run(suite) diff --git a/testtools/source/bridgetest/pyuno/makefile.mk b/testtools/source/bridgetest/pyuno/makefile.mk deleted file mode 100644 index b7a7294dc..000000000 --- a/testtools/source/bridgetest/pyuno/makefile.mk +++ /dev/null @@ -1,124 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=pyuno -TARGET=test -LIBTARGET=NO -TARGETTYPE=CUI -ENABLE_EXCEPTIONS=TRUE - -my_components = pythonloader - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.IF "$(CROSS_COMPILING)"=="YES" -all: - @echo Nothing done when cross-compiling -.ENDIF - -# --- Files -------------------------------------------------------- -.IF "$(DISABLE_PYTHON)" != "TRUE" -.IF "$(L10N_framework)"=="" -PYEXC=$(DLLDEST)$/python$(EXECPOST) -REGEXC=$(DLLDEST)$/regcomp$(EXECPOST) - -.IF "$(SYSTEM_PYTHON)"!="YES" -PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) $(SOLARBINDIR)/python -.ELSE # "$(SYSTEM_PYTHON)"!="YES" -PYTHON=$(AUGMENT_LIBRARY_PATH) $(WRAPCMD) python -.ENDIF # "$(SYSTEM_PYTHON)"!="YES" -.IF "$(GUI)"=="WNT" -PYTHONPATH:=$(SOLARLIBDIR)$/pyuno;$(PWD);$(SOLARLIBDIR);$(SOLARLIBDIR)$/python;$(SOLARLIBDIR)$/python$/lib-dynload -.ELSE # "$(GUI)"=="WNT" -PYTHONPATH:=$(SOLARLIBDIR)$/pyuno:$(PWD):$(SOLARLIBDIR):$(SOLARLIBDIR)$/python:$(SOLARLIBDIR)$/python$/lib-dynload -.ENDIF # "$(GUI)"=="WNT" -.EXPORT: PYTHONPATH - -.IF "$(GUI)"!="WNT" -TEST_ENV=export FOO=file://$(shell @pwd)$/$(DLLDEST) \ - UNO_TYPES=uno_types.rdb UNO_SERVICES=pyuno_services.rdb -.ELSE # "$(GUI)" != "WNT" -# aaaaaa, how to get the current working directory on windows ??? -CWD_TMP=$(strip $(shell @echo "import os;print os.getcwd()" | $(PYTHON))) -TEST_ENV=export FOO=file:///$(strip $(subst,\,/ $(CWD_TMP)$/$(DLLDEST))) && \ - export UNO_TYPES=uno_types.rdb && export UNO_SERVICES=pyuno_services.rdb -.ENDIF # "$(GUI)"!="WNT" -PYFILES = \ - $(DLLDEST)$/core.py \ - $(DLLDEST)$/importer.py \ - $(DLLDEST)$/main.py \ - $(DLLDEST)$/impl.py \ - $(DLLDEST)$/samplecomponent.py \ - $(DLLDEST)$/testcomp.py \ - -PYCOMPONENTS = \ - samplecomponent - -ALL : \ - $(PYFILES) \ - $(DLLDEST)/pyuno_services.rdb \ - doc \ - ALLTAR -.ENDIF # L10N_framework -.ENDIF # DISABLE_PYTHON - -.INCLUDE : target.mk - -.IF "$(DISABLE_PYTHON)" != "TRUE" -.IF "$(L10N_framework)"=="" -$(DLLDEST)$/%.py: %.py - cp $? $@ - -$(DLLDEST)$/python$(EXECPOST) : $(SOLARBINDIR)$/python$(EXECPOST) - cp $? $@ - -$(DLLDEST)$/regcomp$(EXECPOST) : $(SOLARBINDIR)$/regcomp$(EXECPOST) - cp $? $@ - -$(DLLDEST)$/pyuno_services.rdb .ERRREMOVE : \ - $(SOLARENV)/bin/packcomponents.xslt $(MISC)/pyuno_services.input \ - $(my_components:^"$(SOLARXMLDIR)/":+".component") - $(XSLTPROC) --nonet --stringparam prefix $(SOLARXMLDIR)/ -o $@ \ - $(SOLARENV)/bin/packcomponents.xslt $(MISC)/pyuno_services.input - -$(MISC)/pyuno_services.input : - echo \ - '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ - > $@ - -doc .PHONY: - @echo start test with dmake runtest - -runtest : ALL - cd $(DLLDEST) && $(TEST_ENV) && $(PYTHON) main.py -.ENDIF # L10N_framework -.ENDIF # DISABLE_PYTHON - diff --git a/testtools/source/bridgetest/pyuno/pyuno b/testtools/source/bridgetest/pyuno/pyuno deleted file mode 100644 index cf2da2cad..000000000 --- a/testtools/source/bridgetest/pyuno/pyuno +++ /dev/null @@ -1,2 +0,0 @@ -UNO_TYPES=uno_types.rdb -UNO_SERVICES=pyuno_services.rdb diff --git a/testtools/source/bridgetest/pyuno/samplecomponent.py b/testtools/source/bridgetest/pyuno/samplecomponent.py deleted file mode 100644 index 6d378008d..000000000 --- a/testtools/source/bridgetest/pyuno/samplecomponent.py +++ /dev/null @@ -1,154 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -import uno -import unohelper - -from com.sun.star.lang import IllegalArgumentException,XServiceInfo -from com.sun.star.uno import RuntimeException -from com.sun.star.beans import UnknownPropertyException -from test.testtools.bridgetest import TestData,XRecursiveCall,XBridgeTestBase - -g_ImplementationHelper = unohelper.ImplementationHelper() -g_implName = "org.openoffice.comp.pyuno.PythonTestObject" - -g_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \ - "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \ - "String", "Interface", "Any" , "Sequence" , "Struct" - -def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\ - nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ): - rData.Bool = bBool; - rData.Char = cChar; - rData.Byte = nByte; - rData.Short = nShort; - rData.UShort = nUShort; - rData.Long = nLong; - rData.ULong = nULong; - rData.Hyper = nHyper; - rData.UHyper = nUHyper; - rData.Float = fFloat; - rData.Double = fDouble; - rData.Enum = eEnum; - rData.String = rStr; - rData.Interface = xTest; - rData.Any = rAny; - -class MyRecursiveCall( XRecursiveCall, unohelper.Base ): - def callRecursivly( xCall, nToCall ): - if nToCall: - xCall.callRecursivly( self, nToCall -1 ) - -class SampleUnoComponent( XBridgeTestBase,XServiceInfo ): - def __init__(self,ctx): - self.__dict__["callid"] = 0 - self.__dict__["sequenceBroken"] = 0 - - def transportAny( self, value ): - return value - - def raiseException( self, ArgumentPosition, Message, Context ): - raise IllegalArgumentException( Message, Context, ArgumentPosition ) - - def raiseRuntimeExceptionOneway(self, Message, Context ): - raise RuntimeException( Message, Context ) - - def setValues( self, bBool, cChar, nByte, nShort, nUShort, nLong,\ - nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, \ - aString, xInterface, aAny, aSequence, aStruct ): - self.__dict__["data"] = TestDataElements( bBool, cChar, nByte, nShort, nUShort, nLong, - nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, - aAny, aSequence ) - self.__dict__["Struct"] = aStruct - - def setValues2( self, bBool, cChar, nByte, nShort, nUShort, nLong, nULong,\ - nHyper, nUHyper, fFloat, fDouble, eEnum, \ - aString, xInterface, aAny, aSequence, aStruct ): - self.__dict__["Struct"] = TestData( cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\ - nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,\ - aAny, aSequence ) - self.__dict__["Struct"] = aStruct - return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, nULong, \ - nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, aAny, \ - (aSequence[1],aSequence[0]), aStruct - - def getValues(self, a,b,c,d,e,f,g,h, i,j,k,l,m,n): - v = self.__dict__["data"] - return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, v.UShort, v.Long, \ - v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, v.String, v.Interface, \ - v.Any, v.Sequence, self.__dict__["Struct"] - - def call( self, callid, nWaitMUSEC ): - if self.__dict__["callid"] >= callid: - self.__dict__["sequenceBroken"] = 1 - else: - self.__dict__["callid"] = callid - - def callOneway( self, nCallId, nWaitMUSEC ): - call( nCallId, nWaitMUSEC ) - - def sequenceOfCallTestPassed(): - return self.__dict__["sequenceBroken"] - - def startRecursiveCall( xCall , nToCall ): - if nToCall: - xCall.callRecursivly( MyRecursiveCall(), nToCall -1 ) - - def checkExistence( self, name ): - found = 0 - for x in g_attribs: - if x == name: - found = 1 - break - if not found: - raise UnknownPropertyException( "Property "+name+" is unknown", self ) - - def __setattr__( self, name, value ): - checkExistence( name ) - self.__dict__[name] = value - - def __getattr__( self, name ): - checkExistence( name ) - return self.__dict__[name] - - def getSupportedServices( self ): - return g_ImplementationHelper.getSupportedServices(g_implName) - def supportsService( self, ServiceName ): - return g_ImplementationHelper.supportsService( g_implName, ServiceName ) - def getImplementationName(self): - return g_implName - - -g_ImplementationHelper.addImplementation( \ - SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),) - -#g_ImplementationEntries = \ -# unohelper.ImplementationEntry( \ -# "org.openoffice.comp.SamplePythonComponent", \ -# ("com.sun.star.test.bridge.PythonTestObject",), \ -# SampleUnoComponent) \ -# , - diff --git a/testtools/source/bridgetest/pyuno/testcomp.py b/testtools/source/bridgetest/pyuno/testcomp.py deleted file mode 100644 index 14521cf5d..000000000 --- a/testtools/source/bridgetest/pyuno/testcomp.py +++ /dev/null @@ -1,40 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -import uno -import pythonloader - -ctx = uno.getComponentContext() - -loader = pythonloader.Loader( ctx ) -comp = loader.activate( "org.openoffice.comp.pyuno.PythonTestObject" , "", "samplecomponent", ctx ) -ctx.ServiceManager.insert( comp) - -bridgetest = ctx.ServiceManager.createInstanceWithContext( "com.sun.star.test.bridge.BridgeTest", ctx ) -#bridgetest.run( "com.sun.star.test.bridge.PythonTestObject" ) - - - |