diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-12-19 22:46:34 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-12-19 22:46:34 +0100 |
commit | 014fbd610e80c7b89e1f1d280d09d934ab4f3007 (patch) | |
tree | bffc16dd2a380c2e8ffe2bfa47241b9a2ceefbd0 /postprocess | |
parent | a94390d20c50125e25e29431ca15ca2ca6683d17 (diff) |
Improve CppunitTest_services
Change-Id: I4b22ce7e5fa91d5008f72e1f351d25063065ba43
Diffstat (limited to 'postprocess')
-rw-r--r-- | postprocess/CppunitTest_services.mk | 10 | ||||
-rw-r--r-- | postprocess/qa/services.cxx | 67 |
2 files changed, 36 insertions, 41 deletions
diff --git a/postprocess/CppunitTest_services.mk b/postprocess/CppunitTest_services.mk index c80f2513692b..5a8a65dbe298 100644 --- a/postprocess/CppunitTest_services.mk +++ b/postprocess/CppunitTest_services.mk @@ -29,7 +29,17 @@ $(eval $(call gb_CppunitTest_use_sdk_api,services)) $(eval $(call gb_CppunitTest_use_ure,services)) $(eval $(call gb_CppunitTest_use_rdb,services,services)) +ifneq ($(DISABLE_PYTHON),TRUE) +$(eval $(call gb_CppunitTest_use_rdb,services,pyuno)) +endif $(eval $(call gb_CppunitTest_use_configuration,services)) +ifeq ($(ENABLE_JAVA),TRUE) +$(call gb_CppunitTest_get_target,services): $(call gb_Jar_get_target,unoil) +$(eval $(call gb_CppunitTest_add_arguments,services, \ + -env:URE_MORE_JAVA_TYPES=$(call gb_Helper_make_url,$(call gb_Jar_get_target,unoil)) \ +)) +endif + # vim: set noet sw=4 ts=4: diff --git a/postprocess/qa/services.cxx b/postprocess/qa/services.cxx index ea21ab5f7989..bc901f7e9ee1 100644 --- a/postprocess/qa/services.cxx +++ b/postprocess/qa/services.cxx @@ -23,9 +23,6 @@ namespace { class ServicesTest: public test::BootstrapFixture { public: - virtual void setUp(); - virtual void tearDown(); - void test(); CPPUNIT_TEST_SUITE(ServicesTest); @@ -33,58 +30,46 @@ public: CPPUNIT_TEST_SUITE_END(); }; -void ServicesTest::setUp() -{ - test::BootstrapFixture::setUp(); -} - -void ServicesTest::tearDown() -{ - test::BootstrapFixture::tearDown(); -} - void ServicesTest::test() { Reference< XHierarchicalNameAccess > xTypeManager( m_xContext->getValueByName( "/singletons/com.sun.star.reflection.theTypeDescriptionManager"), UNO_QUERY_THROW ); - Sequence<OUString> seq = m_xContext->getServiceManager()->getAvailableServiceNames(); - OUString *s = seq.getArray(); - for (sal_Int32 i = 0; i < seq.getLength(); i++) + Sequence<OUString> s = m_xContext->getServiceManager()->getAvailableServiceNames(); + for (sal_Int32 i = 0; i < s.getLength(); i++) { if (!xTypeManager->hasByHierarchicalName(s[i])) { + SAL_WARN( + "postprocess.cppunit", + "fantasy service name \"" << s[i] << "\""); continue; } Reference< XServiceTypeDescription2 > xDesc( - xTypeManager->getByHierarchicalName(s[i]), UNO_QUERY); - if (!xDesc.is()) - { - // Does happen for singletons? - continue; - } + xTypeManager->getByHierarchicalName(s[i]), UNO_QUERY_THROW); Sequence< Reference< XServiceConstructorDescription > > xseq = xDesc->getConstructors(); - bool bHasDefault = false; for (sal_Int32 c = 0; c < xseq.getLength(); c++) - if (xseq[c]->isDefaultConstructor()) - bHasDefault = true; - - try - { - if (bHasDefault - && s[i] != "com.sun.star.deployment.test.SmoketestCommandEnvironment") - // TODO: com.sun.star.deployment.test.SmoketestCommandEnvironment throws - // "Can not activate the factory for org.libreoffice.smoketest.SmoketestCommandEnvironment - // because java.lang.NoClassDefFoundError: com/sun/star/ucb/XCommandEnvironment" - m_xContext->getServiceManager()->createInstanceWithContext(s[i], m_xContext); - } - catch(const Exception & e) - { - OString exc = "Exception thrown while creating " + - OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8); - CPPUNIT_FAIL(exc.getStr()); - } + if (!xseq[c]->getParameters().hasElements()) + try + { + CPPUNIT_ASSERT_MESSAGE( + OUStringToOString(s[i], RTL_TEXTENCODING_UTF8).getStr(), + ((xseq[c]->isDefaultConstructor() + ? (m_xContext->getServiceManager() + ->createInstanceWithContext(s[i], m_xContext)) + : (m_xContext->getServiceManager() + ->createInstanceWithArgumentsAndContext( + s[i], css::uno::Sequence<css::uno::Any>(), + m_xContext))) + .is())); + } + catch(const Exception & e) + { + OString exc = "Exception thrown while creating " + + OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8); + CPPUNIT_FAIL(exc.getStr()); + } } } |