summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-12-14 10:56:43 +0100
committerLászló Németh <nemeth@numbertext.org>2022-12-17 13:53:25 +0000
commit62f0707f6ff1c0dfca67c8e3d7f6d74d1a43db87 (patch)
tree8989c018d456c876b9a45d876582f996b3c28728 /sw
parentf7b94d7ffd785470962e73408f6fd7f7728f8ec5 (diff)
tdf#124603 sw: test only if spelling dictionary is available
Unit test failed on some test platforms. Disable the test, if the spelling dictionary is not available, like spellDialog.py does. Follow-up to commit e3ae86a38d6282db0f54d3545015ed22ee868ae5 "tdf#124603 sw: pressing Up/Down triggers pending spell checking". "Building using --with-external-dict-dir=/usr/share/myspell and having en-US dictionary in there passes, but using --with-external-dict-dir=/usr/share/hunspell which doesn't exist breaks.", as reported by Christian Lohmaier. Change-Id: I53e92befe0ed35423c4c13ef3bf52f2ab3735cf4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144157 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter6.cxx80
1 files changed, 53 insertions, 27 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 21fab90ca455..305e4fa18732 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -35,6 +35,8 @@
#include <o3tl/cppunittraitshelper.hxx>
#include <swdtflvr.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/scheduler.hxx>
#include <config_fonts.h>
@@ -44,6 +46,18 @@
#include <rootfrm.hxx>
#include <unotxdoc.hxx>
#include <wrong.hxx>
+#include <com/sun/star/linguistic2/LinguServiceManager.hpp>
+#include <com/sun/star/linguistic2/XLinguProperties.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+#include <linguistic/misc.hxx>
+
+using namespace osl;
+using namespace com::sun::star;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::linguistic2;
+using namespace linguistic;
namespace
{
@@ -71,6 +85,13 @@ void emulateTyping(SwXTextDocument& rTextDoc, const std::u16string_view& rStr)
Scheduler::ProcessEventsToIdle();
}
}
+
+uno::Reference<XLinguServiceManager2> GetLngSvcMgr_Impl()
+{
+ uno::Reference<XComponentContext> xContext(comphelper::getProcessComponentContext());
+ uno::Reference<XLinguServiceManager2> xRes = LinguServiceManager::create(xContext);
+ return xRes;
+}
} //namespace
class SwUiWriterTest6 : public SwModelTestBase, public HtmlTestTools
@@ -1354,8 +1375,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testSpellOnlineParameter)
CPPUNIT_ASSERT_EQUAL(!bSet, pOpt->IsOnlineSpell());
}
-// missing spelling dictionary on Windows test platform?
-#if !defined(_WIN32)
CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603)
{
createSwDoc();
@@ -1370,39 +1389,46 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603)
CPPUNIT_ASSERT(pOpt->IsOnlineSpell());
- // Type a correct word
+ // check available en_US dictionary and test spelling with it
+ uno::Reference<XLinguServiceManager2> xLngSvcMgr(GetLngSvcMgr_Impl());
+ uno::Reference<XSpellChecker1> xSpell;
+ xSpell.set(xLngSvcMgr->getSpellChecker(), UNO_QUERY);
+ LanguageType eLang = LanguageTag::convertToLanguageType(lang::Locale("en", "US", OUString()));
+ if (xSpell.is() && xSpell->hasLanguage(static_cast<sal_uInt16>(eLang)))
+ {
+ // Type a correct word
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- emulateTyping(*pTextDoc, u"the ");
- SwCursorShell* pShell(pDoc->GetEditShell());
- SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode();
- // no bad word
- CPPUNIT_ASSERT_EQUAL(static_cast<SwWrongList*>(nullptr), pNode->GetWrong());
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ emulateTyping(*pTextDoc, u"the ");
+ SwCursorShell* pShell(pDoc->GetEditShell());
+ SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode();
+ // no bad word
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwWrongList*>(nullptr), pNode->GetWrong());
- // Create a bad word from the good: "the" -> "thex"
+ // Create a bad word from the good: "the" -> "thex"
- pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
- emulateTyping(*pTextDoc, u"x");
- // tdf#92036 pending spell checking
- bool bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
- CPPUNIT_ASSERT(bPending);
+ pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ emulateTyping(*pTextDoc, u"x");
+ // tdf#92036 pending spell checking
+ bool bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
+ CPPUNIT_ASSERT(bPending);
- // Move right, leave the bad word
+ // Move right, leave the bad word
- pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
- // tdf#92036 still pending spell checking
- bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
- CPPUNIT_ASSERT(bPending);
+ pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ // tdf#92036 still pending spell checking
+ bPending = !pNode->GetWrong() || !pNode->GetWrong()->Count();
+ CPPUNIT_ASSERT(bPending);
- // Move down to trigger spell checking
+ // Move down to trigger spell checking
- pWrtShell->Down(/*bSelect=*/false, 1);
- Scheduler::ProcessEventsToIdle();
- CPPUNIT_ASSERT(pNode->GetWrong());
- // This was 0 (pending spell checking)
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetWrong()->Count());
+ pWrtShell->Down(/*bSelect=*/false, 1);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(pNode->GetWrong());
+ // This was 0 (pending spell checking)
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetWrong()->Count());
+ }
}
-#endif
CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testRedlineAutoCorrect)
{