bump product version to 5.0.4.1
[LibreOffice.git] / testtools / source / bridgetest / pyuno / samplecomponent.py
blob736af9bee858c611e8ce2963689ba8c31cb6860b
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 .
18 import uno
19 import unohelper
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 ):
35 rData.Bool = bBool;
36 rData.Char = cChar;
37 rData.Byte = nByte;
38 rData.Short = nShort;
39 rData.UShort = nUShort;
40 rData.Long = nLong;
41 rData.ULong = nULong;
42 rData.Hyper = nHyper;
43 rData.UHyper = nUHyper;
44 rData.Float = fFloat;
45 rData.Double = fDouble;
46 rData.Enum = eEnum;
47 rData.String = rStr;
48 rData.Interface = xTest;
49 rData.Any = rAny;
51 class MyRecursiveCall( XRecursiveCall, unohelper.Base ):
52 def callRecursivly( xCall, nToCall ):
53 if 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 ):
62 return 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,
75 aAny, aSequence )
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,\
83 aAny, aSequence )
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
98 else:
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 ):
108 if nToCall:
109 xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
111 def checkExistence( self, name ):
112 found = 0
113 for x in g_attribs:
114 if x == name:
115 found = 1
116 break
117 if not found:
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):
133 return g_implName
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) \