From 3ef6cfa566e6d419d58f2659a649ba9c1308cdc5 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 12 Feb 2010 17:36:13 +0100 Subject: sb118: moved test OOo installation stuff to new solenv/inc/installationtest.mk (makefile parts) and new test module (C++ and, new, Java unit test parts); adapted sw/qa/unoapi to new (Java) test framework --- smoketestoo_native/makefile.mk | 71 ++------------- smoketestoo_native/prj/build.lst | 2 +- smoketestoo_native/smoketest.cxx | 180 +++------------------------------------ 3 files changed, 19 insertions(+), 234 deletions(-) (limited to 'smoketestoo_native') diff --git a/smoketestoo_native/makefile.mk b/smoketestoo_native/makefile.mk index bd0bbd8e20d1..0947efe36af4 100644 --- a/smoketestoo_native/makefile.mk +++ b/smoketestoo_native/makefile.mk @@ -40,79 +40,18 @@ SLOFILES = $(SHL1OBJS) SHL1TARGET = smoketest SHL1OBJS = $(SLO)/smoketest.obj SHL1RPATH = NONE -SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB) +SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(CPPUNITLIB) $(SALLIB) $(TESTLIB) SHL1VERSIONMAP = version.map DEF1NAME = $(SHL1TARGET) .INCLUDE: target.mk +.INCLUDE: installationtest.mk -.IF "$(OS)" == "WNT" -my_file = file:/// -.ELSE -my_file = file:// -.END +ALLTAR : cpptest -# The following conditional is an approximation of: UPDATER==YES and -# CWS_WORK_STAMP not set and either SOL_TMP not set or SOLARENV not starting -# with SOL_TMP: -.IF "$(UPDATER)" == "YES" && "$(CWS_WORK_STAMP)" == "" && \ - "$(SOLARENV:s/$(SOL_TMP)//" == "$(SOLARENV)" -my_instsets = $(shell ls -dt \ - $(SHIPDRIVE)/$(INPATH)/OpenOffice/archive/$(WORK_STAMP)_$(UPDMINOR)_native_packed-*_$(defaultlangiso).$(BUILD)) -my_instset = $(my_instsets:1) -.ELSE -my_instset = \ - $(SOLARSRC)/instsetoo_native/$(INPATH)/OpenOffice/archive/install/$(defaultlangiso) -.ENDIF +cpptest : $(SHL1TARGETN) $(BIN)/smoketestdoc.sxw -.IF "$(OS)" == "MACOSX" -my_soffice = $(MISC)/installation/opt/OpenOffice.org.app/Contents/MacOS/soffice -.ELIF "$(OS)" == "WNT" -my_soffice = \ - `cat $(MISC)/installation.flag`'/opt/OpenOffice.org 3/program/soffice.exe' -.ELSE -my_soffice = $(MISC)/installation/opt/openoffice.org3/program/soffice -.END - -ALLTAR: smoketest - -smoketest .PHONY: $(MISC)/installation.flag $(SHL1TARGETN) \ - $(MISC)/services.rdb $(BIN)/smoketestdoc.sxw - $(RM) -r $(MISC)/user - $(MKDIR) $(MISC)/user - $(CPPUNITTESTER) $(SHL1TARGETN) \ - -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/services.rdb \ - -env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/types.rdb \ - -env:arg-path=$(my_soffice) -env:arg-user=$(MISC)/user \ - -env:arg-env=$(OOO_LIBRARY_PATH_VAR)"$${{$(OOO_LIBRARY_PATH_VAR)+=$$$(OOO_LIBRARY_PATH_VAR)}}" \ - -env:arg-doc=$(BIN)/smoketestdoc.sxw -.IF "$(OS)" == "WNT" - $(RM) -r $(MISC)/installation.flag `cat $(MISC)/installation.flag` -.ENDIF - -# Work around Windows problems with long pathnames (see issue 50885) by -# installing into the temp directory instead of the module output tree (in which -# case installation.flag contains the path to the temp installation, which is -# removed after smoketest); can be removed once issue 50885 is fixed: -.IF "$(OS)" == "WNT" -$(MISC)/installation.flag: $(shell ls $(my_instset)/OOo_*_install.zip) - my_tmp=$$(cygpath -m $$(mktemp -dt ooosmoke.XXXXXX)) && \ - unzip $(my_instset)/OOo_*_install.zip -d "$$my_tmp" && \ - mv "$$my_tmp"/OOo_*_install "$$my_tmp"/opt && \ - echo "$$my_tmp" > $@ -.ELSE -$(MISC)/installation.flag: $(shell ls $(my_instset)/OOo_*_install.tar.gz) - $(RM) -r $(MISC)/installation - $(MKDIR) $(MISC)/installation - cd $(MISC)/installation && $(GNUTAR) xfz $(my_instset)/OOo_*_install.tar.gz - $(MV) $(MISC)/installation/OOo_*_install $(MISC)/installation/opt - $(TOUCH) $@ -.END - -$(MISC)/services.rdb: - $(RM) $@ - $(REGCOMP) -register -r $@ -wop -c bridgefac.uno -c connector.uno \ - -c remotebridge.uno -c uuresolver.uno +OOO_CPPTEST_ARGS = $(SHL1TARGETN) -env:arg-doc=$(BIN)/smoketestdoc.sxw $(BIN)/smoketestdoc.sxw: data/smoketestdoc.sxw $(COPY) $< $@ diff --git a/smoketestoo_native/prj/build.lst b/smoketestoo_native/prj/build.lst index 5a0b659bd6d1..f4bd5368c65b 100644 --- a/smoketestoo_native/prj/build.lst +++ b/smoketestoo_native/prj/build.lst @@ -1,4 +1,4 @@ -smtoon smoketestoo_native :: instsetoo_native NULL +smtoon smoketestoo_native :: instsetoo_native test NULL smtoon smoketestoo_native usr1 - all smoketestoonative_mkout NULL smtoon smoketestoo_native\com\sun\star\comp\smoketest nmake - all smoketestoonative_csscs NULL smtoon smoketestoo_native nmake - all,test10 smoketestoonative_mk smoketestoonative_csscs NULL diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx index 4536dd9f9ea9..6eb57a9dc648 100644 --- a/smoketestoo_native/smoketest.cxx +++ b/smoketestoo_native/smoketest.cxx @@ -29,33 +29,23 @@ #include "sal/config.h" -#include - #include "boost/noncopyable.hpp" #include "com/sun/star/beans/PropertyState.hpp" #include "com/sun/star/beans/PropertyValue.hpp" -#include "com/sun/star/bridge/UnoUrlResolver.hpp" -#include "com/sun/star/bridge/XUnoUrlResolver.hpp" -#include "com/sun/star/connection/NoConnectException.hpp" #include "com/sun/star/document/MacroExecMode.hpp" #include "com/sun/star/frame/DispatchResultEvent.hpp" #include "com/sun/star/frame/DispatchResultState.hpp" #include "com/sun/star/frame/XComponentLoader.hpp" #include "com/sun/star/frame/XController.hpp" -#include "com/sun/star/frame/XDesktop.hpp" #include "com/sun/star/frame/XDispatchProvider.hpp" #include "com/sun/star/frame/XDispatchResultListener.hpp" #include "com/sun/star/frame/XModel.hpp" #include "com/sun/star/frame/XNotifyingDispatch.hpp" -#include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/lang/EventObject.hpp" -#include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" -#include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/util/URL.hpp" -#include "cppuhelper/bootstrap.hxx" #include "cppuhelper/implbase1.hxx" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" @@ -63,61 +53,17 @@ #include "cppunit/plugin/TestPlugIn.h" #include "osl/conditn.hxx" #include "osl/diagnose.h" -#include "osl/file.hxx" -#include "osl/process.h" -#include "osl/thread.h" -#include "osl/time.h" -#include "rtl/bootstrap.hxx" -#include "rtl/string.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" -#include "sal/main.h" -#include "sal/types.h" +#include "test/getargument.hxx" +#include "test/officeconnection.hxx" +#include "test/oustringostreaminserter.hxx" +#include "test/toabsolutefileurl.hxx" namespace { namespace css = com::sun::star; -template< typename charT, typename traits > std::basic_ostream & -operator <<( - std::basic_ostream & stream, rtl::OUString const & string) -{ - return stream << - rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr(); - // best effort; potentially loses data due to conversion failures and - // embedded null characters -} - -rtl::OUString argumentName(rtl::OUString const & name) { - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name; -} - -rtl::OUString getArgument(rtl::OUString const & name) { - rtl::OUString val; - CPPUNIT_ASSERT(rtl::Bootstrap::get(argumentName(name), val)); - return val; -} - -bool getOptionalArgument(rtl::OUString const & name, rtl::OUString * value) { - OSL_ASSERT(value != 0); - return rtl::Bootstrap::get(argumentName(name), *value); -} - -rtl::OUString toUrl(rtl::OUString const & pathname) { - rtl::OUString cwd; - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_None, osl_getProcessWorkingDir(&cwd.pData)); - rtl::OUString url; - CPPUNIT_ASSERT_EQUAL( - osl::FileBase::E_None, - osl::FileBase::getFileURLFromSystemPath(pathname, url)); - rtl::OUString absUrl; - CPPUNIT_ASSERT_EQUAL( - osl::FileBase::E_None, - osl::FileBase::getAbsoluteFileURL(cwd, url, absUrl)); - return absUrl; -} - struct Result: private boost::noncopyable { osl::Condition condition; bool success; @@ -152,8 +98,6 @@ void Listener::dispatchFinished(css::frame::DispatchResultEvent const & Result) class Test: public CppUnit::TestFixture { public: - Test(): process_(0) {} - virtual void setUp(); virtual void tearDown(); @@ -165,117 +109,22 @@ private: void test(); - oslProcess process_; - css::uno::Reference< css::lang::XMultiServiceFactory > factory_; + test::OfficeConnection connection_; }; void Test::setUp() { - oslProcessInfo info; - info.Size = sizeof info; - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_None, - osl_getProcessInfo(0, osl_Process_IDENTIFIER, &info)); - rtl::OUString desc( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("pipe,name=oootest")) + - rtl::OUString::valueOf(static_cast< sal_Int64 >(info.Ident)) + - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";urp"))); - rtl::OUString noquickArg( - RTL_CONSTASCII_USTRINGPARAM("-quickstart=no")); - rtl::OUString nofirstArg( - RTL_CONSTASCII_USTRINGPARAM("-nofirststartwizard")); - rtl::OUString acceptArg( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-accept=")) + desc); - rtl::OUString userArg( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-env:UserInstallation=")) + - toUrl(getArgument(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"))))); - rtl::OUString jreArg( - RTL_CONSTASCII_USTRINGPARAM("-env:UNO_JAVA_JFW_ENV_JREHOME=true")); - rtl::OUString classpathArg( - RTL_CONSTASCII_USTRINGPARAM("-env:UNO_JAVA_JFW_ENV_CLASSPATH=true")); - rtl_uString * args[] = { - noquickArg.pData, nofirstArg.pData, acceptArg.pData, userArg.pData, - jreArg.pData, classpathArg.pData }; - rtl_uString ** envs = 0; - rtl::OUString argEnv; - if (getOptionalArgument( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")), &argEnv)) - { - envs = &argEnv.pData; - } - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_None, - osl_executeProcess( - (toUrl( - getArgument( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("path")))). - pData), - args, sizeof args / sizeof args[0], 0, 0, 0, envs, - envs == 0 ? 0 : 1, &process_)); - try { - css::uno::Reference< css::uno::XComponentContext > context( - cppu::defaultBootstrap_InitialComponentContext()); - css::uno::Reference< css::bridge::XUnoUrlResolver > resolver( - css::bridge::UnoUrlResolver::create(context)); - for (int i = 0;; ++i) { - try { - factory_ = - css::uno::Reference< css::lang::XMultiServiceFactory >( - resolver->resolve( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:")) + - desc + - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - ";StarOffice.ServiceManager"))), - css::uno::UNO_QUERY_THROW); - break; - } catch (css::connection::NoConnectException &) { - if (i == 600) { // 600 sec - throw; - } - } - TimeValue delay = { 1, 0 }; // 1 sec - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_TimedOut, - osl_joinProcessWithTimeout(process_, &delay)); - } - } catch (...) { - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_None, osl_terminateProcess(process_)); - osl_freeProcessHandle(process_); - process_ = 0; - throw; - } + connection_.setUp(); } void Test::tearDown() { - if (factory_.is()) { - css::uno::Reference< css::frame::XDesktop > desktop( - factory_->createInstance( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))), - css::uno::UNO_QUERY_THROW); - factory_.clear(); - try { - CPPUNIT_ASSERT(desktop->terminate()); - desktop.clear(); - } catch (css::lang::DisposedException &) {} - // it appears that DisposedExceptions can already happen while - // receiving the response of the terminate call - } - if (process_ != 0) { - CPPUNIT_ASSERT_EQUAL(osl_Process_E_None, osl_joinProcess(process_)); - oslProcessInfo info; - info.Size = sizeof info; - CPPUNIT_ASSERT_EQUAL( - osl_Process_E_None, - osl_getProcessInfo(process_, osl_Process_EXITCODE, &info)); - CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code); - osl_freeProcessHandle(process_); - } + connection_.tearDown(); } void Test::test() { + rtl::OUString doc; + CPPUNIT_ASSERT( + test::getArgument( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("doc")), &doc)); css::uno::Sequence< css::beans::PropertyValue > args(1); args[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode")); @@ -294,15 +143,12 @@ void Test::test() { css::uno::Reference< css::frame::XController >( css::uno::Reference< css::frame::XModel >( css::uno::Reference< css::frame::XComponentLoader >( - factory_->createInstance( + connection_.getFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop"))), css::uno::UNO_QUERY_THROW)->loadComponentFromURL( - toUrl( - getArgument( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("doc")))), + test::toAbsoluteFileUrl(doc), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_default")), 0, args), -- cgit v1.2.3