From 4be9bd0595cec36b6a22ca12b48661e080a5a1d8 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 17 Oct 2023 11:13:07 +0200 Subject: tdf#157442: sw_uiwriter6: Add unittest gerrit_mac fails with [_RUN_____] testTdf157442::TestBody Error: a unit test failed, please do one of: make CppunitTest_sw_uiwriter6 CPPUNITTRACE="lldb --" # for interactive debugging on macOS make CppunitTest_sw_uiwriter6 VALGRIND=memcheck # for memory checking You can limit the execution to just one particular test by: make CppunitTest_sw_uiwriter6 CPPUNIT_TEST_NAME="testXYZ" ...above mentioned params... so disable it for now on mac Change-Id: Iaf51987010a976a3a38f264d6b45c8cc6eb7f283 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158079 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/extras/uiwriter/uiwriter6.cxx | 43 +++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'sw/qa/extras/uiwriter/uiwriter6.cxx') diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index ac5155f429a9..3d4b6e3d8d8a 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -1687,9 +1688,47 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603) } } -CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf65535) +#if !defined(MACOSX) +CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157442) { + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + const SwViewOption* pOpt = pWrtShell->GetViewOptions(); + uno::Sequence params + = comphelper::InitPropertySequence({ { "Enable", uno::Any(true) } }); + dispatchCommand(mxComponent, ".uno:SpellOnline", params); + + // Automatic Spell Checking is enabled + CPPUNIT_ASSERT(pOpt->IsOnlineSpell()); + + // check available en_US dictionary and test spelling with it + uno::Reference xLngSvcMgr(GetLngSvcMgr_Impl()); + uno::Reference xSpell; + xSpell.set(xLngSvcMgr->getSpellChecker(), UNO_QUERY); + LanguageType eLang = LanguageTag::convertToLanguageType(lang::Locale("en", "US", OUString())); + if (xSpell.is() && xSpell->hasLanguage(static_cast(eLang))) + { + uno::Reference xLinguProperties( + LinguMgr::GetLinguPropertySet()); + + // Spell with digits is disabled by default + CPPUNIT_ASSERT_EQUAL(sal_False, xLinguProperties->getIsSpellWithDigits()); + + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + emulateTyping(*pTextDoc, u"ErrorError Treee2 "); + SwCursorShell* pShell(pDoc->GetEditShell()); + SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode(); + + // Without the fix in place, this test would have crashed because GetWrong() returns nullptr + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetWrong()->Count()); + } +} +#endif + #if !defined(MACOSX) +CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf65535) +{ createSwDoc("tdf65535.fodt"); SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); @@ -1755,8 +1794,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf65535) } // This was false (lost comment with spelling replacement) CPPUNIT_ASSERT_EQUAL(OString("with comment"), sCommentText); -#endif } +#endif CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testRedlineAutoCorrect) { -- cgit