summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-04-07 16:48:39 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-04-08 21:06:20 +0200
commit2ed743de88da7ef70eb63fed925a7cf29980c01a (patch)
tree38f2d4a17c5b6f14810e2e9e8217f6b8d2e5a55e
parent3e7679738413054c7e6ce973380eac501bf41cf2 (diff)
sw_uiwriter: put autocorrect tests together
Change-Id: I06e720b6fccab298a866eb05403ca98152ab4c8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132679 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx109
-rw-r--r--sw/qa/extras/uiwriter/uiwriter6.cxx126
-rw-r--r--sw/qa/extras/uiwriter/uiwriter7.cxx16
3 files changed, 124 insertions, 127 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index d6e13827213b..b4b7a9eac36d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1045,115 +1045,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testFdo85554)
CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testAutoCorr)
-{
- SwDoc* pDoc = createSwDoc();
- SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
- const sal_Unicode cIns = ' ';
-
- //Normal AutoCorrect
- pWrtShell->Insert("tset");
- pWrtShell->AutoCorrect(corr, cIns);
- SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
- CPPUNIT_ASSERT_EQUAL(OUString("Test "), static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
-
- //AutoCorrect with change style to bolt
- pWrtShell->Insert("Bolt");
- pWrtShell->AutoCorrect(corr, cIns);
- const uno::Reference< text::XTextRange > xRun = getRun(getParagraph(1), 2);
- CPPUNIT_ASSERT_EQUAL(OUString("Bolt"), xRun->getString());
- CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
-
- //AutoCorrect inserts Table with 2 rows and 3 columns
- pWrtShell->Insert("4xx");
- pWrtShell->AutoCorrect(corr, cIns);
- const uno::Reference< text::XTextTable > xTable(getParagraphOrTable(2), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getColumns()->getCount());
-}
-
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf83260)
-{
- SwDoc* const pDoc(createSwDoc(DATA_DIRECTORY, "tdf83260-1.odt"));
- SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
-
- // enabled but not shown
- CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
-#if 0
- CPPUNIT_ASSERT(IDocumentRedlineAccess::IsHideChanges(
- pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
-#endif
- CPPUNIT_ASSERT(IDocumentRedlineAccess::IsRedlineOn(
- pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
- CPPUNIT_ASSERT(!pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty());
-
- // the document contains redlines that are combined with CompressRedlines()
- // if that happens during AutoCorrect then indexes in Undo are off -> crash
- pWrtShell->Insert("tset");
- pWrtShell->AutoCorrect(corr, u' ');
- sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
- auto const nActions(rUndoManager.GetUndoActionCount());
- for (auto i = nActions; 0 < i; --i)
- {
- rUndoManager.Undo();
- }
- // check that every text node has a layout frame
- for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
- {
- if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
- {
- CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
- }
- }
- for (auto i = nActions; 0 < i; --i)
- {
- rUndoManager.Redo();
- }
- for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
- {
- if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
- {
- CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
- }
- }
- for (auto i = nActions; 0 < i; --i)
- {
- rUndoManager.Undo();
- }
- for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
- {
- if (SwTextNode const*const pNode = pDoc->GetNodes()[i]->GetTextNode())
- {
- CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
- }
- }
-}
-
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf130274)
-{
- SwDoc *const pDoc(createSwDoc());
- SwWrtShell *const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
-
- CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines());
- CPPUNIT_ASSERT(!IDocumentRedlineAccess::IsRedlineOn(
- pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
-
- // "tset" may be replaced by the AutoCorrect in the test profile
- pWrtShell->Insert("tset");
- // select from left to right
- pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 4, /*bBasicCall=*/false);
- pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 4, /*bBasicCall=*/false);
-
- pWrtShell->SetRedlineFlags(pWrtShell->GetRedlineFlags() | RedlineFlags::On);
- // this would crash in AutoCorrect
- pWrtShell->AutoCorrect(corr, '.');
-
- CPPUNIT_ASSERT(!pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty());
-}
-
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testMergeDoc)
{
SwDoc* const pDoc1(createSwDoc(DATA_DIRECTORY, "merge-change1.odt"));
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index a8f27234a361..6386c3f07fc6 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -15,8 +15,6 @@
#include <wrtsh.hxx>
#include <drawdoc.hxx>
#include <view.hxx>
-#include <swacorr.hxx>
-#include <editeng/acorrcfg.hxx>
#include <com/sun/star/text/XTextColumns.hpp>
#include <svx/svdpage.hxx>
@@ -42,6 +40,7 @@
#include <test/htmltesttools.hxx>
#include <wrthtml.hxx>
#include <dbmgr.hxx>
+#include <rootfrm.hxx>
#include <unotxdoc.hxx>
namespace
@@ -1739,6 +1738,129 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133589)
CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testAutoCorr)
+{
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+
+ //Normal AutoCorrect
+ emulateTyping(*pXTextDocument, u"tset ");
+ CPPUNIT_ASSERT_EQUAL(OUString("Test "), getParagraph(1)->getString());
+
+ //AutoCorrect with change style to bolt
+ emulateTyping(*pXTextDocument, u"Bolt ");
+ const uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 2);
+ CPPUNIT_ASSERT_EQUAL(OUString("Bolt"), xRun->getString());
+ CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName"));
+
+ //AutoCorrect inserts Table with 2 rows and 3 columns
+ emulateTyping(*pXTextDocument, u"4xx ");
+ const uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getColumns()->getCount());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf130274)
+{
+ SwDoc* const pDoc(createSwDoc());
+ SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+
+ CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines());
+ CPPUNIT_ASSERT(
+ !IDocumentRedlineAccess::IsRedlineOn(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // "tset" may be replaced by the AutoCorrect in the test profile
+ emulateTyping(*pXTextDocument, u"tset");
+ // select from left to right
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 4, /*bBasicCall=*/false);
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 4, /*bBasicCall=*/false);
+
+ pWrtShell->SetRedlineFlags(pWrtShell->GetRedlineFlags() | RedlineFlags::On);
+ // this would crash in AutoCorrect
+ emulateTyping(*pXTextDocument, u".");
+
+ CPPUNIT_ASSERT(!pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf83260)
+{
+ SwDoc* const pDoc(createSwDoc(DATA_DIRECTORY, "tdf83260-1.odt"));
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+
+ // enabled but not shown
+ CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
+#if 0
+ CPPUNIT_ASSERT(IDocumentRedlineAccess::IsHideChanges(
+ pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+#endif
+ CPPUNIT_ASSERT(
+ IDocumentRedlineAccess::IsRedlineOn(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+ CPPUNIT_ASSERT(!pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty());
+
+ // the document contains redlines that are combined with CompressRedlines()
+ // if that happens during AutoCorrect then indexes in Undo are off -> crash
+ emulateTyping(*pXTextDocument, u"tset ");
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ auto const nActions(rUndoManager.GetUndoActionCount());
+ for (auto i = nActions; 0 < i; --i)
+ {
+ rUndoManager.Undo();
+ }
+ // check that every text node has a layout frame
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
+ {
+ if (SwTextNode const* const pNode = pDoc->GetNodes()[i]->GetTextNode())
+ {
+ CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
+ }
+ }
+ for (auto i = nActions; 0 < i; --i)
+ {
+ rUndoManager.Redo();
+ }
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
+ {
+ if (SwTextNode const* const pNode = pDoc->GetNodes()[i]->GetTextNode())
+ {
+ CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
+ }
+ }
+ for (auto i = nActions; 0 < i; --i)
+ {
+ rUndoManager.Undo();
+ }
+ for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
+ {
+ if (SwTextNode const* const pNode = pDoc->GetNodes()[i]->GetTextNode())
+ {
+ CPPUNIT_ASSERT(pNode->getLayoutFrame(nullptr, nullptr, nullptr));
+ }
+ }
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf74363)
+{
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ SwXTextDocument* pXTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pXTextDocument);
+ //testing autocorrect of initial capitals on start of first paragraph
+ //Inserting one all-lowercase word into the first paragraph
+ emulateTyping(*pXTextDocument, u"testing ");
+ //The word should be capitalized due to autocorrect
+ CPPUNIT_ASSERT_EQUAL(OUString("Testing "), getParagraph(1)->getString());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf143176)
{
// Hungarian test document with right-to-left paragraph setting
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx
index 15c51075c1eb..baac87c9c450 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -1307,22 +1307,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf74230)
aTempFile.EnableKillingFile();
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf74363)
-{
- SwDoc* pDoc = createSwDoc();
- SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- //testing autocorrect of initial capitals on start of first paragraph
- SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
- //Inserting one all-lowercase word into the first paragraph
- pWrtShell->Insert("testing");
- const sal_Unicode cChar = ' ';
- pWrtShell->AutoCorrect(corr, cChar);
- //The word should be capitalized due to autocorrect
- SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
- CPPUNIT_ASSERT_EQUAL(OUString("Testing "),
- static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
-}
-
CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf80663)
{
SwDoc* pDoc = createSwDoc();