summaryrefslogtreecommitdiffstats
path: root/sw/qa/extras/accessibility/tdf155705.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/qa/extras/accessibility/tdf155705.cxx
parentInitial commit. (diff)
downloadlibreoffice-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 'sw/qa/extras/accessibility/tdf155705.cxx')
-rw-r--r--sw/qa/extras/accessibility/tdf155705.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/accessibility/tdf155705.cxx b/sw/qa/extras/accessibility/tdf155705.cxx
new file mode 100644
index 0000000000..c145c7b2c8
--- /dev/null
+++ b/sw/qa/extras/accessibility/tdf155705.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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 <com/sun/star/accessibility/XAccessibleTextMarkup.hpp>
+#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager2.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+#include <com/sun/star/text/TextMarkupType.hpp>
+#include <i18nlangtag/lang.h>
+
+#include <vcl/scheduler.hxx>
+
+#include <test/a11y/swaccessibletestbase.hxx>
+#include <test/a11y/AccessibilityTools.hxx>
+
+using namespace css;
+
+/* This test only works if spell checking is available for en_US */
+CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, tdf155705)
+{
+ loadFromSrc(u"/sw/qa/extras/accessibility/testdocuments/tdf155705.fodt"_ustr);
+
+ /* we need to give it a second to fully set up the XAccessibleTextMarkup, otherwise we get a
+ * dysfunctional one that asserts out on m_pTextFrame */
+ Scheduler::ProcessEventsToIdle();
+
+ uno::Reference<linguistic2::XLinguServiceManager2> xLSM2
+ = linguistic2::LinguServiceManager::create(m_xContext);
+ uno::Reference<linguistic2::XSpellChecker1> xSpell(xLSM2->getSpellChecker(), uno::UNO_QUERY);
+ if (!xSpell.is() || !xSpell->hasLanguage(static_cast<sal_uInt16>(LANGUAGE_ENGLISH_US)))
+ return;
+
+ auto xContext = getDocumentAccessibleContext();
+ CPPUNIT_ASSERT(xContext.is());
+
+ auto xChildContext = getAllChildren(xContext).back();
+ uno::Reference<accessibility::XAccessibleTextMarkup> xMarkup(xChildContext,
+ uno::UNO_QUERY_THROW);
+
+ // make sure the idle spellcheck pass runs
+ AccessibilityTools::Await(
+ [&xMarkup]() { return 0 < xMarkup->getTextMarkupCount(text::TextMarkupType::SPELLCHECK); });
+
+ CPPUNIT_ASSERT_GREATER(sal_Int32(0),
+ xMarkup->getTextMarkupCount(text::TextMarkupType::SPELLCHECK));
+ auto aSegment = xMarkup->getTextMarkup(0, text::TextMarkupType::SPELLCHECK);
+ CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(0), aSegment.SegmentStart);
+ CPPUNIT_ASSERT_GREATER(aSegment.SegmentStart, aSegment.SegmentEnd);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */