tdf#130685: Add unittest

Change-Id: I9f0b9a7129056ff3447e1cf91d4eaf188180a04c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91747
Tested-by: Jenkins
Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/data3/tdf130685.odt b/sw/qa/extras/uiwriter/data3/tdf130685.odt
new file mode 100644
index 0000000..f83827e
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf130685.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 7b35f1a..2bafcd2 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -318,6 +318,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130746)
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
}

CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130685)
{
    load(DATA_DIRECTORY, "tdf130685.odt");

    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
    CPPUNIT_ASSERT(pTextDoc);

    CPPUNIT_ASSERT_EQUAL(2, getPages());
    dispatchCommand(mxComponent, ".uno:SelectAll", {});
    dispatchCommand(mxComponent, ".uno:Cut", {});
    Scheduler::ProcessEventsToIdle();
    CPPUNIT_ASSERT_EQUAL(1, getPages());

    dispatchCommand(mxComponent, ".uno:Paste", {});
    dispatchCommand(mxComponent, ".uno:Paste", {});

    // Without fix in place, this test would have failed with:
    //- Expected: 2
    //- Actual  : 4
    CPPUNIT_ASSERT_EQUAL(2, getPages());

    dispatchCommand(mxComponent, ".uno:Undo", {});
    dispatchCommand(mxComponent, ".uno:Undo", {});
    CPPUNIT_ASSERT_EQUAL(1, getPages());

    //FIXME: See tdf#131147
    //dispatchCommand(mxComponent, ".uno:Undo", {});
    //CPPUNIT_ASSERT_EQUAL(2, getPages());
}

CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680)
{
    load(DATA_DIRECTORY, "tdf130680.odt");
@@ -337,7 +367,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680)
    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
    dispatchCommand(mxComponent, ".uno:Paste", {});
    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
    //FIXME: See https://bugs.documentfoundation.org/show_bug.cgi?id=130680#c5
    //FIXME: See tdf#131147
    //dispatchCommand(mxComponent, ".uno:Undo", {});
    //CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount());
    //dispatchCommand(mxComponent, ".uno:Undo", {});