diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /sw/qa/unit | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/unit')
-rw-r--r-- | sw/qa/unit/data/sw-dialogs-test.txt | 210 | ||||
-rw-r--r-- | sw/qa/unit/data/sw-dialogs-test_2.txt | 79 | ||||
-rw-r--r-- | sw/qa/unit/sw-dialogs-test.cxx | 103 | ||||
-rw-r--r-- | sw/qa/unit/sw-dialogs-test_2.cxx | 94 | ||||
-rw-r--r-- | sw/qa/unit/uibase.cxx | 44 |
5 files changed, 530 insertions, 0 deletions
diff --git a/sw/qa/unit/data/sw-dialogs-test.txt b/sw/qa/unit/data/sw-dialogs-test.txt new file mode 100644 index 000000000..4a077f327 --- /dev/null +++ b/sw/qa/unit/data/sw-dialogs-test.txt @@ -0,0 +1,210 @@ +# -*- 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 writer for now + +# +# Dialogs without a hard-coded representation. These will +# be visualized using a fallback based on VclBuilder +# + +# 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 +# +# modules/swriter/ui/templatedialog(nRegion).ui +# modules/swriter/ui/autoformattable.ui +# modules/swriter/ui/endnotepage.ui +# modules/swriter/ui/footnotesendnotestabpage.ui +# modules/swriter/ui/linenumbering.ui +# modules/swriter/ui/footnotepage.ui +# modules/swriter/ui/outlinenumberingpage.ui +# modules/swriter/ui/picturepage.ui <- problems under Linux +# +# Problems under ASan/UBSan, SwEnvPreview needs SwEnvDlg as parent: +# modules/swriter/ui/envaddresspage.ui +# modules/swriter/ui/envformatpage.ui +# modules/swriter/ui/envprinterpage.ui + +modules/swriter/ui/abstractdialog.ui +modules/swriter/ui/addentrydialog.ui +modules/swriter/ui/addressblockdialog.ui +modules/swriter/ui/alreadyexistsdialog.ui +modules/swriter/ui/asciifilterdialog.ui +modules/swriter/ui/asksearchdialog.ui +modules/swriter/ui/assignfieldsdialog.ui +modules/swriter/ui/assignstylesdialog.ui +modules/swriter/ui/attachnamedialog.ui +modules/swriter/ui/authenticationsettingsdialog.ui +modules/swriter/ui/autotext.ui +modules/swriter/ui/bibliographyentry.ui +modules/swriter/ui/bulletsandnumbering.ui +modules/swriter/ui/businessdatapage.ui +modules/swriter/ui/cannotsavelabeldialog.ui +modules/swriter/ui/captiondialog.ui +modules/swriter/ui/captionoptions.ui +modules/swriter/ui/cardmediumpage.ui +modules/swriter/ui/ccdialog.ui +modules/swriter/ui/characterproperties.ui +modules/swriter/ui/charurlpage.ui +modules/swriter/ui/columndialog.ui +modules/swriter/ui/columnpage.ui +modules/swriter/ui/columnwidth.ui +modules/swriter/ui/conditionpage.ui +modules/swriter/ui/converttexttable.ui +modules/swriter/ui/createaddresslist.ui +modules/swriter/ui/createauthorentry.ui +modules/swriter/ui/createautomarkdialog.ui +modules/swriter/ui/customizeaddrlistdialog.ui +modules/swriter/ui/datasourcesunavailabledialog.ui +modules/swriter/ui/dropcapspage.ui +modules/swriter/ui/dropdownfielddialog.ui +modules/swriter/ui/editcategories.ui +modules/swriter/ui/editfielddialog.ui +modules/swriter/ui/editsectiondialog.ui +modules/swriter/ui/envdialog.ui +modules/swriter/ui/exchangedatabases.ui +modules/swriter/ui/fielddialog.ui +modules/swriter/ui/findentrydialog.ui +modules/swriter/ui/flddbpage.ui +modules/swriter/ui/flddocinfopage.ui +modules/swriter/ui/flddocumentpage.ui +modules/swriter/ui/fldfuncpage.ui +modules/swriter/ui/fldrefpage.ui +modules/swriter/ui/fldvarpage.ui +modules/swriter/ui/floatingsync.ui +modules/swriter/ui/footendnotedialog.ui +modules/swriter/ui/footnoteareapage.ui +modules/swriter/ui/formatsectiondialog.ui +modules/swriter/ui/formattablepage.ui +modules/swriter/ui/frmaddpage.ui +modules/swriter/ui/frmtypepage.ui +modules/swriter/ui/frmurlpage.ui +modules/swriter/ui/indentpage.ui +modules/swriter/ui/indexentry.ui +modules/swriter/ui/infonotfounddialog.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/inputfielddialog.ui +modules/swriter/ui/insertautotextdialog.ui +modules/swriter/ui/insertbookmark.ui +modules/swriter/ui/insertbreak.ui +modules/swriter/ui/insertcaption.ui +modules/swriter/ui/insertdbcolumnsdialog.ui +modules/swriter/ui/insertfootnote.ui +modules/swriter/ui/insertscript.ui +modules/swriter/ui/insertsectiondialog.ui +modules/swriter/ui/inserttable.ui +modules/swriter/ui/labeldialog.ui +modules/swriter/ui/labelformatpage.ui +modules/swriter/ui/labeloptionspage.ui +modules/swriter/ui/mailconfigpage.ui +modules/swriter/ui/mailmerge.ui +modules/swriter/ui/mailmergedialog.ui +modules/swriter/ui/managechangessidebar.ui +modules/swriter/ui/mergeconnectdialog.ui +modules/swriter/ui/mergetabledialog.ui +modules/swriter/ui/mmaddressblockpage.ui +modules/swriter/ui/mmcreatingdialog.ui +modules/swriter/ui/mmlayoutpage.ui +modules/swriter/ui/mmmailbody.ui +modules/swriter/ui/mmoutputtypepage.ui +modules/swriter/ui/mmresultemaildialog.ui +modules/swriter/ui/mmresultprintdialog.ui +modules/swriter/ui/mmresultsavedialog.ui +modules/swriter/ui/mmsalutationpage.ui +modules/swriter/ui/mmselectpage.ui +modules/swriter/ui/mmsendmails.ui +modules/swriter/ui/newuserindexdialog.ui +modules/swriter/ui/notebookbar.ui +modules/swriter/ui/numberingnamedialog.ui +modules/swriter/ui/numparapage.ui +modules/swriter/ui/optcaptionpage.ui +modules/swriter/ui/optcomparison.ui +modules/swriter/ui/optcompatpage.ui +modules/swriter/ui/optfonttabpage.ui +modules/swriter/ui/optformataidspage.ui +modules/swriter/ui/optgeneralpage.ui +modules/swriter/ui/optredlinepage.ui +modules/swriter/ui/opttablepage.ui +modules/swriter/ui/opttestpage.ui +modules/swriter/ui/outlinenumbering.ui +modules/swriter/ui/outlinepositionpage.ui +modules/swriter/ui/paradialog.ui +modules/swriter/ui/previewzoomdialog.ui +modules/swriter/ui/printeroptions.ui +modules/swriter/ui/printmergedialog.ui +modules/swriter/ui/printmonitordialog.ui +modules/swriter/ui/printoptionspage.ui +modules/swriter/ui/privateuserpage.ui +modules/swriter/ui/querycontinuebegindialog.ui +modules/swriter/ui/querycontinueenddialog.ui +modules/swriter/ui/querydefaultcompatdialog.ui +modules/swriter/ui/queryrotateintostandarddialog.ui +modules/swriter/ui/querysavelabeldialog.ui +modules/swriter/ui/renameautotextdialog.ui +modules/swriter/ui/renameentrydialog.ui +modules/swriter/ui/renameobjectdialog.ui +modules/swriter/ui/rowheight.ui +modules/swriter/ui/saveashtmldialog.ui +modules/swriter/ui/savelabeldialog.ui +modules/swriter/ui/sectionpage.ui +modules/swriter/ui/selectaddressdialog.ui +modules/swriter/ui/selectautotextdialog.ui +modules/swriter/ui/selectblockdialog.ui +modules/swriter/ui/selectindexdialog.ui +modules/swriter/ui/selecttabledialog.ui +modules/swriter/ui/sidebarstylepresets.ui +modules/swriter/ui/sidebartheme.ui +modules/swriter/ui/sidebarwrap.ui +modules/swriter/ui/sortdialog.ui +modules/swriter/ui/splittable.ui +modules/swriter/ui/statisticsinfopage.ui +modules/swriter/ui/stringinput.ui +modules/swriter/ui/subjectdialog.ui +modules/swriter/ui/tablecolumnpage.ui +modules/swriter/ui/tablepreviewdialog.ui +modules/swriter/ui/tableproperties.ui +modules/swriter/ui/tabletextflowpage.ui +modules/swriter/ui/testmailsettings.ui +modules/swriter/ui/textgridpage.ui +modules/swriter/ui/titlepage.ui +modules/swriter/ui/tocdialog.ui +modules/swriter/ui/tocentriespage.ui +modules/swriter/ui/tocindexpage.ui +modules/swriter/ui/tocstylespage.ui +modules/swriter/ui/tokenwidget.ui +modules/swriter/ui/viewoptionspage.ui +modules/swriter/ui/warndatasourcedialog.ui +modules/swriter/ui/warnemaildialog.ui +modules/swriter/ui/wordcount.ui +modules/swriter/ui/wrapdialog.ui +modules/swriter/ui/wrappage.ui +modules/swriter/ui/indexentry.ui +modules/swriter/ui/bibliographyentry.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/floatingnavigation.ui +modules/swriter/ui/queryrotateintostandarddialog.ui diff --git a/sw/qa/unit/data/sw-dialogs-test_2.txt b/sw/qa/unit/data/sw-dialogs-test_2.txt new file mode 100644 index 000000000..9384a0a20 --- /dev/null +++ b/sw/qa/unit/data/sw-dialogs-test_2.txt @@ -0,0 +1,79 @@ +# -*- 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/. +# + +# see sw-dialogs-test.txt + +modules/swriter/ui/optcaptionpage.ui +modules/swriter/ui/optcomparison.ui +modules/swriter/ui/optcompatpage.ui +modules/swriter/ui/optfonttabpage.ui +modules/swriter/ui/optformataidspage.ui +modules/swriter/ui/optgeneralpage.ui +modules/swriter/ui/optredlinepage.ui +modules/swriter/ui/opttablepage.ui +modules/swriter/ui/opttestpage.ui +modules/swriter/ui/outlinenumbering.ui +modules/swriter/ui/outlinepositionpage.ui +modules/swriter/ui/paradialog.ui +modules/swriter/ui/previewzoomdialog.ui +modules/swriter/ui/printeroptions.ui +modules/swriter/ui/printmergedialog.ui +modules/swriter/ui/printmonitordialog.ui +modules/swriter/ui/printoptionspage.ui +modules/swriter/ui/privateuserpage.ui +modules/swriter/ui/querycontinuebegindialog.ui +modules/swriter/ui/querycontinueenddialog.ui +modules/swriter/ui/querydefaultcompatdialog.ui +modules/swriter/ui/queryrotateintostandarddialog.ui +modules/swriter/ui/querysavelabeldialog.ui +modules/swriter/ui/renameautotextdialog.ui +modules/swriter/ui/renameentrydialog.ui +modules/swriter/ui/renameobjectdialog.ui +modules/swriter/ui/rowheight.ui +modules/swriter/ui/saveashtmldialog.ui +modules/swriter/ui/savelabeldialog.ui +modules/swriter/ui/sectionpage.ui +modules/swriter/ui/selectaddressdialog.ui +modules/swriter/ui/selectautotextdialog.ui +modules/swriter/ui/selectblockdialog.ui +modules/swriter/ui/selectindexdialog.ui +modules/swriter/ui/selecttabledialog.ui +modules/swriter/ui/sidebarstylepresets.ui +modules/swriter/ui/sidebartheme.ui +modules/swriter/ui/sidebarwrap.ui +modules/swriter/ui/sortdialog.ui +modules/swriter/ui/splittable.ui +modules/swriter/ui/statisticsinfopage.ui +modules/swriter/ui/stringinput.ui +modules/swriter/ui/subjectdialog.ui +modules/swriter/ui/tablecolumnpage.ui +modules/swriter/ui/tablepreviewdialog.ui +modules/swriter/ui/tableproperties.ui +modules/swriter/ui/tabletextflowpage.ui +modules/swriter/ui/testmailsettings.ui +modules/swriter/ui/textgridpage.ui +modules/swriter/ui/titlepage.ui +modules/swriter/ui/tocdialog.ui +modules/swriter/ui/tocentriespage.ui +modules/swriter/ui/tocindexpage.ui +modules/swriter/ui/tocstylespage.ui +modules/swriter/ui/tokenwidget.ui +modules/swriter/ui/viewoptionspage.ui +modules/swriter/ui/warndatasourcedialog.ui +modules/swriter/ui/warnemaildialog.ui +modules/swriter/ui/wordcount.ui +modules/swriter/ui/wrapdialog.ui +modules/swriter/ui/wrappage.ui +modules/swriter/ui/indexentry.ui +modules/swriter/ui/bibliographyentry.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/inforeadonlydialog.ui +modules/swriter/ui/floatingnavigation.ui +modules/swriter/ui/queryrotateintostandarddialog.ui diff --git a/sw/qa/unit/sw-dialogs-test.cxx b/sw/qa/unit/sw-dialogs-test.cxx new file mode 100644 index 000000000..70584b601 --- /dev/null +++ b/sw/qa/unit/sw-dialogs-test.cxx @@ -0,0 +1,103 @@ +/* -*- 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 <sal/config.h> +#include <test/screenshot_test.hxx> +#include <rtl/bootstrap.hxx> +#include <osl/module.hxx> +#include <tools/svlibrary.h> +#include <vcl/abstdlg.hxx> + +class SwAbstractDialogFactory; + +using namespace ::com::sun::star; + +extern "C" { using Fn = SwAbstractDialogFactory * (*)(); } + // sw/source/ui/dialog/swuiexp.cxx + +/// Test opening a dialog in sw +class SwDialogsTest : public ScreenshotTest +{ +private: + css::uno::Reference<css::lang::XComponent> component_; + osl::Module libSwui_; + + /// 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<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override; + +public: + SwDialogsTest(); + + void setUp() override; + + void tearDown() override; + + // try to open a dialog + void openAnyDialog(); + + CPPUNIT_TEST_SUITE(SwDialogsTest); + CPPUNIT_TEST(openAnyDialog); + CPPUNIT_TEST_SUITE_END(); +}; + +SwDialogsTest::SwDialogsTest() +{ +} + +void SwDialogsTest::setUp() +{ + ScreenshotTest::setUp(); + // Make sure the sw library's global pSwResMgr is initialized: + component_ = loadFromDesktop( + "private:factory/swriter", "com.sun.star.text.TextDocument"); + // Make sure the swui library's global pSwResMgr is initialized + // (alternatively to dynamically loading the library, SwCreateDialogFactory + // could be declared in an include file and this CppunitTest link against + // the swui library): + OUString url("${LO_LIB_DIR}/" SVLIBRARY("swui")); + rtl::Bootstrap::expandMacros(url); //TODO: detect failure + CPPUNIT_ASSERT(libSwui_.load(url, SAL_LOADMODULE_GLOBAL)); + auto fn = reinterpret_cast<Fn>( + libSwui_.getFunctionSymbol("SwCreateDialogFactory")); + CPPUNIT_ASSERT(fn != nullptr); + (*fn)(); +} + +void SwDialogsTest::tearDown() +{ + component_->dispose(); + ScreenshotTest::tearDown(); +} + +void SwDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/) +{ + // fill map of known dialogs +} + +VclPtr<VclAbstractDialog> SwDialogsTest::createDialogByID(sal_uInt32 /*nID*/) +{ + return nullptr; +} + +void SwDialogsTest::openAnyDialog() +{ + /// process input file containing the UXMLDescriptions of the dialogs to dump + processDialogBatchFile("sw/qa/unit/data/sw-dialogs-test.txt"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/unit/sw-dialogs-test_2.cxx b/sw/qa/unit/sw-dialogs-test_2.cxx new file mode 100644 index 000000000..a925a8e9c --- /dev/null +++ b/sw/qa/unit/sw-dialogs-test_2.cxx @@ -0,0 +1,94 @@ +/* -*- 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 <sal/config.h> +#include <test/screenshot_test.hxx> +#include <rtl/bootstrap.hxx> +#include <osl/module.hxx> +#include <tools/svlibrary.h> +#include <vcl/abstdlg.hxx> + +#include <swdll.hxx> + +class SwAbstractDialogFactory; + +using namespace ::com::sun::star; + +extern "C" { using Fn = SwAbstractDialogFactory * (*)(); } + // sw/source/ui/dialog/swuiexp.cxx + +/// Test opening a dialog in sw +class SwDialogsTest2 : public ScreenshotTest +{ +private: + osl::Module libSwui_; + + /// 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<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override; + +public: + SwDialogsTest2(); + + void setUp() override; + + // try to open a dialog + void openAnyDialog(); + + CPPUNIT_TEST_SUITE(SwDialogsTest2); + CPPUNIT_TEST(openAnyDialog); + CPPUNIT_TEST_SUITE_END(); +}; + +SwDialogsTest2::SwDialogsTest2() +{ +} + +void SwDialogsTest2::setUp() +{ + ScreenshotTest::setUp(); + SwGlobals::ensure(); + // Make sure the swui library's global pSwResMgr is initialized + // (alternatively to dynamically loading the library, SwCreateDialogFactory + // could be declared in an include file and this CppunitTest link against + // the swui library): + OUString url("${LO_LIB_DIR}/" SVLIBRARY("swui")); + rtl::Bootstrap::expandMacros(url); //TODO: detect failure + CPPUNIT_ASSERT(libSwui_.load(url, SAL_LOADMODULE_GLOBAL)); + auto fn = reinterpret_cast<Fn>( + libSwui_.getFunctionSymbol("SwCreateDialogFactory")); + CPPUNIT_ASSERT(fn != nullptr); + (*fn)(); +} + +void SwDialogsTest2::registerKnownDialogsByID(mapType& /*rKnownDialogs*/) +{ + // fill map of known dialogs +} + +VclPtr<VclAbstractDialog> SwDialogsTest2::createDialogByID(sal_uInt32 /*nID*/) +{ + return nullptr; +} + +void SwDialogsTest2::openAnyDialog() +{ + /// process input file containing the UXMLDescriptions of the dialogs to dump + processDialogBatchFile("sw/qa/unit/data/sw-dialogs-test_2.txt"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SwDialogsTest2); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/unit/uibase.cxx b/sw/qa/unit/uibase.cxx new file mode 100644 index 000000000..188916da3 --- /dev/null +++ b/sw/qa/unit/uibase.cxx @@ -0,0 +1,44 @@ +/* -*- 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 <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <tools/urlobj.hxx> + +#include <dbmgr.hxx> + +namespace +{ +/// Test suite for unit tests covering uibase code. +class Test : public CppUnit::TestFixture +{ +public: + void testTdf98168(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testTdf98168); + CPPUNIT_TEST_SUITE_END(); +}; + +void Test::testTdf98168() +{ + INetURLObject aURL("file:///tmp/test.xlsx"); + // This was sw::DBConnURIType::UNKNOWN, xlsx was not recognized. + CPPUNIT_ASSERT_EQUAL(sw::DBConnURIType::CALC, sw::GetDBunoType(aURL)); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |