Kaydet (Commit) 014fbd61 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Improve CppunitTest_services

Change-Id: I4b22ce7e5fa91d5008f72e1f351d25063065ba43
üst a94390d2
...@@ -435,6 +435,7 @@ certain functionality. ...@@ -435,6 +435,7 @@ certain functionality.
@li @c helpcompiler @li @c helpcompiler
@li @c linguistic @li @c linguistic
@li @c oox @li @c oox
@li @c postprocess.cppunit
@li @c reportdesign @li @c reportdesign
@li @c rsc @li @c rsc
@li @c sax @li @c sax
......
...@@ -29,7 +29,17 @@ $(eval $(call gb_CppunitTest_use_sdk_api,services)) ...@@ -29,7 +29,17 @@ $(eval $(call gb_CppunitTest_use_sdk_api,services))
$(eval $(call gb_CppunitTest_use_ure,services)) $(eval $(call gb_CppunitTest_use_ure,services))
$(eval $(call gb_CppunitTest_use_rdb,services,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)) $(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: # vim: set noet sw=4 ts=4:
...@@ -23,9 +23,6 @@ namespace { ...@@ -23,9 +23,6 @@ namespace {
class ServicesTest: public test::BootstrapFixture class ServicesTest: public test::BootstrapFixture
{ {
public: public:
virtual void setUp();
virtual void tearDown();
void test(); void test();
CPPUNIT_TEST_SUITE(ServicesTest); CPPUNIT_TEST_SUITE(ServicesTest);
...@@ -33,58 +30,46 @@ public: ...@@ -33,58 +30,46 @@ public:
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
void ServicesTest::setUp()
{
test::BootstrapFixture::setUp();
}
void ServicesTest::tearDown()
{
test::BootstrapFixture::tearDown();
}
void ServicesTest::test() void ServicesTest::test()
{ {
Reference< XHierarchicalNameAccess > xTypeManager( Reference< XHierarchicalNameAccess > xTypeManager(
m_xContext->getValueByName( m_xContext->getValueByName(
"/singletons/com.sun.star.reflection.theTypeDescriptionManager"), "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
UNO_QUERY_THROW ); UNO_QUERY_THROW );
Sequence<OUString> seq = m_xContext->getServiceManager()->getAvailableServiceNames(); Sequence<OUString> s = m_xContext->getServiceManager()->getAvailableServiceNames();
OUString *s = seq.getArray(); for (sal_Int32 i = 0; i < s.getLength(); i++)
for (sal_Int32 i = 0; i < seq.getLength(); i++)
{ {
if (!xTypeManager->hasByHierarchicalName(s[i])) if (!xTypeManager->hasByHierarchicalName(s[i]))
{ {
SAL_WARN(
"postprocess.cppunit",
"fantasy service name \"" << s[i] << "\"");
continue; continue;
} }
Reference< XServiceTypeDescription2 > xDesc( Reference< XServiceTypeDescription2 > xDesc(
xTypeManager->getByHierarchicalName(s[i]), UNO_QUERY); xTypeManager->getByHierarchicalName(s[i]), UNO_QUERY_THROW);
if (!xDesc.is())
{
// Does happen for singletons?
continue;
}
Sequence< Reference< XServiceConstructorDescription > > xseq = xDesc->getConstructors(); Sequence< Reference< XServiceConstructorDescription > > xseq = xDesc->getConstructors();
bool bHasDefault = false;
for (sal_Int32 c = 0; c < xseq.getLength(); c++) for (sal_Int32 c = 0; c < xseq.getLength(); c++)
if (xseq[c]->isDefaultConstructor()) if (!xseq[c]->getParameters().hasElements())
bHasDefault = true; try
{
try CPPUNIT_ASSERT_MESSAGE(
{ OUStringToOString(s[i], RTL_TEXTENCODING_UTF8).getStr(),
if (bHasDefault ((xseq[c]->isDefaultConstructor()
&& s[i] != "com.sun.star.deployment.test.SmoketestCommandEnvironment") ? (m_xContext->getServiceManager()
// TODO: com.sun.star.deployment.test.SmoketestCommandEnvironment throws ->createInstanceWithContext(s[i], m_xContext))
// "Can not activate the factory for org.libreoffice.smoketest.SmoketestCommandEnvironment : (m_xContext->getServiceManager()
// because java.lang.NoClassDefFoundError: com/sun/star/ucb/XCommandEnvironment" ->createInstanceWithArgumentsAndContext(
m_xContext->getServiceManager()->createInstanceWithContext(s[i], m_xContext); s[i], css::uno::Sequence<css::uno::Any>(),
} m_xContext)))
catch(const Exception & e) .is()));
{ }
OString exc = "Exception thrown while creating " + catch(const Exception & e)
OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8); {
CPPUNIT_FAIL(exc.getStr()); OString exc = "Exception thrown while creating " +
} OUStringToOString(s[i] + ": " + e.Message, RTL_TEXTENCODING_UTF8);
CPPUNIT_FAIL(exc.getStr());
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment