diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 05:54:39 +0000 |
commit | 267c6f2ac71f92999e969232431ba04678e7437e (patch) | |
tree | 358c9467650e1d0a1d7227a21dac2e3d08b622b2 /svtools/qa | |
parent | Initial commit. (diff) | |
download | libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip |
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svtools/qa')
-rw-r--r-- | svtools/qa/unit/GraphicObjectTest.cxx | 57 | ||||
-rw-r--r-- | svtools/qa/unit/data/svtools-dialogs-test.txt | 43 | ||||
-rw-r--r-- | svtools/qa/unit/svtools-dialogs-test.cxx | 61 | ||||
-rw-r--r-- | svtools/qa/unit/testHtmlReader.cxx | 104 | ||||
-rw-r--r-- | svtools/qa/unit/testHtmlWriter.cxx | 228 | ||||
-rw-r--r-- | svtools/qa/unoapi/knownissues.xcl | 53 | ||||
-rw-r--r-- | svtools/qa/unoapi/svtools.sce | 30 |
7 files changed, 576 insertions, 0 deletions
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx new file mode 100644 index 0000000000..766baea6b1 --- /dev/null +++ b/svtools/qa/unit/GraphicObjectTest.cxx @@ -0,0 +1,57 @@ +/* -*- 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/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <test/bootstrapfixture.hxx> + +#include <com/sun/star/frame/Desktop.hpp> +#include <unotest/macros_test.hxx> +#include <comphelper/processfactory.hxx> + +using namespace css; + +namespace +{ +class GraphicObjectTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +public: + void testTdf88836(); + + virtual void setUp() override + { + test::BootstrapFixture::setUp(); + + mxDesktop.set( + css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); + } + +private: + CPPUNIT_TEST_SUITE(GraphicObjectTest); + CPPUNIT_TEST(testTdf88836); + CPPUNIT_TEST_SUITE_END(); +}; + +void GraphicObjectTest::testTdf88836() +{ + // Construction with empty bitmap -> type should be GraphicType::NONE + Graphic aGraphic = BitmapEx(Bitmap()); + CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); + aGraphic = Graphic(BitmapEx()); + CPPUNIT_ASSERT_EQUAL(int(GraphicType::NONE), int(aGraphic.GetType())); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(GraphicObjectTest); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/qa/unit/data/svtools-dialogs-test.txt b/svtools/qa/unit/data/svtools-dialogs-test.txt new file mode 100644 index 0000000000..a072220f28 --- /dev/null +++ b/svtools/qa/unit/data/svtools-dialogs-test.txt @@ -0,0 +1,43 @@ +# -*- 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 svtools 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 + +svt/ui/addresstemplatedialog.ui +svt/ui/placeedit.ui +svt/ui/printersetupdialog.ui +svt/ui/restartdialog.ui +svt/ui/graphicexport.ui +svt/ui/querydeletedialog.ui +svt/ui/javadisableddialog.ui diff --git a/svtools/qa/unit/svtools-dialogs-test.cxx b/svtools/qa/unit/svtools-dialogs-test.cxx new file mode 100644 index 0000000000..974cf5347c --- /dev/null +++ b/svtools/qa/unit/svtools-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 <sal/config.h> +#include <test/screenshot_test.hxx> +#include <vcl/abstdlg.hxx> + +using namespace ::com::sun::star; + +/// Test opening a dialog in svtools +class SvtoolsDialogsTest : 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<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override; + +public: + SvtoolsDialogsTest(); + + // try to open a dialog + void openAnyDialog(); + + CPPUNIT_TEST_SUITE(SvtoolsDialogsTest); + CPPUNIT_TEST(openAnyDialog); + CPPUNIT_TEST_SUITE_END(); +}; + +SvtoolsDialogsTest::SvtoolsDialogsTest() {} + +void SvtoolsDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/) +{ + // fill map of known dialogs +} + +VclPtr<VclAbstractDialog> SvtoolsDialogsTest::createDialogByID(sal_uInt32 /*nID*/) +{ + return nullptr; +} + +void SvtoolsDialogsTest::openAnyDialog() +{ + /// process input file containing the UXMLDescriptions of the dialogs to dump + processDialogBatchFile(u"svtools/qa/unit/data/svtools-dialogs-test.txt"); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SvtoolsDialogsTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/qa/unit/testHtmlReader.cxx b/svtools/qa/unit/testHtmlReader.cxx new file mode 100644 index 0000000000..5605060eab --- /dev/null +++ b/svtools/qa/unit/testHtmlReader.cxx @@ -0,0 +1,104 @@ +/* -*- 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 <unotest/bootstrapfixturebase.hxx> +#include <svtools/parhtml.hxx> +#include <tools/ref.hxx> +#include <tools/stream.hxx> + +namespace +{ +/// Subclass of HTMLParser that can sense the import result. +class TestHTMLParser : public HTMLParser +{ +public: + TestHTMLParser(SvStream& rStream); + virtual void NextToken(HtmlTokenId nToken) override; + /// Make this public for test purposes. + using HTMLParser::SetNamespace; + + OUString m_aDocument; + int m_nLineBreakCount = 0; + OUString m_aCdata; +}; + +TestHTMLParser::TestHTMLParser(SvStream& rStream) + : HTMLParser(rStream) +{ +} + +void TestHTMLParser::NextToken(HtmlTokenId nToken) +{ + if (nToken == HtmlTokenId::TEXTTOKEN) + m_aDocument += aToken; + else if (nToken == HtmlTokenId::LINEBREAK) + ++m_nLineBreakCount; + else if (nToken == HtmlTokenId::CDATA) + m_aCdata = aToken; +} + +/// Tests HTMLParser. +class Test : public CppUnit::TestFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(Test, testTdf114428) +{ + SvMemoryStream aStream; + OString aDocument("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<html>hello</html>"_ostr); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + tools::SvRef<TestHTMLParser> xParser = new TestHTMLParser(aStream); + xParser->CallParser(); + + // This was '<?xml version="1.0" encoding="utf-8"?> hello', XML declaration + // was not ignored. + CPPUNIT_ASSERT_EQUAL(OUString("hello"), xParser->m_aDocument.trim()); +} + +CPPUNIT_TEST_FIXTURE(Test, testLineBreak) +{ + SvMemoryStream aStream; + OString aDocument("aaa<br></br>bbb"_ostr); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + tools::SvRef<TestHTMLParser> xParser = new TestHTMLParser(aStream); + xParser->SetNamespace(u"reqif-xhtml"); + xParser->CallParser(); + + // This was 2, <br></br> was interpreted as 2 line breaks in XHTML mode. + CPPUNIT_ASSERT_EQUAL(1, xParser->m_nLineBreakCount); +} + +CPPUNIT_TEST_FIXTURE(Test, testCdata) +{ + // Given a document with CDATA: + SvMemoryStream aStream; + OString aDocument("A<![CDATA[B ü <]]>C"_ostr); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + // When parsing that HTML: + tools::SvRef<TestHTMLParser> xParser = new TestHTMLParser(aStream); + xParser->CallParser(); + + // Then make sure that we get a cdata token with the correct content: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: B ü < + // - Actual : + // i.e. the content inside CDATA was lost. + CPPUNIT_ASSERT_EQUAL(OUString("B ü <"), xParser->m_aCdata); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/qa/unit/testHtmlWriter.cxx b/svtools/qa/unit/testHtmlWriter.cxx new file mode 100644 index 0000000000..513978b1f5 --- /dev/null +++ b/svtools/qa/unit/testHtmlWriter.cxx @@ -0,0 +1,228 @@ +/* -*- 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/plugin/TestPlugIn.h> + +#include <unotest/bootstrapfixturebase.hxx> +#include <tools/stream.hxx> +#include <svtools/HtmlWriter.hxx> + +namespace +{ +OString extractFromStream(SvMemoryStream& rStream) +{ + rStream.WriteChar('\0'); + rStream.FlushBuffer(); + rStream.Seek(STREAM_SEEK_TO_BEGIN); + return static_cast<const char*>(rStream.GetData()); +} +} + +class Test : public CppUnit::TestFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(Test, testSingleElement) +{ + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.end(); + + OString aString = extractFromStream(aStream); + CPPUNIT_ASSERT_EQUAL("<abc/>"_ostr, aString); + } + + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.single("abc"_ostr); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc/>"_ostr, aString); + } +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithAttributes) +{ + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.attribute("x", "y"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc x=\"y\"/>"_ostr, aString); + } + + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.attribute("x", "y"); + aHtml.attribute("q", "w"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc x=\"y\" q=\"w\"/>"_ostr, aString); + } +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithContent) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc/>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithContentAndAttributes) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.attribute("x", "y"); + aHtml.attribute("q", "w"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc x=\"y\" q=\"w\"/>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testNested) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.start("xyz"_ostr); + aHtml.end(); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc><xyz/></abc>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testNamespace) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream, "reqif-xhtml"); + aHtml.prettyPrint(false); + aHtml.single("br"_ostr); + + OString aString = extractFromStream(aStream); + + // This was <br/>, namespace request was ignored. + CPPUNIT_ASSERT_EQUAL("<reqif-xhtml:br/>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testAttributeValues) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.attribute("one", "one"); + aHtml.attribute("two", u"two"_ustr); + aHtml.attribute("three", sal_Int32(12)); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc one=\"one\" two=\"two\" three=\"12\"/>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testCharacters) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"_ostr); + aHtml.characters("hello"); + aHtml.end(); + aHtml.characters(" "); // Should not try to close a not opened tag + aHtml.start("abc"_ostr); + aHtml.characters("world"); // Should close opening tag + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL("<abc>hello</abc> <abc>world</abc>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testExactElementEnd) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("start"_ostr); + aHtml.start("a"_ostr); + CPPUNIT_ASSERT(aHtml.end("a"_ostr)); + aHtml.start("b"_ostr); + CPPUNIT_ASSERT(!aHtml.end("c"_ostr)); + CPPUNIT_ASSERT(aHtml.end("start"_ostr)); + + OString aString = extractFromStream(aStream); + CPPUNIT_ASSERT_EQUAL("<start><a/><b/></start>"_ostr, aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testAttributeValueEncode) +{ + // Given a HTML writer: + SvMemoryStream aStream; + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + + // When writing an attribute with a value that needs encoding: + aHtml.start("element"_ostr); + aHtml.attribute("attribute", "a&b"); + aHtml.end(); + + // Then make sure that the encoding is performed: + OString aString = extractFromStream(aStream); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: <element attribute="a&b"/> + // - Actual : <element attribute="a&b"/> + // i.e. attribute value was not encoded in HTML, but it was in e.g. XML. + CPPUNIT_ASSERT_EQUAL("<element attribute=\"a&b\"/>"_ostr, aString); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/qa/unoapi/knownissues.xcl b/svtools/qa/unoapi/knownissues.xcl new file mode 100644 index 0000000000..f8c79ca136 --- /dev/null +++ b/svtools/qa/unoapi/knownissues.xcl @@ -0,0 +1,53 @@ +# +# 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 . +# + +### i85237 ### +svtools.AccessibleBrowseBox::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i85238 ### +svtools.AccessibleBrowseBox::com::sun::star::accessibility::XAccessibleContext + +### i85239 ### +svtools.AccessibleBrowseBoxHeaderBar::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i85240 ### +svtools.AccessibleTabBar::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i85244 ### +svtools.AccessibleTabBarPage::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i85245 ### +svtools.AccessibleBrowseBoxTableCell +# -> test is disabled in svtools.sce + +### i85246 ### +svtools.AccessibleTabBarPageList +# -> test is disabled in svtools.sce + +### i88276 ### +svtools.AccessibleIconChoiceCtrlEntry +# -> test is disabled in svtools.sce + +### i88296 ### +svtools.AccessibleTreeListBox::com::sun::star::accessibility::XAccessibleEventBroadcaster + +### i88300 ### +svtools.AccessibleTreeListBoxEntry::com::sun::star::accessibility::XAccessibleText + +### i88647 ### +svtools.AccessibleTabBarPage diff --git a/svtools/qa/unoapi/svtools.sce b/svtools/qa/unoapi/svtools.sce new file mode 100644 index 0000000000..a5ab4ebfaf --- /dev/null +++ b/svtools/qa/unoapi/svtools.sce @@ -0,0 +1,30 @@ +# +# 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 . +# + +#i88276 -o svtools.AccessibleIconChoiceCtrlEntry +#i88647 -o svtools.AccessibleTabBarPage +#i110988 -o svtools.AccessibleBrowseBox +#i110988 -o svtools.AccessibleBrowseBoxHeaderBar +#i110988 -o svtools.AccessibleBrowseBoxHeaderCell +#i110988 -o svtools.AccessibleBrowseBoxTable +#i85245 -o svtools.AccessibleBrowseBoxTableCell +#i88276 -o svtools.AccessibleIconChoiceCtrl +-o svtools.AccessibleTabBar +#i85246 -o svtools.AccessibleTabBarPageList +#i110988 -o svtools.AccessibleTreeListBox +#i110988 -o svtools.AccessibleTreeListBoxEntry |