summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter/uiwriter.cxx
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-12-11 15:24:40 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2014-12-11 22:31:35 +0100
commit95b7cf6cef5edc920adee62c18fd97668a9ed3a8 (patch)
tree87696f83687a47d2dd46f82085cc40d9eb2e0626 /sw/qa/extras/uiwriter/uiwriter.cxx
parentb4000bac50431b75d9e1157b88c2fb137e684591 (diff)
Add undo operation for deleting a bookmark + unit test, related fdo#51741
(cherry picked from commit 9338bea6e8dfab8d360fe8ab19dd5d75071bfc2a) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx sw/source/core/undo/unbkmk.cxx Change-Id: I79d8d3c30b6b0b2cc253963fdd50019aec033e12
Diffstat (limited to 'sw/qa/extras/uiwriter/uiwriter.cxx')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 2ed5298f6aa0..23b1e7d84ba0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -57,6 +57,7 @@ public:
void testChineseConversionTraditionalToSimplified();
void testChineseConversionSimplifiedToTraditional();
void testFdo85554();
+ void testBookmarkUndo();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -80,6 +81,7 @@ public:
CPPUNIT_TEST(testChineseConversionTraditionalToSimplified);
CPPUNIT_TEST(testChineseConversionSimplifiedToTraditional);
CPPUNIT_TEST(testFdo85554);
+ CPPUNIT_TEST(testBookmarkUndo);
CPPUNIT_TEST_SUITE_END();
@@ -586,6 +588,40 @@ void SwUiWriterTest::testFdo85554()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
}
+void SwUiWriterTest::testBookmarkUndo()
+{
+ SwDoc* pDoc = createDoc();
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
+ SwPaM aPaM( SwNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1) );
+
+ pMarkAccess->makeMark(aPaM, OUString("Mark"), IDocumentMarkAccess::BOOKMARK);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ rUndoManager.Undo();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount());
+ rUndoManager.Redo();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+
+ IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark("Mark");
+ CPPUNIT_ASSERT(ppBkmk != pMarkAccess->getAllMarksEnd());
+
+ pMarkAccess->renameMark(ppBkmk->get(), "Mark_");
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark") == pMarkAccess->getAllMarksEnd());
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark_") != pMarkAccess->getAllMarksEnd());
+ rUndoManager.Undo();
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark") != pMarkAccess->getAllMarksEnd());
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark_") == pMarkAccess->getAllMarksEnd());
+ rUndoManager.Redo();
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark") == pMarkAccess->getAllMarksEnd());
+ CPPUNIT_ASSERT(pMarkAccess->findMark("Mark_") != pMarkAccess->getAllMarksEnd());
+
+ pMarkAccess->deleteMark( pMarkAccess->findMark("Mark_") );
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount());
+ rUndoManager.Undo();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ rUndoManager.Redo();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount());
+}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();