1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
30 from com
.sun
.star
.lang
import IllegalArgumentException
,XServiceInfo
31 from com
.sun
.star
.uno
import RuntimeException
32 from com
.sun
.star
.beans
import UnknownPropertyException
33 from test
.testtools
.bridgetest
import TestData
,XRecursiveCall
,XBridgeTestBase
35 g_ImplementationHelper
= unohelper
.ImplementationHelper()
36 g_implName
= "org.openoffice.comp.pyuno.PythonTestObject"
38 g_attribs
= "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
39 "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
40 "String", "Interface", "Any" , "Sequence" , "Struct"
42 def assign( rData
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
,\
43 nUHyper
, fFloat
, fDouble
, eEnum
, rStr
, xTest
, rAny
):
48 rData
.UShort
= nUShort
;
52 rData
.UHyper
= nUHyper
;
54 rData
.Double
= fDouble
;
57 rData
.Interface
= xTest
;
60 class MyRecursiveCall( XRecursiveCall
, unohelper
.Base
):
61 def callRecursivly( xCall
, nToCall
):
63 xCall
.callRecursivly( self
, nToCall
-1 )
65 class SampleUnoComponent( XBridgeTestBase
,XServiceInfo
):
66 def __init__(self
,ctx
):
67 self
.__dict
__["callid"] = 0
68 self
.__dict
__["sequenceBroken"] = 0
70 def transportAny( self
, value
):
73 def raiseException( self
, ArgumentPosition
, Message
, Context
):
74 raise IllegalArgumentException( Message
, Context
, ArgumentPosition
)
76 def raiseRuntimeExceptionOneway(self
, Message
, Context
):
77 raise RuntimeException( Message
, Context
)
79 def setValues( self
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
,\
80 nULong
, nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, \
81 aString
, xInterface
, aAny
, aSequence
, aStruct
):
82 self
.__dict
__["data"] = TestDataElements( bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
,
83 nULong
, nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,
85 self
.__dict
__["Struct"] = aStruct
87 def setValues2( self
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,\
88 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, \
89 aString
, xInterface
, aAny
, aSequence
, aStruct
):
90 self
.__dict
__["Struct"] = TestData( cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
,\
91 nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,\
93 self
.__dict
__["Struct"] = aStruct
94 return bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, nULong
, \
95 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
, aAny
, \
96 (aSequence
[1],aSequence
[0]), aStruct
98 def getValues(self
, a
,b
,c
,d
,e
,f
,g
,h
, i
,j
,k
,l
,m
,n
):
99 v
= self
.__dict
__["data"]
100 return self
.__dict
__["Struct"],v
.Bool
, v
.Char
, v
.Byte
, v
.Short
, v
.UShort
, v
.Long
, \
101 v
.ULong
, v
.Hyper
, v
.UHyper
, v
.Float
, v
.Double
, v
.Enum
, v
.String
, v
.Interface
, \
102 v
.Any
, v
.Sequence
, self
.__dict
__["Struct"]
104 def call( self
, callid
, nWaitMUSEC
):
105 if self
.__dict
__["callid"] >= callid
:
106 self
.__dict
__["sequenceBroken"] = 1
108 self
.__dict
__["callid"] = callid
110 def callOneway( self
, nCallId
, nWaitMUSEC
):
111 call( nCallId
, nWaitMUSEC
)
113 def sequenceOfCallTestPassed():
114 return self
.__dict
__["sequenceBroken"]
116 def startRecursiveCall( xCall
, nToCall
):
118 xCall
.callRecursivly( MyRecursiveCall(), nToCall
-1 )
120 def checkExistence( self
, name
):
127 raise UnknownPropertyException( "Property "+name
+" is unknown", self
)
129 def __setattr__( self
, name
, value
):
130 checkExistence( name
)
131 self
.__dict
__[name
] = value
133 def __getattr__( self
, name
):
134 checkExistence( name
)
135 return self
.__dict
__[name
]
137 def getSupportedServices( self
):
138 return g_ImplementationHelper
.getSupportedServices(g_implName
)
139 def supportsService( self
, ServiceName
):
140 return g_ImplementationHelper
.supportsService( g_implName
, ServiceName
)
141 def getImplementationName(self
):
145 g_ImplementationHelper
.addImplementation( \
146 SampleUnoComponent
,g_implName
,("com.sun.star.test.bridge.PythonTestObject",),)
148 #g_ImplementationEntries = \
149 # unohelper.ImplementationEntry( \
150 # "org.openoffice.comp.SamplePythonComponent", \
151 # ("com.sun.star.test.bridge.PythonTestObject",), \
152 # SampleUnoComponent) \