2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 from com
.sun
.star
.lang
import IllegalArgumentException
,XServiceInfo
22 from com
.sun
.star
.uno
import RuntimeException
23 from com
.sun
.star
.beans
import UnknownPropertyException
24 from test
.testtools
.bridgetest
import TestData
,XRecursiveCall
,XBridgeTestBase
26 g_ImplementationHelper
= unohelper
.ImplementationHelper()
27 g_implName
= "org.openoffice.comp.pyuno.PythonTestObject"
29 g_attribs
= "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
30 "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
31 "String", "Interface", "Any" , "Sequence" , "Struct"
33 def assign( rData
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
,\
34 nUHyper
, fFloat
, fDouble
, eEnum
, rStr
, xTest
, rAny
):
39 rData
.UShort
= nUShort
;
43 rData
.UHyper
= nUHyper
;
45 rData
.Double
= fDouble
;
48 rData
.Interface
= xTest
;
51 class MyRecursiveCall( XRecursiveCall
, unohelper
.Base
):
52 def callRecursivly( xCall
, nToCall
):
54 xCall
.callRecursivly( self
, nToCall
-1 )
56 class SampleUnoComponent( XBridgeTestBase
,XServiceInfo
):
57 def __init__(self
,ctx
):
58 self
.__dict
__["callid"] = 0
59 self
.__dict
__["sequenceBroken"] = 0
61 def transportAny( self
, value
):
64 def raiseException( self
, ArgumentPosition
, Message
, Context
):
65 raise IllegalArgumentException( Message
, Context
, ArgumentPosition
)
67 def raiseRuntimeExceptionOneway(self
, Message
, Context
):
68 raise RuntimeException( Message
, Context
)
70 def setValues( self
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
,\
71 nULong
, nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, \
72 aString
, xInterface
, aAny
, aSequence
, aStruct
):
73 self
.__dict
__["data"] = TestDataElements( bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
,
74 nULong
, nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,
76 self
.__dict
__["Struct"] = aStruct
78 def setValues2( self
, bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
,\
79 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, \
80 aString
, xInterface
, aAny
, aSequence
, aStruct
):
81 self
.__dict
__["Struct"] = TestData( cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
,\
82 nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,\
84 self
.__dict
__["Struct"] = aStruct
85 return bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, nULong
, \
86 nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
, aAny
, \
87 (aSequence
[1],aSequence
[0]), aStruct
89 def getValues(self
, a
,b
,c
,d
,e
,f
,g
,h
, i
,j
,k
,l
,m
,n
):
90 v
= self
.__dict
__["data"]
91 return self
.__dict
__["Struct"],v
.Bool
, v
.Char
, v
.Byte
, v
.Short
, v
.UShort
, v
.Long
, \
92 v
.ULong
, v
.Hyper
, v
.UHyper
, v
.Float
, v
.Double
, v
.Enum
, v
.String
, v
.Interface
, \
93 v
.Any
, v
.Sequence
, self
.__dict
__["Struct"]
95 def call( self
, callid
, nWaitMUSEC
):
96 if self
.__dict
__["callid"] >= callid
:
97 self
.__dict
__["sequenceBroken"] = 1
99 self
.__dict
__["callid"] = callid
101 def callOneway( self
, nCallId
, nWaitMUSEC
):
102 call( nCallId
, nWaitMUSEC
)
104 def sequenceOfCallTestPassed():
105 return self
.__dict
__["sequenceBroken"]
107 def startRecursiveCall( xCall
, nToCall
):
109 xCall
.callRecursivly( MyRecursiveCall(), nToCall
-1 )
111 def checkExistence( self
, name
):
118 raise UnknownPropertyException( "Property "+name
+" is unknown", self
)
120 def __setattr__( self
, name
, value
):
121 checkExistence( name
)
122 self
.__dict
__[name
] = value
124 def __getattr__( self
, name
):
125 checkExistence( name
)
126 return self
.__dict
__[name
]
128 def getSupportedServices( self
):
129 return g_ImplementationHelper
.getSupportedServices(g_implName
)
130 def supportsService( self
, ServiceName
):
131 return g_ImplementationHelper
.supportsService( g_implName
, ServiceName
)
132 def getImplementationName(self
):
136 g_ImplementationHelper
.addImplementation( \
137 SampleUnoComponent
,g_implName
,("com.sun.star.test.bridge.PythonTestObject",),)
139 #g_ImplementationEntries = \
140 # unohelper.ImplementationEntry( \
141 # "org.openoffice.comp.SamplePythonComponent", \
142 # ("com.sun.star.test.bridge.PythonTestObject",), \
143 # SampleUnoComponent) \