From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- reportdesign/qa/complex/reportdesign/FileURL.java | 47 +++ .../complex/reportdesign/ReportDesignerTest.java | 434 +++++++++++++++++++++ .../qa/complex/reportdesign/TestDocument.java | 33 ++ .../complex/reportdesign/mysql-connector-exists.pl | 27 ++ reportdesign/qa/complex/reportdesign/runner.props | 40 ++ .../reportdesign/test_documents/RPTCalcTests.odb | Bin 0 -> 6715 bytes .../reportdesign/test_documents/RPTWriterTests.odb | Bin 0 -> 5762 bytes .../qa/unit/data/reportdesign-dialogs-test.txt | 51 +++ reportdesign/qa/unit/reportdesign-dialogs-test.cxx | 61 +++ 9 files changed, 693 insertions(+) create mode 100644 reportdesign/qa/complex/reportdesign/FileURL.java create mode 100644 reportdesign/qa/complex/reportdesign/ReportDesignerTest.java create mode 100644 reportdesign/qa/complex/reportdesign/TestDocument.java create mode 100644 reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl create mode 100644 reportdesign/qa/complex/reportdesign/runner.props create mode 100644 reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb create mode 100644 reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb create mode 100644 reportdesign/qa/unit/data/reportdesign-dialogs-test.txt create mode 100644 reportdesign/qa/unit/reportdesign-dialogs-test.cxx (limited to 'reportdesign/qa') diff --git a/reportdesign/qa/complex/reportdesign/FileURL.java b/reportdesign/qa/complex/reportdesign/FileURL.java new file mode 100644 index 000000000..fa67b191e --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/FileURL.java @@ -0,0 +1,47 @@ +/* + * 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 new file mode 100644 index 000000000..3db6eafd7 --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/ReportDesignerTest.java @@ -0,0 +1,434 @@ +/* + * 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 _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 aPropertyList = new ArrayList(); + + 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 _aPropertyList, int _nType) throws Exception + { + if (_xNameAccess != null) + { + String[] sElementNames = _xNameAccess.getElementNames(); + for(int i=0;i aPropertyList = new ArrayList(); // 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 _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 new file mode 100644 index 000000000..7422147bb --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/TestDocument.java @@ -0,0 +1,33 @@ +/* + * 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 new file mode 100644 index 000000000..9728f70cd --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/mysql-connector-exists.pl @@ -0,0 +1,27 @@ +# +# 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 new file mode 100644 index 000000000..a9830f2c8 --- /dev/null +++ b/reportdesign/qa/complex/reportdesign/runner.props @@ -0,0 +1,40 @@ +# +# 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 new file mode 100644 index 000000000..0e91d633d Binary files /dev/null and b/reportdesign/qa/complex/reportdesign/test_documents/RPTCalcTests.odb differ diff --git a/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb new file mode 100644 index 000000000..7099b1abf Binary files /dev/null and b/reportdesign/qa/complex/reportdesign/test_documents/RPTWriterTests.odb differ diff --git a/reportdesign/qa/unit/data/reportdesign-dialogs-test.txt b/reportdesign/qa/unit/data/reportdesign-dialogs-test.txt new file mode 100644 index 000000000..470deda69 --- /dev/null +++ b/reportdesign/qa/unit/data/reportdesign-dialogs-test.txt @@ -0,0 +1,51 @@ +# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +# +# 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 contains all dialogs that the unit tests in the module +# will work on if it is in script mode. It will read one-by-one, +# try to open it and create a screenshot that will be saved in +# workdir/screenshots using the pattern of the ui-file name. +# +# Syntax: +# - empty lines are allowed +# - lines starting with '#' are treated as comment +# - all other lines should contain a *.ui filename in the same +# notation as in the dialog constructors (see code) + +# +# The 'known' dialogs which have a hard-coded representation +# in registerKnownDialogsByID/createDialogByID +# + +# No known dialogs in reportdesign for now + +# +# Dialogs without a hard-coded representation. These will +# be visualized using a fallback based on weld::Builder +# + +# currently deactivated, leads to problems and the test to not work +# This is typically a hint that these should be hard-coded in the +# test case since they need some document and model data to work +# all these are pretty much a single one based on modules/dbreport/ui/_.ui +# with _ being the listed entries - probably all work when base dialog works +# modules/dbreport/ui/background.ui +# modules/dbreport/ui/page.ui +# modules/dbreport/ui/font.ui +# modules/dbreport/ui/fonteffects.ui +# modules/dbreport/ui/position.ui +# modules/dbreport/ui/asianlayout.ui +# modules/dbreport/ui/alignment.ui + +modules/dbreport/ui/condformatdialog.ui +modules/dbreport/ui/datetimedialog.ui +modules/dbreport/ui/pagenumberdialog.ui +modules/dbreport/ui/floatingsort.ui +modules/dbreport/ui/floatingnavigator.ui +modules/dbreport/ui/conditionwin.ui diff --git a/reportdesign/qa/unit/reportdesign-dialogs-test.cxx b/reportdesign/qa/unit/reportdesign-dialogs-test.cxx new file mode 100644 index 000000000..0f3295ea6 --- /dev/null +++ b/reportdesign/qa/unit/reportdesign-dialogs-test.cxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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 +#include +#include + +using namespace ::com::sun::star; + +/// Test opening a dialog in reportdesign +class ReportdesignDialogsTest : public ScreenshotTest +{ +private: + /// helper method to populate KnownDialogs, called in setUp(). Needs to be + /// written and has to add entries to KnownDialogs + virtual void registerKnownDialogsByID(mapType& rKnownDialogs) override; + + /// dialog creation for known dialogs by ID. Has to be implemented for + /// each registered known dialog + virtual VclPtr createDialogByID(sal_uInt32 nID) override; + +public: + ReportdesignDialogsTest(); + + // try to open a dialog + void openAnyDialog(); + + CPPUNIT_TEST_SUITE(ReportdesignDialogsTest); + CPPUNIT_TEST(openAnyDialog); + CPPUNIT_TEST_SUITE_END(); +}; + +ReportdesignDialogsTest::ReportdesignDialogsTest() {} + +void ReportdesignDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/) +{ + // fill map of known dialogs +} + +VclPtr ReportdesignDialogsTest::createDialogByID(sal_uInt32 /*nID*/) +{ + return nullptr; +} + +void ReportdesignDialogsTest::openAnyDialog() +{ + /// process input file containing the UXMLDescriptions of the dialogs to dump + processDialogBatchFile(u"reportdesign/qa/unit/data/reportdesign-dialogs-test.txt"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ReportdesignDialogsTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3