Kaydet (Commit) 94bcfb04 authored tarafından Daniel Sikeler's avatar Daniel Sikeler Kaydeden (comit) Caolán McNamara

Unittest for autocorrect in writer

At first we test normal replacement of wrong words.
Second part of the test is about style changes during autocorrection.
And at the end we replace a word with a table.

The rules for the autocorrection are in
test/user-template/user/autocorr/acor_fr.dat
I needed to make SwAutoCorrect public for my test.

Conflicts:
	sw/qa/extras/uiwriter/uiwriter.cxx

Change-Id: Ie753c2187c1f4eddaefe0cc428a605107112c24f
Reviewed-on: https://gerrit.libreoffice.org/13131Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 45ca1bfc
......@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
comphelper \
cppu \
cppuhelper \
editeng \
sal \
sfx \
svl \
......
......@@ -25,8 +25,9 @@
#include <com/sun/star/embed/XStorage.hpp>
#include "SwXMLTextBlocks.hxx"
#include "swdllapi.h"
class SwAutoCorrect : public SvxAutoCorrect
class SW_DLLPUBLIC SwAutoCorrect : public SvxAutoCorrect
{
using SvxAutoCorrect::PutText;
......
......@@ -22,6 +22,8 @@
#include <textboxhelper.hxx>
#include <view.hxx>
#include <hhcwrp.hxx>
#include <swacorr.hxx>
#include <editeng/acorrcfg.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
......@@ -57,6 +59,7 @@ public:
void testChineseConversionTraditionalToSimplified();
void testChineseConversionSimplifiedToTraditional();
void testFdo85554();
void testAutoCorr();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
......@@ -80,6 +83,7 @@ public:
CPPUNIT_TEST(testChineseConversionTraditionalToSimplified);
CPPUNIT_TEST(testChineseConversionSimplifiedToTraditional);
CPPUNIT_TEST(testFdo85554);
CPPUNIT_TEST(testAutoCorr);
CPPUNIT_TEST_SUITE_END();
......@@ -586,6 +590,34 @@ void SwUiWriterTest::testFdo85554()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
}
void SwUiWriterTest::testAutoCorr()
{
SwDoc* pDoc = createDoc();
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
const sal_Unicode cIns = ' ';
//Normal AutoCorrect
pWrtShell->Insert("tset");
pWrtShell->AutoCorrect(corr, cIns);
sal_uLong nIndex = pWrtShell->GetCrsr()->GetNode().GetIndex();
CPPUNIT_ASSERT_EQUAL(OUString("Test "), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
//AutoCorrect with change style to bolt
pWrtShell->Insert("Bolt");
pWrtShell->AutoCorrect(corr, cIns);
nIndex = pWrtShell->GetCrsr()->GetNode().GetIndex();
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_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -20,5 +20,6 @@ $(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/tem
$(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/standard.bau,user/autotext/en-US/standard.bau))
$(eval $(call gb_Package_add_file,test_unittest,unittest/user/autotext/en-US/crdbus50.bau,user/autotext/en-US/crdbus50.bau))
$(eval $(call gb_Package_add_file,test_unittest,unittest/user/config/soffice.cfg/.dummy,empty-directory-dummy))
$(eval $(call gb_Package_add_file,test_unittest,unittest/user/autocorr/acor_en-US.dat,user/autocorr/acor_fr.dat))
# vim: set noet sw=4 ts=4:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment