From 267c6f2ac71f92999e969232431ba04678e7437e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 07:54:39 +0200 Subject: Adding upstream version 4:24.2.0. Signed-off-by: Daniel Baumann --- sw/qa/extras/accessibility/tdf155705.cxx | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sw/qa/extras/accessibility/tdf155705.cxx (limited to 'sw/qa/extras/accessibility/tdf155705.cxx') 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 +#include +#include +#include +#include +#include + +#include + +#include +#include + +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 xLSM2 + = linguistic2::LinguServiceManager::create(m_xContext); + uno::Reference xSpell(xLSM2->getSpellChecker(), uno::UNO_QUERY); + if (!xSpell.is() || !xSpell->hasLanguage(static_cast(LANGUAGE_ENGLISH_US))) + return; + + auto xContext = getDocumentAccessibleContext(); + CPPUNIT_ASSERT(xContext.is()); + + auto xChildContext = getAllChildren(xContext).back(); + uno::Reference 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: */ -- cgit v1.2.3