Kaydet (Commit) 477e19d2 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen Kaydeden (comit) Michael Meeks

targetted make reversion.

üst 764e7e71
...@@ -45,9 +45,7 @@ $(eval $(call gb_CppunitTest_set_include,writerfilter_doctok,\ ...@@ -45,9 +45,7 @@ $(eval $(call gb_CppunitTest_set_include,writerfilter_doctok,\
-I$(SRCDIR)/writerfilter/inc \ -I$(SRCDIR)/writerfilter/inc \
)) ))
$(eval $(call gb_CppunitTest_use_api,writerfilter_doctok,\ $(eval $(call gb_CppunitTest_use_sdk_api,writerfilter_doctok))
offapi \ $(eval $(call gb_CppunitTest_use_udk_api,writerfilter_doctok))
udkapi \
))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -35,12 +35,9 @@ $(eval $(call gb_Module_add_targets,writerfilter,\ ...@@ -35,12 +35,9 @@ $(eval $(call gb_Module_add_targets,writerfilter,\
)) ))
$(eval $(call gb_Module_add_check_targets,writerfilter,\ $(eval $(call gb_Module_add_check_targets,writerfilter,\
CppunitTest_writerfilter_doctok \
CppunitTest_writerfilter_rtftok \ CppunitTest_writerfilter_rtftok \
)) ))
$(eval $(call gb_Module_add_subsequentcheck_targets,writerfilter,\ # CppunitTest_writerfilter_doctok \
JunitTest_writerfilter_complex \
))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -17,17 +17,10 @@ ...@@ -17,17 +17,10 @@
*/ */
package complex.ooxml; package complex.ooxml;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime; import complexlib.ComplexTestCase;
import java.io.File; import java.io.File;
import org.junit.AfterClass; import com.sun.star.text.XTextDocument;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openoffice.test.Argument;
import org.openoffice.test.OfficeConnection;
import static org.junit.Assert.*;
/* /*
* To change this template, choose Tools | Templates * To change this template, choose Tools | Templates
...@@ -38,54 +31,38 @@ import static org.junit.Assert.*; ...@@ -38,54 +31,38 @@ import static org.junit.Assert.*;
* *
* @author hb137859 * @author hb137859
*/ */
public class LoadDocuments { public class LoadDocuments extends ComplexTestCase {
@Test public void test1() { private XMultiServiceFactory m_xMSF;
String testDocumentsPath = Argument.get("tdoc");
System.out.println("Test documents in:" + testDocumentsPath); @Override
public String[] getTestMethodNames() {
return new String [] {
"test1"
};
}
public void before() throws Exception {
m_xMSF = (XMultiServiceFactory) param.getMSF();
}
public void test1() {
String testDocumentsPath = util.utils.getFullTestDocName("");
log.println("Test documents in:" + testDocumentsPath);
File dir = new File(testDocumentsPath); File dir = new File(testDocumentsPath);
String [] files = dir.list(); String [] files = dir.list();
try { if (files != null) {
if (files != null) { for (int i = 0; i < files.length; ++i) {
for (int i = 0; i < files.length; ++i) { log.println(files[i]);
System.out.println(files[i]); String url = util.utils.getFullTestURL(files[i]);
String url = TestDocument.getUrl(files[i]); log.println(url);
System.out.println(url);
XComponent xDoc = util.DesktopTools.loadDoc(getMSF(), url, null); XTextDocument xDoc = util.WriterTools.loadTextDoc(m_xMSF, url);
System.out.println("loaded."); util.DesktopTools.closeDoc(xDoc);
util.DesktopTools.closeDoc(xDoc);
System.out.println("done.");
}
} else {
fail("Files not found");
} }
} else {
failed();
} }
catch (Exception e) {
System.out.println(e);
fail("failed");
}
}
private XMultiServiceFactory getMSF()
{
final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
return xMSF1;
}
// setup and close connections
@BeforeClass public static void setUpConnection() throws Exception
{
System.out.println("setUpConnection()");
connection.setUp();
}
@AfterClass public static void tearDownConnection()
throws InterruptedException, com.sun.star.uno.Exception
{
System.out.println("tearDownConnection()");
connection.tearDown();
} }
private static final OfficeConnection connection = new OfficeConnection();
} }
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
package complex.ooxml;
import java.io.File;
import org.openoffice.test.OfficeFileUrl;
import org.openoffice.test.Argument;
final class TestDocument {
public static String getUrl(String name) {
return OfficeFileUrl.getAbsolute(new File(Argument.get("tdoc"), name));
}
private TestDocument() {}
}
...@@ -17,141 +17,234 @@ ...@@ -17,141 +17,234 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <sal/config.h>
#include <osl/process.h> #include <osl/process.h>
#include <ucbhelper/contentbroker.hxx>
#include <ucbhelper/std_inputstream.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
#include "cppunit/TestAssert.h" #include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h" #include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h" #include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h" #include "cppunit/plugin/TestPlugIn.h"
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <iostream> #include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/container/XNameContainer.hpp>
#include <resourcemodel/exceptions.hxx>
#include <doctok/WW8Document.hxx> #include <doctok/WW8Document.hxx>
#include <resourcemodel/WW8ResourceModel.hxx>
#include <iostream>
namespace testdoctok namespace testdoctok
{ {
using namespace ::std; using namespace ::std;
using namespace ::com::sun::star; using namespace ::writerfilter::doctok;
using namespace ::writerfilter::doctok; using namespace ::com::sun::star;
uno::Reference<io::XInputStream> xStream; uno::Reference<io::XInputStream> xStream;
uno::Reference<uno::XComponentContext> xContext; uno::Reference<uno::XComponentContext> xContext;
WW8Document::Pointer_t pDocument; WW8Document::Pointer_t pDocument;
uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess; uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess;
class test : public CppUnit::TestFixture class test : public CppUnit::TestFixture
{
public:
// initialise your test code values here.
void setUp()
{ {
}
void tearDown() public:
{ // initialise your test code values here.
} void setUp()
{
}
void testInitUno() void tearDown()
{ {
bool bResult = false; }
uno::Reference<uno::XComponentContext> void testInitUno()
xComponentContext {
(::cppu::defaultBootstrap_InitialComponentContext()); bool bResult = false;
OSL_ASSERT( xComponentContext.is() );
xContext = xComponentContext; // initialise UCB-Broker
uno::Reference<uno::XComponentContext>
xComponentContext
(::cppu::defaultBootstrap_InitialComponentContext());
OSL_ASSERT( xComponentContext.is() );
uno::Reference<lang::XMultiComponentFactory> xContext = xComponentContext;
xFactory(xComponentContext->getServiceManager() );
OSL_ASSERT(xFactory.is());
uno::Reference<lang::XMultiServiceFactory> uno::Reference<lang::XMultiComponentFactory>
xServiceFactory(xFactory, uno::UNO_QUERY); xFactory(xComponentContext->getServiceManager() );
OSL_ASSERT( xServiceFactory.is() ); OSL_ASSERT(xFactory.is());
if (xServiceFactory.is()) uno::Sequence<uno::Any> aUcbInitSequence(2);
{ aUcbInitSequence[0] <<=
uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
xNameContainer(xFactory->createInstanceWithContext aUcbInitSequence[1] <<=
("com.sun.star.ucb.SimpleFileAccess", rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
xComponentContext), uno::UNO_QUERY );
if (xNameContainer.is()) uno::Reference<lang::XMultiServiceFactory>
{ xServiceFactory(xFactory, uno::UNO_QUERY);
xSimpleFileAccess = xNameContainer; OSL_ASSERT( xServiceFactory.is() );
bResult = true; if (xServiceFactory.is())
{
sal_Bool bRet =
::ucb::ContentBroker::initialize(xServiceFactory,
aUcbInitSequence);
OSL_ASSERT(bRet);
if (bRet)
{
uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >
xNameContainer(xFactory->createInstanceWithContext
(::rtl::OUString::createFromAscii
("com.sun.star.ucb.SimpleFileAccess" ),
xComponentContext), uno::UNO_QUERY );
if (xNameContainer.is())
{
xSimpleFileAccess = xNameContainer;
bResult = true;
}
}
} }
CPPUNIT_ASSERT_MESSAGE("UNO initialization failed",
bResult);
} }
CPPUNIT_ASSERT_MESSAGE("UNO initialization failed", // insert your test code here.
bResult); void testOpenFile()
} {
try
{
rtl_uString *dir=NULL;
osl_getProcessWorkingDir(&dir);
rtl_uString *fname=NULL;
//rtl_uString_newFromAscii(&fname, "/OpenDocument-v1.doc");
rtl_uString_newFromAscii(&fname, "/test.doc");
//rtl_uString_newFromAscii(&fname, "/numbers.doc");
rtl_uString *absfile=NULL;
rtl_uString_newConcat(&absfile, dir, fname);
// insert your test code here. rtl::OUString sInputFileURL( absfile );
void testOpenFile()
{
rtl_uString *dir=NULL;
osl_getProcessWorkingDir(&dir);
rtl_uString *fname=NULL;
rtl_uString_newFromAscii(&fname, "/test.doc");
rtl_uString *absfile=NULL;
rtl_uString_newConcat(&absfile, dir, fname);
OUString sInputFileURL( absfile ); for (sal_uInt32 n = 0; n < sInputFileURL.getLength(); ++n)
{
sal_uChar nC = sInputFileURL[n];
for (sal_Int32 n = 0; n < sInputFileURL.getLength(); ++n) if (nC < 0xff && isprint(nC))
{ clog << static_cast<char>(nC);
sal_uChar nC = sInputFileURL[n]; else
clog << ".";
}
clog << endl;
xStream = xSimpleFileAccess->openFileRead(sInputFileURL);
WW8Stream::Pointer_t pStream =
WW8DocumentFactory::createStream(xContext, xStream);
if (nC < 0xff && isprint(nC)) pDocument = WW8DocumentFactory::createDocument(pStream);
clog << static_cast<char>(nC); }
else catch (writerfilter::Exception e)
clog << "."; {
clog << "Exception!!" << endl;
}
CPPUNIT_ASSERT_MESSAGE("creating document failed",
pDocument != NULL);
#if 1
} }
clog << endl; void testTraversal()
{
#endif
sal_uInt32 nResult = 0;
xStream = xSimpleFileAccess->openFileRead(sInputFileURL); try
{
WW8DocumentIterator::Pointer_t pIt = pDocument->begin();
WW8DocumentIterator::Pointer_t pItEnd = pDocument->end();
WW8Stream::Pointer_t pStream = while (! pIt->equal(*pItEnd))
WW8DocumentFactory::createStream(xContext, xStream); {
pIt->dump(clog);
pDocument.reset(WW8DocumentFactory::createDocument(pStream)); clog << endl;
CPPUNIT_ASSERT_MESSAGE("creating document failed", WW8PropertySet::Pointer_t pAttrs = pIt->getProperties();
pDocument != NULL);
}
void testEvents() if (pAttrs != NULL)
{ {
::writerfilter::Stream::Pointer_t pStream = ::writerfilter::createStreamHandler(); pAttrs->dump(clog);
}
pDocument->resolve(*pStream); pIt->getText().dump(clog);
} ++(*pIt);
++nResult;
}
}
catch (writerfilter::Exception e)
{
clog << "Exception!!" << endl;
}
// Change the following lines only, if you add, remove or rename char sBuffer[256];
// member functions of the current class, snprintf(sBuffer, 255, "%d", nResult);
// because these macros are need by auto register mechanism. clog << "Iterator steps:" << sBuffer << endl;
CPPUNIT_TEST_SUITE(test); CPPUNIT_ASSERT_MESSAGE("traversing document failed",
CPPUNIT_TEST(testInitUno); nResult > 0);
CPPUNIT_TEST(testOpenFile); }
CPPUNIT_TEST(testEvents);
CPPUNIT_TEST_SUITE_END();
}; // class test
// ----------------------------------------------------------------------------- void testEvents()
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testdoctok::test, "doctok"); {
} // namespace doctok try
{
Stream::Pointer_t pStream = doctok::createStreamHandler();
pDocument->resolve(*pStream);
}
catch (writerfilter::Exception e)
{
clog << "Exception!!" << endl;
}
}
void testEnd()
{
::ucb::ContentBroker::deinitialize();
}
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
CPPUNIT_TEST_SUITE(test);
CPPUNIT_TEST(testInitUno);
CPPUNIT_TEST(testOpenFile);
//CPPUNIT_TEST(testTraversal);
CPPUNIT_TEST(testEvents);
CPPUNIT_TEST(testEnd);
CPPUNIT_TEST_SUITE_END();
}; // class test
// -----------------------------------------------------------------------------
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testdoctok::test, "doctok");
} // namespace doctok
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
CPPUNIT_PLUGIN_IMPLEMENT(); // this macro creates an empty function, which will called by the RegisterAllFunctions()
// to let the user the possibility to also register some functions by hand.
NOADDITIONAL;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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