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