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

Varun varun.dhall at studentpartner.com
Thu Jul 30 12:33:44 PDT 2015


 sw/qa/extras/uiwriter/uiwriter.cxx |   62 +++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

New commits:
commit f55bb7d301823556ba58b59a7286cb132bd5f6e4
Author: Varun <varun.dhall at studentpartner.com>
Date:   Thu Jul 30 22:00:22 2015 +0530

    Added Test for #tdf79236 Undo of changing style crashes
    
    Change-Id: I2b4da9f297312390e394f24ca40fdb3d400e6df5
    Reviewed-on: https://gerrit.libreoffice.org/17434
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index e0cebab..bf04bd0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -70,6 +70,8 @@
 #include "com/sun/star/text/XTextField.hpp"
 #include "com/sun/star/text/TextMarkupType.hpp"
 #include <osl/file.hxx>
+#include <paratr.hxx>
+#include <editeng/svxenum.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
@@ -118,6 +120,7 @@ public:
     void testXFlatParagraph();
     void testTdf81995();
     void testExportToPicture();
+    void testTdf79236();
     void testTextSearch();
     void testTdf69282();
     void testTdf69282WithMirror();
@@ -181,6 +184,7 @@ public:
     CPPUNIT_TEST(testXFlatParagraph);
     CPPUNIT_TEST(testTdf81995);
     CPPUNIT_TEST(testExportToPicture);
+    CPPUNIT_TEST(testTdf79236);
     CPPUNIT_TEST(testTextSearch);
     CPPUNIT_TEST(testTdf69282);
     CPPUNIT_TEST(testTdf69282WithMirror);
@@ -1176,6 +1180,64 @@ void SwUiWriterTest::testExportToPicture()
     aTempFile.EnableKillingFile();
 }
 
+void SwUiWriterTest::testTdf79236()
+{
+    SwDoc* pDoc = createDoc();
+    sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+    //Getting some paragraph style
+    SwTextFormatColl* pTextFormat = pDoc->FindTextFormatCollByName(OUString("Text Body"));
+    const SwAttrSet& attrSet = pTextFormat->GetAttrSet();
+    SfxItemSet* itemSet = attrSet.Clone();
+    sal_uInt16 initialCount = itemSet->Count();
+    SvxAdjustItem AdjustItem = attrSet.GetAdjust(true);
+    SvxAdjust initialAdjust = AdjustItem.GetAdjust();
+    //By default the adjust is LEFT
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_LEFT, initialAdjust);
+    //Changing the adjust to RIGHT
+    AdjustItem.SetAdjust(SVX_ADJUST_RIGHT);
+    //Checking whether the change is made or not
+    SvxAdjust modifiedAdjust = AdjustItem.GetAdjust();
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_RIGHT, modifiedAdjust);
+    //Modifying the itemset, putting *one* item
+    itemSet->Put(AdjustItem);
+    //The count should increment by 1
+    sal_uInt16 modifiedCount = itemSet->Count();
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(initialCount + 1), modifiedCount);
+    //Setting the updated item set on the style
+    pDoc->ChgFormat(*pTextFormat, *itemSet);
+    //Checking the Changes
+    SwTextFormatColl* pTextFormat2 = pDoc->FindTextFormatCollByName(OUString("Text Body"));
+    const SwAttrSet& attrSet2 = pTextFormat2->GetAttrSet();
+    const SvxAdjustItem& AdjustItem2 = attrSet2.GetAdjust(true);
+    SvxAdjust Adjust2 = AdjustItem2.GetAdjust();
+    //The adjust should be RIGHT as per the modifications made
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_RIGHT, Adjust2);
+    //Undo the changes
+    rUndoManager.Undo();
+    SwTextFormatColl* pTextFormat3 = pDoc->FindTextFormatCollByName(OUString("Text Body"));
+    const SwAttrSet& attrSet3 = pTextFormat3->GetAttrSet();
+    const SvxAdjustItem& AdjustItem3 = attrSet3.GetAdjust(true);
+    SvxAdjust Adjust3 = AdjustItem3.GetAdjust();
+    //The adjust should be back to default, LEFT
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_LEFT, Adjust3);
+    //Redo the changes
+    rUndoManager.Redo();
+    SwTextFormatColl* pTextFormat4 = pDoc->FindTextFormatCollByName(OUString("Text Body"));
+    const SwAttrSet& attrSet4 = pTextFormat4->GetAttrSet();
+    const SvxAdjustItem& AdjustItem4 = attrSet4.GetAdjust(true);
+    SvxAdjust Adjust4 = AdjustItem4.GetAdjust();
+    //The adjust should be RIGHT as per the modifications made
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_RIGHT, Adjust4);
+    //Undo the changes
+    rUndoManager.Undo();
+    SwTextFormatColl* pTextFormat5 = pDoc->FindTextFormatCollByName(OUString("Text Body"));
+    const SwAttrSet& attrSet5 = pTextFormat5->GetAttrSet();
+    const SvxAdjustItem& AdjustItem5 = attrSet5.GetAdjust(true);
+    SvxAdjust Adjust5 = AdjustItem5.GetAdjust();
+    //The adjust should be back to default, LEFT
+    CPPUNIT_ASSERT_EQUAL(SVX_ADJUST_LEFT, Adjust5);
+}
+
 void SwUiWriterTest::testTextSearch()
 {
     // Create a new empty Writer document


More information about the Libreoffice-commits mailing list