summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-04-22 04:43:23 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-04-30 15:18:25 +0000
commit320ae3dba8b95a1286d579c37b33b34116c5bb5b (patch)
tree6fef08c3cfb11a999ff23b95c32ec66b207d2149
parente070fa3eab9cef868aab38643060e20ae0c77b26 (diff)
Fix tdf#96515 unit test
This also makes the test font independent, as it just tests the growth and shrink of the first page in "HideWhitespace" mode. Change-Id: I65d6b7c761939679f72fa24c744f1df23f8ba321 Reviewed-on: https://gerrit.libreoffice.org/24520 Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> Tested-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 01c6500a0b6b..11a08246c787 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -3355,6 +3355,7 @@ void SwUiWriterTest::testTdf96515()
SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
aViewOptions.SetHideWhitespaceMode(true);
pWrtShell->ApplyViewOptions(aViewOptions);
+ CPPUNIT_ASSERT(pWrtShell->GetViewOptions()->IsWhitespaceHidden());
// Insert a new paragraph at the end of the document.
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
@@ -3391,24 +3392,29 @@ void SwUiWriterTest::testTdf96536()
SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
aViewOptions.SetHideWhitespaceMode(true);
pWrtShell->ApplyViewOptions(aViewOptions);
+ CPPUNIT_ASSERT(pWrtShell->GetViewOptions()->IsWhitespaceHidden());
// Insert a page break and go back to the first page.
pWrtShell->InsertPageBreak();
pWrtShell->SttEndDoc(/*bStt=*/true);
+ calcLayout();
+ sal_Int32 nSingleParaPageHeight = parseDump("/root/page[1]/infos/bounds", "height").toInt32();
+ discardDumpedLayout();
- // Insert a new paragraph at the end of the page, and then delete it.
+ // Insert a 2nd paragraph at the end of the first page, so the page height grows at least twice...
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XParagraphAppend> xParagraphAppend(xTextDocument->getText(), uno::UNO_QUERY);
- xParagraphAppend->finishParagraph(uno::Sequence<beans::PropertyValue>());
+ const uno::Reference< text::XTextRange > xInsertPos = getRun(getParagraph(1), 1);
+ xParagraphAppend->finishParagraphInsert(uno::Sequence<beans::PropertyValue>(), xInsertPos);
calcLayout();
+ CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() >= 2 * nSingleParaPageHeight);
+ discardDumpedLayout();
+
+ // ... and then delete the 2nd paragraph, which shriks the page to the previous size.
uno::Reference<lang::XComponent> xParagraph(getParagraph(2), uno::UNO_QUERY);
xParagraph->dispose();
calcLayout();
-
- // This was 552, page did not shrink after deleting the second paragraph.
- // Expected 276, which is 12pt font size + default line spacing (15%), but
- // tolerate some difference to that.
- CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() <= 276);
+ CPPUNIT_ASSERT(parseDump("/root/page[1]/infos/bounds", "height").toInt32() == nSingleParaPageHeight);
}
void SwUiWriterTest::testTdf96479()