summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-11-11 12:29:52 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-11-11 12:23:48 +0100
commit0d0068f7231e2839c24370c69c9176d353b1945a (patch)
tree6be99c101f71a8966d1c4a1fc13f13d116a25164
parent42f6e7e5d638bbc3b597b22dbf5689bcbe86292a (diff)
Make the unit test linear and more explicit
In the pevious state, the test would not even fail in case when import started to drop last paragraphs. Change-Id: Ic28d059ed41f88c9264743034a5ce5397fff0b2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159317 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx87
1 files changed, 47 insertions, 40 deletions
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 763a7f196c39..604cafe616aa 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1716,47 +1716,54 @@ CPPUNIT_TEST_FIXTURE(Test, test158044Tdf)
{
createSwDoc("tdf158044.rtf");
- uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
- uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
- uno::UNO_QUERY);
- uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
- int paraIndex = 0;
- while (xParaEnum->hasMoreElements())
{
- uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
- sal_Int16 adjust = getProperty<sal_Int16>(xPropertySet, "ParaAdjust");
- Color fillColor = getProperty<Color>(xPropertySet, "FillColor");
- drawing::FillStyle fillStyle = getProperty<drawing::FillStyle>(xPropertySet, "FillStyle");
- uno::Sequence<style::TabStop> tabStops
- = getProperty<uno::Sequence<style::TabStop>>(xPropertySet, "ParaTabStops");
- switch (paraIndex)
- {
- case 0:
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops.getLength());
- break;
- case 1:
- CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
- CPPUNIT_ASSERT_EQUAL(Color(0xffffff), fillColor);
- break;
- case 2:
- CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust);
- break;
- case 3:
- CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops.getLength());
- break;
- case 4:
- CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
- CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, fillStyle);
- CPPUNIT_ASSERT_EQUAL(Color(0xff0000), fillColor);
- break;
- case 5:
- CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
- CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
- break;
- default:
- break;
- }
- ++paraIndex;
+ auto xPara(getParagraph(1));
+ auto tabStops = getProperty<uno::Sequence<style::TabStop>>(xPara, "ParaTabStops");
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), tabStops.getLength());
+ }
+
+ {
+ auto xPara(getParagraph(2));
+ auto fillColor = getProperty<Color>(xPara, "FillColor");
+ auto fillStyle = getProperty<drawing::FillStyle>(xPara, "FillStyle");
+
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
+ CPPUNIT_ASSERT_EQUAL(Color(0xffffff), fillColor);
+ }
+
+ {
+ auto xPara(getParagraph(3));
+ auto adjust = getProperty<sal_Int16>(xPara, "ParaAdjust");
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(0), adjust);
+ }
+
+ {
+ auto xPara(getParagraph(4));
+ auto tabStops = getProperty<uno::Sequence<style::TabStop>>(xPara, "ParaTabStops");
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), tabStops.getLength());
+ }
+
+ {
+ auto xPara(getParagraph(5));
+ auto fillColor = getProperty<Color>(xPara, "FillColor");
+ auto fillStyle = getProperty<drawing::FillStyle>(xPara, "FillStyle");
+ auto tabStops = getProperty<uno::Sequence<style::TabStop>>(xPara, "ParaTabStops");
+
+ CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, fillStyle);
+ CPPUNIT_ASSERT_EQUAL(Color(0xff0000), fillColor);
+ }
+
+ {
+ auto xPara(getParagraph(6));
+ auto fillStyle = getProperty<drawing::FillStyle>(xPara, "FillStyle");
+ auto tabStops = getProperty<uno::Sequence<style::TabStop>>(xPara, "ParaTabStops");
+
+ CPPUNIT_ASSERT_LESS(sal_Int32(2), tabStops.getLength());
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, fillStyle);
}
}
// tests should only be added to rtfIMPORT *if* they fail round-tripping in rtfEXPORT