[Libreoffice-commits] core.git: include/svx sw/CppunitTest_sw_core_accessibilitycheck.mk sw/Module_sw.mk sw/qa sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 28 11:36:09 UTC 2019


 include/svx/AccessibilityIssue.hxx                       |   14 +++
 sw/CppunitTest_sw_core_accessibilitycheck.mk             |   69 +++++++++++++++
 sw/Module_sw.mk                                          |    1 
 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx |   40 ++++++++
 sw/qa/core/accessibilitycheck/data/DocumentTest.odt      |binary
 sw/source/core/access/AccessibilityCheck.cxx             |    6 -
 sw/source/core/inc/AccessibilityCheck.hxx                |    2 
 7 files changed, 128 insertions(+), 4 deletions(-)

New commits:
commit d5fa04b4e4e030c3d0f362c46a290da428deccc2
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Dec 15 10:41:05 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Dec 28 12:35:36 2019 +0100

    acc. check: introduce AccessibilityCheckTest + document test
    
    This adds AccessibilityCheckTest to test that AccessibilityCheck
    returns correct issues for documents. This in addition adds 2
    tests for document title and document/style language.
    
    Change-Id: I71f3b0de0af7a08507f2b90b46847010948bc8cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85856
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/AccessibilityIssue.hxx b/include/svx/AccessibilityIssue.hxx
index 894439c54fec..9d9143aef683 100644
--- a/include/svx/AccessibilityIssue.hxx
+++ b/include/svx/AccessibilityIssue.hxx
@@ -15,9 +15,23 @@
 
 namespace svx
 {
+enum class AccessibilityIssueID
+{
+    UNSPECIFIED, // TODO: remove - temporary
+    DOCUMENT_TITLE,
+    DOCUMENT_LANGUAGE,
+    STYLE_LANGUAGE
+};
+
 class SVX_DLLPUBLIC AccessibilityIssue
 {
 public:
+    AccessibilityIssue(AccessibilityIssueID eIssueID = AccessibilityIssueID::UNSPECIFIED)
+        : m_eIssueID(eIssueID)
+    {
+    }
+
+    AccessibilityIssueID m_eIssueID;
     OUString m_aIssueText;
 };
 }
diff --git a/sw/CppunitTest_sw_core_accessibilitycheck.mk b/sw/CppunitTest_sw_core_accessibilitycheck.mk
new file mode 100644
index 000000000000..3927603c400b
--- /dev/null
+++ b/sw/CppunitTest_sw_core_accessibilitycheck.mk
@@ -0,0 +1,69 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_core_accessibilitycheck))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_accessibilitycheck))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_accessibilitycheck, \
+    sw/qa/core/accessibilitycheck/AccessibilityCheckTest \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_accessibilitycheck, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    svx \
+    sfx \
+    sw \
+    test \
+    unotest \
+    utl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_accessibilitycheck,\
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_accessibilitycheck,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/source/uibase/inc \
+    -I$(SRCDIR)/sw/qa/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_accessibilitycheck,\
+    udkapi \
+    offapi \
+    oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_accessibilitycheck))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_accessibilitycheck))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_accessibilitycheck,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_accessibilitycheck,\
+    officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_accessibilitycheck))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_accessibilitycheck, \
+    modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_accessibilitycheck))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 101d3b73921b..17b60a0eec14 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -105,6 +105,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_apitests \
     CppunitTest_sw_unowriter \
     CppunitTest_sw_core_text \
+    CppunitTest_sw_core_accessibilitycheck \
 ))
 
 ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
new file mode 100644
index 000000000000..1f114c004a6c
--- /dev/null
+++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx
@@ -0,0 +1,40 @@
+/* -*- 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 <swmodeltestbase.hxx>
+#include <wrtsh.hxx>
+#include <AccessibilityCheck.hxx>
+
+class AccessibilityCheckTest : public SwModelTestBase
+{
+public:
+    SwDoc* createDoc(const char* pName = nullptr)
+    {
+        load("/sw/qa/core/accessibilitycheck/data/", pName);
+        SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+        CPPUNIT_ASSERT(pTextDoc);
+        return pTextDoc->GetDocShell()->GetDoc();
+    }
+};
+
+CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheck)
+{
+    SwDoc* pDoc = createDoc("DocumentTest.odt");
+    CPPUNIT_ASSERT(pDoc);
+    sw::AccessibilityCheck aCheck(pDoc);
+    aCheck.check();
+    auto& aIssues = aCheck.getIssueCollecton();
+    CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size());
+    CPPUNIT_ASSERT_EQUAL(svx::AccessibilityIssueID::DOCUMENT_LANGUAGE, aIssues[0].m_eIssueID);
+    CPPUNIT_ASSERT_EQUAL(svx::AccessibilityIssueID::DOCUMENT_TITLE, aIssues[1].m_eIssueID);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/accessibilitycheck/data/DocumentTest.odt b/sw/qa/core/accessibilitycheck/data/DocumentTest.odt
new file mode 100644
index 000000000000..65b9a7c2fd46
Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/DocumentTest.odt differ
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index cce19f896e47..5608e29dff47 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -287,7 +287,7 @@ public:
         LanguageType eLanguage = rLang.GetLanguage();
         if (eLanguage == LANGUAGE_NONE)
         {
-            svx::AccessibilityIssue aIssue;
+            svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::DOCUMENT_LANGUAGE);
             aIssue.m_aIssueText = sDocumentDefaultLanguage;
             m_rIssueCollection.push_back(aIssue);
         }
@@ -298,7 +298,7 @@ public:
                 const SwAttrSet& rAttrSet = pTextFormatCollection->GetAttrSet();
                 if (rAttrSet.GetLanguage(false).GetLanguage() == LANGUAGE_NONE)
                 {
-                    svx::AccessibilityIssue aIssue;
+                    svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::STYLE_LANGUAGE);
                     OUString sName = pTextFormatCollection->GetName();
                     aIssue.m_aIssueText = sStyleNoLanguage.replaceAll("%STYLE_NAME%", sName);
                     m_rIssueCollection.push_back(aIssue);
@@ -328,7 +328,7 @@ public:
             OUString sTitle = xDocumentProperties->getTitle();
             if (sTitle.isEmpty())
             {
-                svx::AccessibilityIssue aIssue;
+                svx::AccessibilityIssue aIssue(svx::AccessibilityIssueID::DOCUMENT_TITLE);
                 aIssue.m_aIssueText = sDocumentTitle;
                 m_rIssueCollection.push_back(aIssue);
             }
diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx
index 9e77ca15e125..30bcb90e00a1 100644
--- a/sw/source/core/inc/AccessibilityCheck.hxx
+++ b/sw/source/core/inc/AccessibilityCheck.hxx
@@ -16,7 +16,7 @@
 
 namespace sw
 {
-class AccessibilityCheck final : public svx::AccessibilityCheck
+class SW_DLLPUBLIC AccessibilityCheck final : public svx::AccessibilityCheck
 {
 private:
     SwDoc* m_pDoc;


More information about the Libreoffice-commits mailing list