Kaydet (Commit) af5cef5b authored tarafından sb's avatar sb

sb123: #i111601# various additional test helper functionality

üst 88d1e25d
......@@ -49,7 +49,8 @@ ALLTAR : cpptest
cpptest : $(SHL1TARGETN) $(BIN)/smoketestdoc.sxw
OOO_CPPTEST_ARGS = $(SHL1TARGETN) -env:arg-doc=$(BIN)/smoketestdoc.sxw
TEST_ARGUMENTS = smoketest.doc=$(BIN)/smoketestdoc.sxw
CPPTEST_LIBRARY = $(SHL1TARGETN)
$(BIN)/smoketestdoc.sxw: data/smoketestdoc.sxw
$(COPY) $< $@
......
......@@ -53,7 +53,7 @@
#include "osl/diagnose.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "test/getargument.hxx"
#include "test/gettestargument.hxx"
#include "test/officeconnection.hxx"
#include "test/oustringostreaminserter.hxx"
#include "test/toabsolutefileurl.hxx"
......@@ -121,8 +121,8 @@ void Test::tearDown() {
void Test::test() {
rtl::OUString doc;
CPPUNIT_ASSERT(
test::getArgument(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("doc")), &doc));
test::getTestArgument(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smoketest.doc")), &doc));
css::uno::Sequence< css::beans::PropertyValue > args(1);
args[0].Name = rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
......
/*************************************************************************
*
* 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
......@@ -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
......
......@@ -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) {
}
}
}
......@@ -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
/*************************************************************************
*
* 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);
}
}
......@@ -37,6 +37,7 @@ CFLAGSCXX += $(CPPUNIT_CFLAGS)
SLOFILES = \
$(SLO)/getargument.obj \
$(SLO)/gettestargument.obj \
$(SLO)/officeconnection.obj \
$(SLO)/toabsolutefileurl.obj
......
......@@ -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;
......
/*************************************************************************
*
* 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() {}
}
......@@ -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
{
......
/*************************************************************************
*
* 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() {}
}
/*************************************************************************
*
* 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() {}
}
......@@ -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)
......
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