Update ooo320-m1
[ooovba.git] / testtools / source / bridgetest / pyuno / importer.py
blobeb4f398eba684c53def609d200696d3a4e3416ce
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: importer.py,v $
11 # $Revision: 1.4 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
31 import unittest
32 import uno
33 import unohelper
35 from com.sun.star.lang import EventObject,IllegalArgumentException,typeOfIllegalArgumentException
36 from test.testtools.bridgetest.TestEnum import TWO
37 from com.sun.star.uno.TypeClass import UNSIGNED_LONG,EXCEPTION
38 class ImporterTestCase(unittest.TestCase):
39 def __init__(self,method,ctx):
40 unittest.TestCase.__init__(self,method)
41 self.ctx = ctx
43 def setUp(self):
44 self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \
45 "com.sun.star.test.bridge.CppTestObject",self.ctx)
47 def testStandard( self ):
48 self.failUnless( IllegalArgumentException != None, "none-test" )
49 self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj)
51 self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" )
52 self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) )
53 self.failUnless( typeOfIllegalArgumentException ==
54 uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) )
56 # should not throw an exception
57 e = EventObject()
58 e.Source = self.ctx
59 e = EventObject( self.ctx )
60 e = EventObject( e )
62 def testDynamicComponentRegistration( self ):
63 ctx = uno.getComponentContext()
64 self.failUnless(
65 not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()),
66 "precondition for dynamic component registration test is not fulfilled" )
67 self.failUnless(
68 not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()),
69 "precondition for dynamic component registration test is not fulfilled" )
70 unohelper.addComponentsToContext(
71 ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" )
72 self.failUnless(
73 ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) )
74 self.failUnless(
75 ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()))
77 def suite( ctx ):
78 suite = unittest.TestSuite()
79 suite.addTest(ImporterTestCase("testStandard",ctx))
80 suite.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx))
81 return suite