sw/qa/extras/uiwriter/uiwriter6.cxx | 50 ++++++++++++++++++++++ sw/qa/uitest/writer_tests4/spellDialog.py | 66 ------------------------------ 2 files changed, 50 insertions(+), 66 deletions(-)
New commits: commit 7acd895d8a6ed16611a20873f3b2216fccef0634 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Oct 17 12:59:15 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Oct 18 00:19:37 2023 +0200 tdf#45949, tdf#152492: move UITest to CppUnittest Disable the test on mac because it fails with Test name: testTdf45949::TestBody equality assertion failed - Expected: 2 - Actual : 1 Change-Id: I366eba2db939b25f70a859c6622901c1e0f55718 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158082 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 3d4b6e3d8d8a..726e16774f3f 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -1688,6 +1688,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603) } } +#if !defined(MACOSX) +CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf45949) +{ + createSwDoc(); + SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + const SwViewOption* pOpt = pWrtShell->GetViewOptions(); + uno::Sequence<beans::PropertyValue> 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<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))) + { + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + emulateTyping(*pTextDoc, u"baaad http://www.baaad.org baaad"); + SwCursorShell* pShell(pDoc->GetEditShell()); + SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode(); + + // tdf#152492: Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 3 + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetWrong()->Count()); + + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 10, /*bBasicCall=*/false); + emulateTyping(*pTextDoc, u" "); + + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode->GetWrong()->Count()); + + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 6, /*bBasicCall=*/false); + emulateTyping(*pTextDoc, u" "); + + // Move down to trigger spell checking + pWrtShell->Down(/*bSelect=*/false, 1); + + // Without the fix in place, this test would have failed with + // - Expected: 3 + // - Actual : 2 + CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), pNode->GetWrong()->Count()); + } +} +#endif + #if !defined(MACOSX) CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157442) { diff --git a/sw/qa/uitest/writer_tests4/spellDialog.py b/sw/qa/uitest/writer_tests4/spellDialog.py index 39ef8eaebe42..5fbffe93b1ca 100644 --- a/sw/qa/uitest/writer_tests4/spellDialog.py +++ b/sw/qa/uitest/writer_tests4/spellDialog.py @@ -139,72 +139,6 @@ frog, dogg, catt""" # correctly without the redline containing a deleted "o" self.assertEqual(output_text, 'goood baaadbaaed eeend') - def test_DoNotCheckURL(self): - supported_locale = self.is_supported_locale("en", "US") - if not supported_locale: - self.skipTest("no dictionary support for en_US available") - - with self.ui_test.create_doc_in_start_center("writer") as document: - cursor = document.getCurrentController().getViewCursor() - # Inserted text must be en_US, so make sure to set language in current location - cursor.CharLocale = Locale("en", "US", "") - - xMainWindow = self.xUITest.getTopFocusWindow() - xEdit = xMainWindow.getChild("writer_edit") - - # URL is recognized during typing - type_text(xEdit, "baaad http://www.baaad.org baaad baaad") - - with self.ui_test.execute_modeless_dialog_through_command(".uno:SpellingAndGrammarDialog", close_button="close") as xDialog: - checkgrammar = xDialog.getChild('checkgrammar') - if get_state_as_dict(checkgrammar)['Selected'] == 'true': - checkgrammar.executeAction('CLICK', ()) - self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') - - change = xDialog.getChild('change') - change.executeAction("CLICK", ()) - change.executeAction("CLICK", ()) - - output_text = document.Text.getString() - # This was "Baaed HTTP://www.baaad.org baaad baaad" (spelling URLs) - self.assertEqual("Baaed http://www.baaad.org baaed baaad", output_text) - - def test_tdf45949(self): - supported_locale = self.is_supported_locale("en", "US") - if not supported_locale: - self.skipTest("no dictionary support for en_US available") - - with self.ui_test.create_doc_in_start_center("writer") as document: - cursor = document.getCurrentController().getViewCursor() - # Inserted text must be en_US, so make sure to set language in current location - cursor.CharLocale = Locale("en", "US", "") - - xMainWindow = self.xUITest.getTopFocusWindow() - xEdit = xMainWindow.getChild("writer_edit") - - # URL is recognized during typing - type_text(xEdit, "baaad http://www.baaad.org baaad") - - # add spaces before and after the word "baaad" within the URL - cursor.goLeft(10, False) - type_text(xEdit, " ") - cursor.goLeft(6, False) - type_text(xEdit, " ") - - with self.ui_test.execute_modeless_dialog_through_command(".uno:SpellingAndGrammarDialog", close_button="close") as xDialog: - checkgrammar = xDialog.getChild('checkgrammar') - if get_state_as_dict(checkgrammar)['Selected'] == 'true': - checkgrammar.executeAction('CLICK', ()) - self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') - - change = xDialog.getChild('change') - change.executeAction("CLICK", ()) - change.executeAction("CLICK", ()) - - output_text = document.Text.getString() - # This was "Baaed HTTP://www. baaad .org baaed" (skipped non-URL words of hypertext) - self.assertEqual("Baaed http://www. baaed .org baaad", output_text) - def test_tdf65535(self): supported_locale = self.is_supported_locale("en", "US") if not supported_locale: