summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-06-25 16:46:18 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-06-25 21:09:43 +0200
commit122628e63543e7015547f522cf771f08afc4ea90 (patch)
treeb45caf10c9226d77e68d266b180969b65899654a
parent82cb3eb7389b4ff9b3254f8370379cf6fd81322f (diff)
tdf#133326: sc: Add unittest
Change-Id: I2436822fa289ae1bf10643cfc5232f4db6df2e29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97150 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/qa/unit/uicalc/data/tdf133326.odsbin0 -> 10149 bytes
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx57
2 files changed, 57 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/data/tdf133326.ods b/sc/qa/unit/uicalc/data/tdf133326.ods
new file mode 100644
index 000000000000..102f169bd56e
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf133326.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 46e4b24bf669..84b16529c864 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -12,6 +12,7 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <vcl/scheduler.hxx>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <document.hxx>
@@ -89,6 +90,62 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf122232)
checkCurrentCell(2, 6);
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326)
+{
+ ScModelObj* pModelObj = createDoc("tdf133326.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
+
+ uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+ { { "Name", uno::Any(OUString("")) }, { "Index", uno::Any(sal_Int32(2)) } }));
+ dispatchCommand(mxComponent, ".uno:Insert", aArgs);
+
+ OUString aFormula;
+ pDoc->GetFormula(0, 0, 1, aFormula);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+ Scheduler::ProcessEventsToIdle();
+
+ pDoc->GetFormula(0, 0, 1, aFormula);
+ CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ pDoc->GetFormula(0, 0, 1, aFormula);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+ pDoc->GetFormula(0, 0, 1, aFormula);
+ CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+
+ // Without the fix in place, it would have crashed here
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+
+ pDoc->GetFormula(0, 0, 1, aFormula);
+ CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+}
+
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126904)
{
ScModelObj* pModelObj = createDoc("tdf126904.ods");