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 --- svtools/qa/unit/GraphicObjectTest.cxx | 57 +++++++ svtools/qa/unit/data/svtools-dialogs-test.txt | 43 +++++ svtools/qa/unit/svtools-dialogs-test.cxx | 61 +++++++ svtools/qa/unit/testHtmlReader.cxx | 104 ++++++++++++ svtools/qa/unit/testHtmlWriter.cxx | 224 ++++++++++++++++++++++++++ svtools/qa/unoapi/knownissues.xcl | 53 ++++++ svtools/qa/unoapi/svtools.sce | 30 ++++ 7 files changed, 572 insertions(+) create mode 100644 svtools/qa/unit/GraphicObjectTest.cxx create mode 100644 svtools/qa/unit/data/svtools-dialogs-test.txt create mode 100644 svtools/qa/unit/svtools-dialogs-test.cxx create mode 100644 svtools/qa/unit/testHtmlReader.cxx create mode 100644 svtools/qa/unit/testHtmlWriter.cxx create mode 100644 svtools/qa/unoapi/knownissues.xcl create mode 100644 svtools/qa/unoapi/svtools.sce (limited to 'svtools/qa') diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx new file mode 100644 index 000000000..766baea6b --- /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 +#include + +#include + +#include +#include +#include + +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 000000000..a072220f2 --- /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 000000000..974cf5347 --- /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 +#include +#include + +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 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 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 000000000..37f74e903 --- /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 +#include +#include +#include +#include + +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("\nhello"); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + tools::SvRef xParser = new TestHTMLParser(aStream); + xParser->CallParser(); + + // This was ' 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

bbb"); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + tools::SvRef xParser = new TestHTMLParser(aStream); + xParser->SetNamespace(u"reqif-xhtml"); + xParser->CallParser(); + + // This was 2,

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("AC"); + aStream.WriteBytes(aDocument.getStr(), aDocument.getLength()); + aStream.Seek(0); + + // When parsing that HTML: + tools::SvRef 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 000000000..702bf6446 --- /dev/null +++ b/svtools/qa/unit/testHtmlWriter.cxx @@ -0,0 +1,224 @@ +/* -*- 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 +#include +#include + +namespace +{ +OString extractFromStream(SvMemoryStream& rStream) +{ + rStream.WriteChar('\0'); + rStream.FlushBuffer(); + rStream.Seek(STREAM_SEEK_TO_BEGIN); + return static_cast(rStream.GetData()); +} +} + +class Test : public CppUnit::TestFixture +{ +}; + +CPPUNIT_TEST_FIXTURE(Test, testSingleElement) +{ + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + CPPUNIT_ASSERT_EQUAL(OString(""), aString); + } + + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.single("abc"); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); + } +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithAttributes) +{ + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.attribute("x", "y"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); + } + + { + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.attribute("x", "y"); + aHtml.attribute("q", "w"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); + } +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithContent) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testSingleElementWithContentAndAttributes) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.attribute("x", "y"); + aHtml.attribute("q", "w"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testNested) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.start("xyz"); + aHtml.end(); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testNamespace) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream, "reqif-xhtml"); + aHtml.prettyPrint(false); + aHtml.single("br"); + + OString aString = extractFromStream(aStream); + + // This was
, namespace request was ignored. + CPPUNIT_ASSERT_EQUAL(OString(""), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testAttributeValues) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.attribute("one", "one"); + aHtml.attribute("two", u"two"); + aHtml.attribute("three", sal_Int32(12)); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString(""), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testCharacters) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("abc"); + aHtml.characters("hello"); + aHtml.end(); + + OString aString = extractFromStream(aStream); + + CPPUNIT_ASSERT_EQUAL(OString("hello"), aString); +} + +CPPUNIT_TEST_FIXTURE(Test, testExactElementEnd) +{ + SvMemoryStream aStream; + + HtmlWriter aHtml(aStream); + aHtml.prettyPrint(false); + aHtml.start("start"); + aHtml.start("a"); + CPPUNIT_ASSERT(aHtml.end("a")); + aHtml.start("b"); + CPPUNIT_ASSERT(!aHtml.end("c")); + CPPUNIT_ASSERT(aHtml.end("start")); + + OString aString = extractFromStream(aStream); + CPPUNIT_ASSERT_EQUAL(OString(""), 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"); + 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: + // - Actual : + // i.e. attribute value was not encoded in HTML, but it was in e.g. XML. + CPPUNIT_ASSERT_EQUAL(OString(""), 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 000000000..f8c79ca13 --- /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 000000000..a5ab4ebfa --- /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 -- cgit v1.2.3