summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Sikeler <d.sikeler94@gmail.com>2014-11-26 07:09:00 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-28 11:18:11 +0000
commit94bcfb04194baa55f995de57981a293cbd1a4f5e (patch)
treebc3bcfe4ff948837956ac0409c97efa5eddad61d
parent45ca1bfc22f5d6857aeefc1e444f369cf6519805 (diff)
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/13131 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/CppunitTest_sw_uiwriter.mk1
-rw-r--r--sw/inc/swacorr.hxx3
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx32
-rw-r--r--test/Package_unittest.mk1
-rw-r--r--test/user-template/user/autocorr/acor_fr.datbin0 -> 9538 bytes
5 files changed, 36 insertions, 1 deletions
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index a5c9db081df6..589421dc560a 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
comphelper \
cppu \
cppuhelper \
+ editeng \
sal \
sfx \
svl \
diff --git a/sw/inc/swacorr.hxx b/sw/inc/swacorr.hxx
index 33598c6dbc16..ebcb30470433 100644
--- a/sw/inc/swacorr.hxx
+++ b/sw/inc/swacorr.hxx
@@ -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;
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2ed5298f6aa0..5cb57649835b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -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();
diff --git a/test/Package_unittest.mk b/test/Package_unittest.mk
index 3c0aad7330e4..77c45932780d 100644
--- a/test/Package_unittest.mk
+++ b/test/Package_unittest.mk
@@ -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:
diff --git a/test/user-template/user/autocorr/acor_fr.dat b/test/user-template/user/autocorr/acor_fr.dat
new file mode 100644
index 000000000000..d4ef5567fa17
--- /dev/null
+++ b/test/user-template/user/autocorr/acor_fr.dat
Binary files differ