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.
@li @c helpcompiler
@li @c linguistic
@li @c oox
@li @c postprocess.cppunit
@li @c reportdesign
@li @c rsc
@li @c sax
......
......@@ -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:
......@@ -23,9 +23,6 @@ namespace {
class ServicesTest: public test::BootstrapFixture
{
public:
virtual void setUp();
virtual void tearDown();
void test();
CPPUNIT_TEST_SUITE(ServicesTest);
......@@ -33,51 +30,39 @@ 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;
if (!xseq[c]->getParameters().hasElements())
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);
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)
{
......
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