diff options
author | sb <sb@openoffice.org> | 2010-05-14 16:22:06 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-05-14 16:22:06 +0200 |
commit | af5cef5b1e2f3d76f52340bbd2ea8bd93cb5185d (patch) | |
tree | c39196dc04450640a0edadcee3b96917251bb63d /test | |
parent | sb123: #i111598# OfficeConnection getFactory -> getComponentContext (diff) | |
download | core-af5cef5b1e2f3d76f52340bbd2ea8bd93cb5185d.tar.gz core-af5cef5b1e2f3d76f52340bbd2ea8bd93cb5185d.zip |
sb123: #i111601# various additional test helper functionality
Diffstat (limited to 'test')
-rw-r--r-- | test/inc/test/gettestargument.hxx | 46 | ||||
-rw-r--r-- | test/prj/d.lst | 2 | ||||
-rw-r--r-- | test/source/cpp/getargument.cxx | 7 | ||||
-rw-r--r-- | test/source/cpp/getargument.hxx (renamed from test/inc/test/getargument.hxx) | 14 | ||||
-rw-r--r-- | test/source/cpp/gettestargument.cxx | 43 | ||||
-rw-r--r-- | test/source/cpp/makefile.mk | 1 | ||||
-rw-r--r-- | test/source/cpp/officeconnection.cxx | 9 | ||||
-rw-r--r-- | test/source/java/Argument.java | 36 | ||||
-rw-r--r-- | test/source/java/OfficeConnection.java | 10 | ||||
-rw-r--r-- | test/source/java/OfficeFileUrl.java | 42 | ||||
-rw-r--r-- | test/source/java/TestArgument.java | 39 | ||||
-rw-r--r-- | test/source/java/makefile.mk | 6 |
12 files changed, 234 insertions, 21 deletions
diff --git a/test/inc/test/gettestargument.hxx b/test/inc/test/gettestargument.hxx new file mode 100644 index 000000000000..21b9df7a097e --- /dev/null +++ b/test/inc/test/gettestargument.hxx @@ -0,0 +1,46 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_TEST_GETTESTARGUMENT_HXX +#define INCLUDED_TEST_GETTESTARGUMENT_HXX + +#include "sal/config.h" + +#include "test/detail/testdllapi.hxx" + +namespace rtl { class OUString; } + +namespace test { + +// Obtain the value of a test argument (tunneled in via an "arg-testarg.<name>" +// bootstrap variable): +OOO_DLLPUBLIC_TEST bool getTestArgument( + rtl::OUString const & name, rtl::OUString * value); + +} + +#endif diff --git a/test/prj/d.lst b/test/prj/d.lst index bcea8bee46fe..34218f54e974 100644 --- a/test/prj/d.lst +++ b/test/prj/d.lst @@ -5,7 +5,7 @@ mkdir: %_DEST%\inc%_EXT%\test\detail ..\%__SRC%\lib\libtest.dylib %_DEST%\lib%_EXT%\libtest.dylib ..\%__SRC%\lib\libtest.so %_DEST%\lib%_EXT%\libtest.so ..\inc\test\detail\testdllapi.hxx %_DEST%\inc%_EXT%\test\detail\testdllapi.hxx -..\inc\test\getargument.hxx %_DEST%\inc%_EXT%\test\getargument.hxx +..\inc\test\gettestargument.hxx %_DEST%\inc%_EXT%\test\gettestargument.hxx ..\inc\test\officeconnection.hxx %_DEST%\inc%_EXT%\test\officeconnection.hxx ..\inc\test\oustringostreaminserter.hxx %_DEST%\inc%_EXT%\test\oustringostreaminserter.hxx ..\inc\test\toabsolutefileurl.hxx %_DEST%\inc%_EXT%\test\toabsolutefileurl.hxx diff --git a/test/source/cpp/getargument.cxx b/test/source/cpp/getargument.cxx index 339c5c9c797d..0db144679d92 100644 --- a/test/source/cpp/getargument.cxx +++ b/test/source/cpp/getargument.cxx @@ -29,10 +29,13 @@ #include "rtl/bootstrap.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" -#include "test/getargument.hxx" + +#include "getargument.hxx" namespace test { +namespace detail { + bool getArgument(rtl::OUString const & name, rtl::OUString * value) { OSL_ASSERT(value != 0); return rtl::Bootstrap::get( @@ -40,3 +43,5 @@ bool getArgument(rtl::OUString const & name, rtl::OUString * value) { } } + +} diff --git a/test/inc/test/getargument.hxx b/test/source/cpp/getargument.hxx index 1b4df29d2115..4ba7e0f47827 100644 --- a/test/inc/test/getargument.hxx +++ b/test/source/cpp/getargument.hxx @@ -23,22 +23,22 @@ * for a copy of the LGPLv3 License. ************************************************************************/ -#ifndef INCLUDED_TEST_GETARGUMENT_HXX -#define INCLUDED_TEST_GETARGUMENT_HXX +#ifndef INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX +#define INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX #include "sal/config.h" -#include "test/detail/testdllapi.hxx" - -namespace rtl { class OUString; } - namespace test { +namespace detail { + // Obtain the value of an argument tunneled in via an "arg-<name>" bootstrap // variable: -OOO_DLLPUBLIC_TEST bool getArgument( +bool getArgument( rtl::OUString const & name, rtl::OUString * value); } +} + #endif diff --git a/test/source/cpp/gettestargument.cxx b/test/source/cpp/gettestargument.cxx new file mode 100644 index 000000000000..757faa751d37 --- /dev/null +++ b/test/source/cpp/gettestargument.cxx @@ -0,0 +1,43 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "test/gettestargument.hxx" + +#include "getargument.hxx" + +namespace test { + +bool getTestArgument(rtl::OUString const & name, rtl::OUString * value) { + return detail::getArgument( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("testarg.")) + name, value); +} + +} diff --git a/test/source/cpp/makefile.mk b/test/source/cpp/makefile.mk index 8494bd4aaa05..1c2d5a8ca2ff 100644 --- a/test/source/cpp/makefile.mk +++ b/test/source/cpp/makefile.mk @@ -37,6 +37,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS) SLOFILES = \ $(SLO)/getargument.obj \ + $(SLO)/gettestargument.obj \ $(SLO)/officeconnection.obj \ $(SLO)/toabsolutefileurl.obj diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx index c8c42873c4a8..5ea493f0bd0d 100644 --- a/test/source/cpp/officeconnection.cxx +++ b/test/source/cpp/officeconnection.cxx @@ -37,10 +37,11 @@ #include "osl/process.h" #include "osl/time.h" #include "sal/types.h" -#include "test/getargument.hxx" #include "test/officeconnection.hxx" #include "test/toabsolutefileurl.hxx" +#include "getargument.hxx" + namespace { namespace css = com::sun::star; @@ -57,7 +58,7 @@ void OfficeConnection::setUp() { rtl::OUString desc; rtl::OUString argSoffice; CPPUNIT_ASSERT( - getArgument( + detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")), &argSoffice)); if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("path:"))) { @@ -78,7 +79,7 @@ void OfficeConnection::setUp() { rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";urp"))); rtl::OUString argUser; CPPUNIT_ASSERT( - getArgument( + detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), &argUser)); rtl::OUString userArg( rtl::OUString( @@ -94,7 +95,7 @@ void OfficeConnection::setUp() { acceptArg.pData, userArg.pData, jreArg.pData, classpathArg.pData }; rtl_uString ** envs = 0; rtl::OUString argEnv; - if (getArgument( + if (detail::getArgument( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")), &argEnv)) { envs = &argEnv.pData; diff --git a/test/source/java/Argument.java b/test/source/java/Argument.java new file mode 100644 index 000000000000..4e2a781531a8 --- /dev/null +++ b/test/source/java/Argument.java @@ -0,0 +1,36 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package org.openoffice.test; + +final class Argument { + public static String get(String name) { + return System.getProperty("org.openoffice.test.arg." + name); + } + + private Argument() {} +} diff --git a/test/source/java/OfficeConnection.java b/test/source/java/OfficeConnection.java index b0b08c1643fd..fc6e78f5f108 100644 --- a/test/source/java/OfficeConnection.java +++ b/test/source/java/OfficeConnection.java @@ -49,17 +49,17 @@ public final class OfficeConnection { /** Start up an OOo instance. */ public void setUp() throws Exception { - String sofficeArg = getArgument("soffice"); + String sofficeArg = Argument.get("soffice"); if (sofficeArg.startsWith("path:")) { description = "pipe,name=oootest" + UUID.randomUUID(); ProcessBuilder pb = new ProcessBuilder( sofficeArg.substring("path:".length()), "-quickstart=no", "-nofirststartwizard", "-norestore", "-accept=" + description + ";urp", - "-env:UserInstallation=" + getArgument("user"), + "-env:UserInstallation=" + Argument.get("user"), "-env:UNO_JAVA_JFW_ENV_JREHOME=true", "-env:UNO_JAVA_JFW_ENV_CLASSPATH=true"); - String envArg = getArgument("env"); + String envArg = Argument.get("env"); if (envArg != null) { Map<String, String> env = pb.environment(); int i = envArg.indexOf("="); @@ -142,10 +142,6 @@ public final class OfficeConnection { return description; } - private static String getArgument(String name) { - return System.getProperty("org.openoffice.test.arg." + name); - } - private static Integer waitForProcess(Process process, final long millis) throws InterruptedException { diff --git a/test/source/java/OfficeFileUrl.java b/test/source/java/OfficeFileUrl.java new file mode 100644 index 000000000000..1ab62e283e6a --- /dev/null +++ b/test/source/java/OfficeFileUrl.java @@ -0,0 +1,42 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package org.openoffice.test; + +import java.io.File; + +/** Obtain the office-internal absolute file URL of a given file. + */ +public final class OfficeFileUrl { + public static String getAbsolute(File file) { + return file.getAbsoluteFile().toURI().toString().replaceFirst( + "\\A[Ff][Ii][Ll][Ee]:/(?=[^/]|\\z)", "file:///"); + // file:/path -> file:///path + } + + private OfficeFileUrl() {} +} diff --git a/test/source/java/TestArgument.java b/test/source/java/TestArgument.java new file mode 100644 index 000000000000..1303d09e1ba2 --- /dev/null +++ b/test/source/java/TestArgument.java @@ -0,0 +1,39 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package org.openoffice.test; + +/** Obtain the value of a test argument (tunneled in via an + "org.openoffice.test.arg.testarg.<name>" system property). + */ +public final class TestArgument { + public static String get(String name) { + return Argument.get("testarg." + name); + } + + private TestArgument() {} +} diff --git a/test/source/java/makefile.mk b/test/source/java/makefile.mk index a541d532f158..86506f11cc0f 100644 --- a/test/source/java/makefile.mk +++ b/test/source/java/makefile.mk @@ -30,7 +30,11 @@ TARGET = java .IF "$(OOO_JUNIT_JAR)" != "" PACKAGE = org/openoffice/test -JAVAFILES = OfficeConnection.java +JAVAFILES = \ + Argument.java \ + OfficeConnection.java \ + OfficeFileUrl.java \ + TestArgument.java JARFILES = juh.jar ridl.jar unoil.jar EXTRAJARFILES = $(OOO_JUNIT_JAR) |