summaryrefslogtreecommitdiffstats
path: root/svtools/qa
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/qa')
-rw-r--r--svtools/qa/unit/GraphicObjectTest.cxx57
-rw-r--r--svtools/qa/unit/data/svtools-dialogs-test.txt43
-rw-r--r--svtools/qa/unit/svtools-dialogs-test.cxx61
-rw-r--r--svtools/qa/unit/testHtmlReader.cxx104
-rw-r--r--svtools/qa/unit/testHtmlWriter.cxx224
-rw-r--r--svtools/qa/unoapi/knownissues.xcl53
-rw-r--r--svtools/qa/unoapi/svtools.sce30
7 files changed, 572 insertions, 0 deletions
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 <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 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 <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 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 <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>");
+ 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");
+ 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 &uuml; &lt;]]>C");
+ 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 &uuml; &lt;
+ // - Actual :
+ // i.e. the content inside CDATA was lost.
+ CPPUNIT_ASSERT_EQUAL(OUString("B &uuml; &lt;"), 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 <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");
+ aHtml.end();
+
+ OString aString = extractFromStream(aStream);
+ CPPUNIT_ASSERT_EQUAL(OString("<abc/>"), aString);
+ }
+
+ {
+ SvMemoryStream aStream;
+
+ HtmlWriter aHtml(aStream);
+ aHtml.prettyPrint(false);
+ aHtml.single("abc");
+
+ OString aString = extractFromStream(aStream);
+
+ CPPUNIT_ASSERT_EQUAL(OString("<abc/>"), 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("<abc x=\"y\"/>"), 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("<abc x=\"y\" q=\"w\"/>"), 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("<abc/>"), 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("<abc x=\"y\" q=\"w\"/>"), 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("<abc><xyz/></abc>"), 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 <br/>, namespace request was ignored.
+ CPPUNIT_ASSERT_EQUAL(OString("<reqif-xhtml:br/>"), 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("<abc one=\"one\" two=\"two\" three=\"12\"/>"), 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("<abc>hello</abc>"), 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("<start><a/><b/></start>"), 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: <element attribute="a&amp;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(OString("<element attribute=\"a&amp;b\"/>"), 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