[Libreoffice-commits] core.git: sw/qa

Justin Luth justin_luth at sil.org
Thu Jun 30 06:21:19 UTC 2016


 sw/qa/extras/rtfexport/rtfexport.cxx |   51 +++++++++++++++++++++++++++++++----
 1 file changed, 46 insertions(+), 5 deletions(-)

New commits:
commit 8448d0930177da0014b7faa99bb124227ae1c16e
Author: Justin Luth <justin_luth at sil.org>
Date:   Tue Jun 28 07:08:28 2016 +0300

    remove pageStyle name dependencies from rtfexport
    
    It was not the intention of these unittests
    to specify the name of the style.
    Better not to hardcode a "random" name in a unit test.
    
    Change-Id: Ic071bf42dc45c4fa831fec433e3c02b161b4268c
    Reviewed-on: https://gerrit.libreoffice.org/26734
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index f7a272d..6b0cc5c 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -1012,34 +1012,75 @@ DECLARE_RTFEXPORT_TEST(testCustomDocProps, "custom-doc-props.rtf")
 
 DECLARE_RTFEXPORT_TEST(testTdf65642, "tdf65642.rtf")
 {
+
+    uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
     // The second page's numbering type: this was style::NumberingType::ARABIC.
-    CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_UPPER_LETTER_N, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_UPPER_LETTER_N, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
     // The second page's restart value: this was 0.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty<sal_Int32>(getParagraph(2), "PageNumberOffset"));
 }
 
 DECLARE_RTFEXPORT_TEST(testPgnlcltr, "pgnlcltr.rtf")
 {
+    uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
     // The second page's numbering type: this was style::NumberingType::ARABIC.
-    CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_LOWER_LETTER_N, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_LOWER_LETTER_N, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
 }
 
 DECLARE_RTFEXPORT_TEST(testPgnucrm, "pgnucrm.rtf")
 {
+    uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
     // The second page's numbering type: this was style::NumberingType::ARABIC.
-    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ROMAN_UPPER, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ROMAN_UPPER, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
 }
 
 DECLARE_RTFEXPORT_TEST(testPgnlcrm, "pgnlcrm.rtf")
 {
+    uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
     // The second page's numbering type: this was style::NumberingType::ARABIC.
-    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ROMAN_LOWER, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ROMAN_LOWER, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
 }
 
 DECLARE_RTFEXPORT_TEST(testPgndec, "pgndec.rtf")
 {
+    uno::Reference<container::XNameAccess> xPageStyles = getStyles("PageStyles");
+    uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+    uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
+        xModel->getCurrentController(), uno::UNO_QUERY);
+    uno::Reference<text::XPageCursor> xCursor(
+        xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+    xCursor->jumpToLastPage();
+    OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName");
     // The second page's numbering type: this was style::NumberingType::ROMAN_LOWER.
-    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
+    CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, getProperty<sal_Int16>(xPageStyles->getByName(pageStyleName), "NumberingType"));
 }
 
 DECLARE_RTFEXPORT_TEST(testTdf98806, "tdf98806.rtf")


More information about the Libreoffice-commits mailing list