1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21import unittest 22import uno 23import unohelper 24 25from com.sun.star.lang import EventObject,IllegalArgumentException,typeOfIllegalArgumentException 26from test.testtools.bridgetest.TestEnum import TWO 27from com.sun.star.uno.TypeClass import UNSIGNED_LONG,EXCEPTION 28class ImporterTestCase(unittest.TestCase): 29 def __init__(self,method,ctx): 30 unittest.TestCase.__init__(self,method) 31 self.ctx = ctx 32 33 def setUp(self): 34 self.tobj = self.ctx.ServiceManager.createInstanceWithContext( \ 35 "com.sun.star.test.bridge.CppTestObject",self.ctx) 36 37 def testStandard( self ): 38 self.failUnless( IllegalArgumentException != None, "none-test" ) 39 self.failUnlessRaises( IllegalArgumentException, self.tobj.raiseException, 1,"foo",self.tobj) 40 41 self.failUnless( TWO == uno.Enum( "test.testtools.bridgetest.TestEnum","TWO"), "enum" ) 42 self.failUnless( UNSIGNED_LONG == uno.Enum( "com.sun.star.uno.TypeClass", "UNSIGNED_LONG" ) ) 43 self.failUnless( typeOfIllegalArgumentException == 44 uno.Type( "com.sun.star.lang.IllegalArgumentException", EXCEPTION) ) 45 46 # should not throw an exception 47 e = EventObject() 48 e.Source = self.ctx 49 e = EventObject( self.ctx ) 50 e = EventObject( e ) 51 52 def testDynamicComponentRegistration( self ): 53 ctx = uno.getComponentContext() 54 self.failUnless( 55 not ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()), 56 "precondition for dynamic component registration test is not fulfilled" ) 57 self.failUnless( 58 not ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames()), 59 "precondition for dynamic component registration test is not fulfilled" ) 60 unohelper.addComponentsToContext( 61 ctx , ctx, ("acceptor.uno","connector.uno"), "com.sun.star.loader.SharedLibrary" ) 62 self.failUnless( 63 ("com.sun.star.connection.Acceptor" in ctx.ServiceManager.getAvailableServiceNames()) ) 64 self.failUnless( 65 ("com.sun.star.connection.Connector" in ctx.ServiceManager.getAvailableServiceNames())) 66 67def suite( ctx ): 68 suite = unittest.TestSuite() 69 suite.addTest(ImporterTestCase("testStandard",ctx)) 70 suite.addTest(ImporterTestCase("testDynamicComponentRegistration",ctx)) 71 return suite 72 73