diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-12-15 10:41:05 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-12-28 12:35:36 +0100 |
commit | d5fa04b4e4e030c3d0f362c46a290da428deccc2 (patch) | |
tree | 9375b66b562d3b1b322e63b98065c6290b96f984 /sw | |
parent | a9a1602affde43f2d910e9d63d36d42ebeb824d9 (diff) |
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@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_core_accessibilitycheck.mk | 69 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 40 | ||||
-rw-r--r-- | sw/qa/core/accessibilitycheck/data/DocumentTest.odt | bin | 0 -> 9338 bytes | |||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/inc/AccessibilityCheck.hxx | 2 |
6 files changed, 114 insertions, 4 deletions
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 Binary files differnew file mode 100644 index 000000000000..65b9a7c2fd46 --- /dev/null +++ b/sw/qa/core/accessibilitycheck/data/DocumentTest.odt 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; |