dev/null |binary reportdesign/CppunitTest_reportdesign_basic_test.mk | 61 + reportdesign/JunitTest_reportdesign_complex.mk | 39 reportdesign/Module_reportdesign.mk | 12 reportdesign/qa/complex/reportdesign/FileURL.java | 47 - reportdesign/qa/complex/reportdesign/ReportDesignerTest.java | 434 ---------- reportdesign/qa/complex/reportdesign/TestDocument.java | 33 reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl | 27 reportdesign/qa/complex/reportdesign/runner.props | 40 reportdesign/qa/unit/ReportDesignBasicTests.cxx | 89 ++ reportdesign/qa/unit/ReportDesignTest_base.cxx | 55 + reportdesign/qa/unit/data/roundTrip.odb |binary 12 files changed, 211 insertions(+), 626 deletions(-)
New commits: commit 341ff2074886bf8ea4bf80331ea78a49b9a8b3d9 Author: Adam Seskunas <adamsesku...@gmail.com> AuthorDate: Tue Aug 12 07:27:31 2025 -0700 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 15 22:26:06 2025 +0200 Port old Java test to C++ for ReportDesign - Create new C++ test suit - Port round trip ReportDesign test - Remove old deactivated Java test Change-Id: I5f3a53b3c7f528c4c171fcdc1d271faf61b17260 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189436 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/reportdesign/CppunitTest_reportdesign_basic_test.mk b/reportdesign/CppunitTest_reportdesign_basic_test.mk new file mode 100644 index 000000000000..2c79a2c6a649 --- /dev/null +++ b/reportdesign/CppunitTest_reportdesign_basic_test.mk @@ -0,0 +1,61 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,reportdesign_basic_test)) + +$(eval $(call gb_CppunitTest_use_external,reportdesign_basic_test,boost_headers)) + +$(eval $(call gb_CppunitTest_add_exception_objects,reportdesign_basic_test, \ + reportdesign/qa/unit/ReportDesignBasicTests \ +)) + +$(eval $(call gb_CppunitTest_set_include,reportdesign_basic_test,\ + -I$(SRCDIR)/reportdesign/source/inc \ + -I$(SRCDIR)/reportdesign/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,reportdesign_basic_test, \ + comphelper \ + cppu \ + cppuhelper \ + dbaxml \ + dbtools \ + sal \ + subsequenttest \ + utl \ + test \ + tk \ + tl \ + unotest \ + xo \ +)) + +$(eval $(call gb_CppunitTest_use_api,reportdesign_basic_test,\ + offapi \ + oovbaapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_use_ure,reportdesign_basic_test)) +$(eval $(call gb_CppunitTest_use_vcl,reportdesign_basic_test)) + +$(eval $(call gb_CppunitTest_use_rdb,reportdesign_basic_test,services)) + +$(eval $(call gb_CppunitTest_use_configuration,reportdesign_basic_test)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,reportdesign_basic_test, \ + reportdesign \ +)) + +$(eval $(call gb_CppunitTest_use_jars,reportdesign_basic_test, \ + sdbc_hsqldb \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/reportdesign/JunitTest_reportdesign_complex.mk b/reportdesign/JunitTest_reportdesign_complex.mk deleted file mode 100644 index 0ba631e4f8a0..000000000000 --- a/reportdesign/JunitTest_reportdesign_complex.mk +++ /dev/null @@ -1,39 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# 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 . -# - -$(eval $(call gb_JunitTest_JunitTest,reportdesign_complex)) - -$(eval $(call gb_JunitTest_set_defs,reportdesign_complex,\ - $$(DEFS) \ - -Dorg.openoffice.test.arg.tdoc=$(SRCDIR)/reportdesign/qa/complex/reportdesign/test_documents \ -)) - -$(eval $(call gb_JunitTest_add_sourcefiles,reportdesign_complex,\ - reportdesign/qa/complex/reportdesign/ReportDesignerTest \ - reportdesign/qa/complex/reportdesign/TestDocument \ - reportdesign/qa/complex/reportdesign/FileURL \ -)) - -$(eval $(call gb_JunitTest_use_unoapi_jars,reportdesign_complex)) - -$(eval $(call gb_JunitTest_add_classes,reportdesign_complex,\ - complex.reportdesign.ReportDesignerTest \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/reportdesign/Module_reportdesign.mk b/reportdesign/Module_reportdesign.mk index 88db258318d2..f9f2775837d0 100644 --- a/reportdesign/Module_reportdesign.mk +++ b/reportdesign/Module_reportdesign.mk @@ -19,15 +19,15 @@ $(eval $(call gb_Module_add_l10n_targets,reportdesign,\ AllLangMoTarget_rpt \ )) -# deactivated since sb123; -# apparently fails because OOo does not find JVM? -#$(eval $(call gb_Module_add_subsequentcheck_targets,reportdesign,\ - JunitTest_reportdesign_complex \ -)) - # screenshots $(eval $(call gb_Module_add_screenshot_targets,reportdesign,\ CppunitTest_reportdesign_dialogs_test \ )) +ifeq ($(ENABLE_JAVA),TRUE) +$(eval $(call gb_Module_add_check_targets,reportdesign,\ + CppunitTest_reportdesign_basic_test \ +)) +endif + # vim: set noet sw=4 ts=4: diff --git a/reportdesign/qa/complex/reportdesign/FileURL.java b/reportdesign/qa/complex/reportdesign/FileURL.java deleted file mode 100644 index fa67b191e917..000000000000 --- a/reportdesign/qa/complex/reportdesign/FileURL.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.reportdesign; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; - -public class FileURL -{ - private final String m_sFileURL; - - public FileURL(String _sFileURL) - { - m_sFileURL = _sFileURL; - } - public boolean exists() - { - try - { - final URI aURI = new URI(m_sFileURL); - final File aFile = new File(aURI); - return aFile.exists(); - } - catch (URISyntaxException ex) - { - System.out.println("Error: URI is wrong. '" + m_sFileURL + "': " + ex.getMessage()); - } - return false; - } -} diff --git a/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java deleted file mode 100644 index 3db6eafd7aa1..000000000000 --- a/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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.reportdesign; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import helper.URLHelper; - -import java.io.File; -import java.util.ArrayList; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openoffice.test.OfficeConnection; - -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.container.XNameAccess; -import com.sun.star.frame.XComponentLoader; -import com.sun.star.frame.XDesktop; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XStorable; -import com.sun.star.io.IOException; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.sdb.XDocumentDataSource; -import com.sun.star.sdb.XOfficeDatabaseDocument; -import com.sun.star.sdb.XReportDocumentsSupplier; -import com.sun.star.sdb.application.XDatabaseDocumentUI; -import com.sun.star.uno.RuntimeException; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; -import com.sun.star.util.CloseVetoException; -import com.sun.star.util.XCloseable; - -import convwatch.DB; - -class PropertySetHelper -{ - XPropertySet m_xPropertySet; - public PropertySetHelper(Object _aObj) - { - m_xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, _aObj); - } - - /** - get a property and don't convert it - @param _sName the string name of the property - @return the object value of the property without any conversion - */ - public Object getPropertyValueAsObject(String _sName) - { - Object aObject = null; - - if (m_xPropertySet != null) - { - try - { - aObject = m_xPropertySet.getPropertyValue(_sName); - } - catch (com.sun.star.beans.UnknownPropertyException e) - { - System.out.println("ERROR: UnknownPropertyException caught. '" + _sName + "'"); - System.out.println("Message: " + e.getMessage()); - } - catch (com.sun.star.lang.WrappedTargetException e) - { - System.out.println("ERROR: WrappedTargetException caught."); - System.out.println("Message: " + e.getMessage()); - } - } - return aObject; - } -} - -class PropertyHelper -{ - /** - Create a PropertyValue[] from an ArrayList - */ - public static PropertyValue[] createPropertyValueArrayFormArrayList(ArrayList<PropertyValue> _aPropertyList) - { - // copy the whole PropertyValue List to a PropertyValue Array - PropertyValue[] aSaveProperties = null; - - if (_aPropertyList == null) - { - aSaveProperties = new PropertyValue[0]; - } - else - { - if (_aPropertyList.size() > 0) - { - aSaveProperties = new PropertyValue[_aPropertyList.size()]; - for (int i = 0;i<_aPropertyList.size(); i++) - { - aSaveProperties[i] = _aPropertyList.get(i); - } - } - else - { - aSaveProperties = new PropertyValue[0]; - } - } - return aSaveProperties; - } -} - -public class ReportDesignerTest -{ - - String mTestDocumentPath; - - @Before public void before() - { - System.out.println("before"); - } - - @After public void after() - { - System.out.println("after"); - } - - private XDesktop m_xDesktop = null; - public XDesktop getXDesktop() throws com.sun.star.uno.Exception - { - - if (m_xDesktop == null) - { - XInterface xInterface = (XInterface) getMSF().createInstance( "com.sun.star.frame.Desktop" ); - m_xDesktop = UnoRuntime.queryInterface(XDesktop.class, xInterface); - assertNotNull("Can't get XDesktop", m_xDesktop); - } - return m_xDesktop; - } - - private void showElements(XNameAccess _xNameAccess) - { - if (_xNameAccess != null) - { - String[] sElementNames = _xNameAccess.getElementNames(); - for(int i=0;i<sElementNames.length; i++) - { - System.out.println("Value: [" + i + "] := " + sElementNames[i]); - } - } - else - { - System.out.println("Warning: Given object is null."); - } - } - - - private static final int WRITER = 1; - private static final int CALC = 2; - - @Test public void firsttest() throws Exception - { - // -------------------- preconditions, try to find an office -------------------- - - String sUser = System.getProperty("user.name"); - System.out.println("user.name='" + sUser + "'"); - - String sVCSID = System.getProperty("VCSID"); - System.out.println("VCSID='" + sVCSID + "'"); - String sMailAddress = sVCSID + "@openoffice.org"; - System.out.println("Assumed mail address: " + sMailAddress); - - String sUPDMinor = System.getProperty("UPDMINOR"); - System.out.println("Current MWS: " + sUPDMinor); - - // --------------------------- Start the given Office --------------------------- - - // ------------------------------ Start a test run ------------------------------ - - String sWriterDocument = TestDocument.getUrl("RPTWriterTests.odb"); - startTestForFile(sWriterDocument, WRITER); - - String sCalcDocument = TestDocument.getUrl("RPTCalcTests.odb"); - startTestForFile(sCalcDocument, CALC); - - // ------------------------------ Office shutdown ------------------------------ - } - - - private void startTestForFile(String _sDocument, int _nType) throws Exception - { - FileURL aFileURL = new FileURL(_sDocument); - assertTrue("Test File doesn't '" + _sDocument + "'exist.", aFileURL.exists()); - - String sFileURL = _sDocument; - System.out.println("File URL: " + sFileURL); - - XComponent xDocComponent = loadComponent(sFileURL, getXDesktop(), null); - System.out.println("Load done"); - assertNotNull("Can't load document ", xDocComponent); - - - XInterface x = (XInterface)getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); - assertNotNull("can't create instance of com.sun.star.sdb.DatabaseContext", x); - System.out.println("createInstance com.sun.star.sdb.DatabaseContext done"); - - XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, x); - showElements(xNameAccess); - Object aObj = xNameAccess.getByName(sFileURL); - - XDocumentDataSource xDataSource = UnoRuntime.queryInterface(XDocumentDataSource.class, aObj); - XOfficeDatabaseDocument xOfficeDBDoc = xDataSource.getDatabaseDocument(); - - assertNotNull("can't access DatabaseDocument", xOfficeDBDoc); - - XModel xDBSource = UnoRuntime.queryInterface(XModel.class, xOfficeDBDoc); - Object aController = xDBSource.getCurrentController(); - assertNotNull("Controller of xOfficeDatabaseDocument is empty!", aController); - - XDatabaseDocumentUI aDBDocUI = UnoRuntime.queryInterface(XDatabaseDocumentUI.class, aController); - /* boolean isConnect = */ - // TODO: throws an exception in DEV300m78 - aDBDocUI.connect(); - Object aActiveConnectionObj = aDBDocUI.getActiveConnection(); - assertNotNull("ActiveConnection is empty", aActiveConnectionObj); - - XReportDocumentsSupplier xSupplier = UnoRuntime.queryInterface(XReportDocumentsSupplier.class, xOfficeDBDoc); - xNameAccess = xSupplier.getReportDocuments(); - assertNotNull("xOfficeDatabaseDocument returns no Report Document", xNameAccess); - - showElements(xNameAccess); - - ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); - - PropertyValue aActiveConnection = new PropertyValue(); - aActiveConnection.Name = "ActiveConnection"; - aActiveConnection.Value = aActiveConnectionObj; - aPropertyList.add(aActiveConnection); - - loadAndStoreReports(xNameAccess, aPropertyList, _nType); - createDBEntry(); - - // Close the document - closeComponent(xDocComponent); - } - - private String getDocumentPoolName(int _nType) - { - return getFileFormat(_nType); - } - - - private void createDBEntry() - { - // try to connect the database - String sDBConnection = ""; // (String)param.get( convwatch.PropertyName.DB_CONNECTION_STRING ); - System.out.println("DBConnection: " + sDBConnection); - DB.init(sDBConnection); -// String sDestinationVersion = m_sUPDMinor; -// String sDestinationName = ""; -// String sDestinationCreatorType = ""; -// String sDocumentPoolDir = getOutputPath(_nType); -// String sDocumentPoolName = getDocumentPoolName(_nType); -// String sSpecial = ""; -// String sFixRefSubDirectory = "ReportDesign_qa_complex_" + getFileFormat(_nType); -// DB.insertinto_documentcompare(sFixRefSubDirectory, "", "fixref", -// sDestinationVersion, sDestinationName, sDestinationCreatorType, -// sDocumentPoolDir, sDocumentPoolName, m_sMailAddress, -// sSpecial); - } - - private void loadAndStoreReports(XNameAccess _xNameAccess, ArrayList<PropertyValue> _aPropertyList, int _nType) throws Exception - { - if (_xNameAccess != null) - { - String[] sElementNames = _xNameAccess.getElementNames(); - for(int i=0;i<sElementNames.length; i++) - { - String sReportName = sElementNames[i]; - XComponent xDoc = loadComponent(sReportName, _xNameAccess, _aPropertyList); - // print? or store? - storeComponent(sReportName, xDoc, _nType); - closeComponent(xDoc); - } - } - } - - private String getFormatExtension(int _nType) - { - String sExtension; - switch(_nType) - { - case WRITER: - sExtension = ".odt"; - break; - case CALC: - sExtension = ".ods"; - break; - default: - sExtension = ".UNKNOWN"; - } - return sExtension; - } - private String getFileFormat(int _nType) - { - String sFileType; - switch(_nType) - { - case WRITER: - sFileType = "writer8"; - break; - case CALC: - sFileType = "calc8"; - break; - default: - sFileType = "UNKNOWN"; - } - return sFileType; - } - - private String getOutputPath() - { - String sOutputPath = util.utils.getOfficeTemp/*Dir*/(getMSF());// (String)param.get( convwatch.PropertyName.DOC_COMPARATOR_OUTPUT_PATH ); - - if (!sOutputPath.endsWith("/") || // construct the output file name - !sOutputPath.endsWith("\")) - { - sOutputPath += System.getProperty("file.separator"); - } - sOutputPath += "tmp_123"; - sOutputPath += System.getProperty("file.separator"); - - File aOutputFile = new File(sOutputPath); // create the directory of the given output path - aOutputFile.mkdirs(); - - return sOutputPath; - } - - /* - store given _xComponent under the given Name in DOC_COMPARATOR_INPUTPATH - */ - private void storeComponent(String _sName, Object _xComponent, int _nType) throws Exception - { - String sOutputPath = getOutputPath(); - - // add DocumentPoolName - sOutputPath += getDocumentPoolName(_nType); - sOutputPath += System.getProperty("file.separator"); - - File aOutputFile = new File(sOutputPath); // create the directory of the given output path - aOutputFile.mkdirs(); - - sOutputPath += _sName; - sOutputPath += getFormatExtension(_nType); - - String sOutputURL = URLHelper.getFileURLFromSystemPath(sOutputPath); - - ArrayList<PropertyValue> aPropertyList = new ArrayList<PropertyValue>(); // set some properties for storeAsURL - - PropertyValue aFileFormat = new PropertyValue(); - aFileFormat.Name = "FilterName"; - aFileFormat.Value = getFileFormat(_nType); - aPropertyList.add(aFileFormat); - - PropertyValue aOverwrite = new PropertyValue(); // always overwrite already exist files - aOverwrite.Name = "Overwrite"; - aOverwrite.Value = Boolean.TRUE; - aPropertyList.add(aOverwrite); - - // store the document in another directory - XStorable aStorable = UnoRuntime.queryInterface(XStorable.class, _xComponent); - if (aStorable != null) - { - System.out.println("store document as URL: '" + sOutputURL + "'"); - aStorable.storeAsURL(sOutputURL, PropertyHelper.createPropertyValueArrayFormArrayList(aPropertyList)); - } - } - - private XComponent loadComponent(String _sName, Object _xComponent, ArrayList<PropertyValue> _aPropertyList) throws RuntimeException, IOException - { - XComponent xDocComponent = null; - XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, _xComponent); - - PropertyValue[] aLoadProperties = PropertyHelper.createPropertyValueArrayFormArrayList(_aPropertyList); - System.out.println("Load component: '" + _sName + "'"); - xDocComponent = xComponentLoader.loadComponentFromURL(_sName, "_blank", 0, aLoadProperties); - return xDocComponent; - } - - private void closeComponent(XComponent _xDoc) throws CloseVetoException - { - // Close the document - XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, _xDoc); - xCloseable.close(true); - } - - - 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(); - -} diff --git a/reportdesign/qa/complex/reportdesign/TestDocument.java b/reportdesign/qa/complex/reportdesign/TestDocument.java deleted file mode 100644 index 7422147bbb1a..000000000000 --- a/reportdesign/qa/complex/reportdesign/TestDocument.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.reportdesign; - -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() {} -} diff --git a/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl deleted file mode 100644 index 9728f70cd42a..000000000000 --- a/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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 . -# - -eval 'exec perl -wS $0 ${1+\"$@\"}' - if 0; - -my $sMySQLConnector = $ARGV[0]; -if (! -e $sMySQLConnector) -{ - exit 1; -} -exit 0; diff --git a/reportdesign/qa/complex/reportdesign/runner.props b/reportdesign/qa/complex/reportdesign/runner.props deleted file mode 100644 index a9830f2c8695..000000000000 --- a/reportdesign/qa/complex/reportdesign/runner.props +++ /dev/null @@ -1,40 +0,0 @@ -# -# 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 . -# - -# where to store created documents -wntmsci.DOC_COMPARATOR_OUTPUT_PATH=\\so-gfxcmp-lin\doc-pool\reporttest -unxlngi.DOC_COMPARATOR_OUTPUT_PATH=/net/so-gfxcmp-lin/export/gfxcmp/document-pool/reporttest - -DB_CONNECTION_STRING=server:jakobus,db:jobs_convwatch,user:admin,passwd:admin - -# Set path to an existing office installation -wntmsci.AppExecutionCommand=C:\home\${USERNAME}\staroffice8\program\soffice.exe --norestore --accept=socket,host=localhost,port=8100;urp; -unxlngi.AppExecutionCommand=/opt/staroffice8/program/soffice --norestore --accept=socket,host=localhost,port=8100;urp; - -# Set the 'Continue' Property to true, to leave out already done tests. -Continue=true - -TestBase=java_complex -TestJob=-o complex.ReportDesignerTest -DebugIsActive=true -ThreadTimeOut=400000 -SingleTimeOut=300000 - -# don't start office automatically -NoOffice=true - diff --git a/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb deleted file mode 100644 index 0e91d633d4e7..000000000000 Binary files a/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb and /dev/null differ diff --git a/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb deleted file mode 100644 index 7099b1abf2b5..000000000000 Binary files a/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb and /dev/null differ diff --git a/reportdesign/qa/unit/ReportDesignBasicTests.cxx b/reportdesign/qa/unit/ReportDesignBasicTests.cxx new file mode 100644 index 000000000000..5d71b0ac1153 --- /dev/null +++ b/reportdesign/qa/unit/ReportDesignBasicTests.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 . + */ + +#include "ReportDesignTest_base.cxx" + +#include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> +#include <comphelper/namedvaluecollection.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +class RptBasicTest : public ReportDesignTestBase +{ +public: + void roundTripTest(); + void testLoadingAndSaving(const OUString& rFilterName, const OUString& rReportName, + Reference<frame::XComponentLoader>& xComponentLoader, + Reference<XConnection>& xActiveConnection); + + CPPUNIT_TEST_SUITE(RptBasicTest); + CPPUNIT_TEST(roundTripTest); + CPPUNIT_TEST_SUITE_END(); +}; + +void RptBasicTest::roundTripTest() +{ + // Test loading and saving an already prepared Report + // This is a very general test designed to catch crashes + // on import and saving + loadURL(u"roundTrip.odb"); + + Reference<frame::XModel> xModel(mxComponent, UNO_QUERY_THROW); + Reference<frame::XController> xController(xModel->getCurrentController()); + Reference<sdb::application::XDatabaseDocumentUI> xUI(xController, UNO_QUERY_THROW); + + xUI->connect(); + Reference<XConnection> xActiveConnection = xUI->getActiveConnection(); + + Reference<XReportDocumentsSupplier> xSupp(xModel, UNO_QUERY_THROW); + Reference<container::XNameAccess> xNameAccess = xSupp->getReportDocuments(); + const Sequence<OUString> aReportNames(xNameAccess->getElementNames()); + + Reference<frame::XComponentLoader> xComponentLoader(xNameAccess, UNO_QUERY_THROW); + + testLoadingAndSaving(u"writer8"_ustr, aReportNames[0], xComponentLoader, xActiveConnection); + testLoadingAndSaving(u"calc8"_ustr, aReportNames[1], xComponentLoader, xActiveConnection); +} + +void RptBasicTest::testLoadingAndSaving(const OUString& rFilterName, const OUString& rReportName, + Reference<frame::XComponentLoader>& xComponentLoader, + Reference<XConnection>& xActiveConnection) +{ + ::comphelper::NamedValueCollection aLoadArgs; + aLoadArgs.put(u"ActiveConnection"_ustr, xActiveConnection); + + ::comphelper::NamedValueCollection aSaveArgs; + aSaveArgs.put(u"FilterName"_ustr, rFilterName); + + Reference<lang::XComponent> xComponent = xComponentLoader->loadComponentFromURL( + rReportName, u"_blank"_ustr, 0, aLoadArgs.getPropertyValues()); + + Reference<frame::XStorable> xStorable(xComponent, UNO_QUERY_THROW); + xStorable->storeAsURL(maTempFile.GetURL(), aSaveArgs.getPropertyValues()); + + Reference<util::XCloseable> xCloseable(xComponent, UNO_QUERY_THROW); + xCloseable->close(true); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(RptBasicTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/reportdesign/qa/unit/ReportDesignTest_base.cxx b/reportdesign/qa/unit/ReportDesignTest_base.cxx new file mode 100644 index 000000000000..923e49525b95 --- /dev/null +++ b/reportdesign/qa/unit/ReportDesignTest_base.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <sal/config.h> + +#include <string_view> + +#include <test/unoapi_test.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/util/XCloseable.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +class ReportDesignTestBase : public UnoApiTest +{ +public: + ReportDesignTestBase() + : UnoApiTest(u"reportdesign/qa/unit/data"_ustr){}; + + void loadURL(std::u16string_view rURL); + virtual void tearDown() override; +}; + +void ReportDesignTestBase::loadURL(std::u16string_view sURL) +{ + mxComponent = mxDesktop->loadComponentFromURL(createFileURL(sURL), u"_default"_ustr, 0, {}); +} + +void ReportDesignTestBase::tearDown() +{ + if (mxComponent) + { + // In order to close all windows + css::uno::Reference<util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(false); + } + + UnoApiTest::tearDown(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/reportdesign/qa/unit/data/roundTrip.odb b/reportdesign/qa/unit/data/roundTrip.odb new file mode 100644 index 000000000000..8ab8306646bc Binary files /dev/null and b/reportdesign/qa/unit/data/roundTrip.odb differ