diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-02 18:02:20 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-03 20:05:29 +0200 |
commit | acfda3dd7cab2a27780a162310bd8a457f9bfa33 (patch) | |
tree | 8dd23edf17e9d3840351f7fe8354f130be3e89f6 /sw/qa | |
parent | 946f3f491d3f7e47be6c5b943e725009b4cf2d16 (diff) |
AutoText: first tests & windows fix
First tests for AutoText DOCX import:
+ checking if nothing will be imported when
there is no AutoText, only normal content
+ checking count of loaded entries
+ checking names of entries
+ checking first and last paragraph
Windows fix: Added swdocxreader to msword library
Change-Id: I3cf02572dd85e72b1566ce523e373753a4bd346c
Reviewed-on: https://gerrit.libreoffice.org/37176
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/data/autotext-empty.dotx | bin | 0 -> 11390 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/data/autotext-multiple.dotx | bin | 0 -> 18470 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 61 |
3 files changed, 61 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/autotext-empty.dotx b/sw/qa/extras/uiwriter/data/autotext-empty.dotx Binary files differnew file mode 100644 index 000000000000..0d9f51dc2a4a --- /dev/null +++ b/sw/qa/extras/uiwriter/data/autotext-empty.dotx diff --git a/sw/qa/extras/uiwriter/data/autotext-multiple.dotx b/sw/qa/extras/uiwriter/data/autotext-multiple.dotx Binary files differnew file mode 100644 index 000000000000..83b083992a08 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/autotext-multiple.dotx diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 2b4764b7b998..89229db942a4 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -120,6 +120,8 @@ public: void testFdo70807(); void testImportRTF(); void testExportRTF(); + void testDOCXAutoTextEmpty(); + void testDOCXAutoTextMultiple(); void testTdf67238(); void testFdo75110(); void testFdo75898(); @@ -248,6 +250,8 @@ public: CPPUNIT_TEST(testFdo70807); CPPUNIT_TEST(testImportRTF); CPPUNIT_TEST(testExportRTF); + CPPUNIT_TEST(testDOCXAutoTextEmpty); + CPPUNIT_TEST(testDOCXAutoTextMultiple); CPPUNIT_TEST(testTdf67238); CPPUNIT_TEST(testFdo75110); CPPUNIT_TEST(testFdo75898); @@ -370,6 +374,7 @@ public: private: SwDoc* createDoc(const char* pName = nullptr); + SwTextBlocks* readDOCXAutotext(const OUString& sFileName, bool bEmpty = false); }; SwDoc* SwUiWriterTest::createDoc(const char* pName) @@ -384,6 +389,23 @@ SwDoc* SwUiWriterTest::createDoc(const char* pName) return pTextDoc->GetDocShell()->GetDoc(); } +SwTextBlocks* SwUiWriterTest::readDOCXAutotext(const OUString& sFileName, bool bEmpty) +{ + OUString rURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + sFileName; + + SfxMedium* pSrcMed = new SfxMedium(rURL, StreamMode::STD_READ); + SwDoc* pDoc = createDoc(); + + SwReader aReader(*pSrcMed, rURL, pDoc); + Reader* pDOCXReader = SwReaderWriter::GetDOCXReader(); + SwTextBlocks* pGlossary = new SwTextBlocks(rURL); + + CPPUNIT_ASSERT(pDOCXReader != nullptr); + CPPUNIT_ASSERT_EQUAL(!bEmpty, aReader.ReadGlossaries(*pDOCXReader, *pGlossary, false)); + + return pGlossary; +} + //Replacement tests static void lcl_selectCharacters(SwPaM& rPaM, sal_Int32 first, sal_Int32 end) @@ -745,6 +767,45 @@ void SwUiWriterTest::testExportRTF() CPPUNIT_ASSERT(aData.endsWith("bbb}" SAL_NEWLINE_STRING "}")); } +void SwUiWriterTest::testDOCXAutoTextEmpty() +{ + // file contains normal content but no AutoText + SwTextBlocks* pGlossary = readDOCXAutotext("autotext-empty.dotx", true); + CPPUNIT_ASSERT(pGlossary != nullptr); +} + +void SwUiWriterTest::testDOCXAutoTextMultiple() +{ + // file contains three AutoText entries + SwTextBlocks* pGlossary = readDOCXAutotext("autotext-multiple.dotx"); + + // check entries count + CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, pGlossary->GetCount()); + + // check names of entries, sorted order + CPPUNIT_ASSERT_EQUAL(OUString("Anothercomplex"), pGlossary->GetLongName(0)); + CPPUNIT_ASSERT_EQUAL(OUString("Multiple"), pGlossary->GetLongName(1)); + CPPUNIT_ASSERT_EQUAL(OUString("Second Autotext"), pGlossary->GetLongName(2)); + + // check if previously loaded content is correct (eg. doesn't contain title) + SwDoc* pDoc = pGlossary->GetDoc(); + CPPUNIT_ASSERT(pDoc != nullptr); + + SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent()); + SwNodeIndex aStart(*aDocEnd.GetNode().StartOfSectionNode(), 1); + + CPPUNIT_ASSERT(aStart < aDocEnd); + + // first line + SwNode& rNode = aStart.GetNode(); + CPPUNIT_ASSERT_EQUAL(OUString("Another "), rNode.GetTextNode()->GetText()); + + // last line + SwNodeIndex aLast(*aDocEnd.GetNode().EndOfSectionNode(), -1); + SwNode& rLastNode = aLast.GetNode(); + CPPUNIT_ASSERT_EQUAL(OUString("complex"), rLastNode.GetTextNode()->GetText()); +} + void SwUiWriterTest::testFdo74981() { // create a document with an input field |