1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2010 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 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. 14# 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). 20# 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. 25# 26#************************************************************************* 27import unittest 28import uno 29import unohelper 30 31from com.sun.star.lang import EventObject,IllegalArgumentException,typeOfIllegalArgumentException 32from test.testtools.bridgetest.TestEnum import TWO 33from com.sun.star.uno.TypeClass import UNSIGNED_LONG,EXCEPTION 34class ImporterTestCase(unittest.TestCase): 35 def __init__(self,method,ctx): 36 unittest.TestCase.__init__(self,method) 37 self.ctx = ctx 38 39 def setUp(self): 40 self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \ 41 "com.sun.star.test.bridge.CppTestObject",self.ctx) 42 43 def testStandard( self ): 44 self.failUnless( IllegalArgumentException != None, "none-test" ) 45 self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj) 46 47 self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" ) 48 self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) ) 49 self.failUnless( typeOfIllegalArgumentException == 50 uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) ) 51 52 # should not throw an exception 53 e = EventObject() 54 e.Source = self.ctx 55 e = EventObject( self.ctx ) 56 e = EventObject( e ) 57 58 def testDynamicComponentRegistration( self ): 59 ctx = uno.getComponentContext() 60 self.failUnless( 61 not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()), 62 "precondition for dynamic component registration test is not fulfilled" ) 63 self.failUnless( 64 not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()), 65 "precondition for dynamic component registration test is not fulfilled" ) 66 unohelper.addComponentsToContext( 67 ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" ) 68 self.failUnless( 69 ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) ) 70 self.failUnless( 71 ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames())) 72 73def suite( ctx ): 74 suite = unittest.TestSuite() 75 suite.addTest(ImporterTestCase("testStandard",ctx)) 76 suite.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx)) 77 return suite 78 79