diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-11-23 21:15:43 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-11-24 18:53:05 +0100 |
commit | b5525444db57e9e9c289f08d7a03f77b15acd8b4 (patch) | |
tree | d73eb75685058dc7c1dd042964aa6b1c4b2f8f97 | |
parent | 5814084f02f3d660fc28afd6a053050073944b81 (diff) |
tdf#138428: sc_uicalc: Add unittest
Change-Id: I8379ced4d04efcfaf355734d50a784bf29636140
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106455
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 725e1c7c48dc..a5c9a589023a 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -323,6 +323,67 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf83901) CPPUNIT_ASSERT_EQUAL(3.0, pDoc->GetValue(ScAddress(0, 1, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138428) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + checkCurrentCell(0, 0); + + // Add a new comment + uno::Sequence<beans::PropertyValue> aArgs + = comphelper::InitPropertySequence({ { "Text", uno::makeAny(OUString("Comment")) } }); + dispatchCommand(mxComponent, ".uno:InsertAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on B1", !pDoc->HasNote(ScAddress(1, 0, 0))); + + // .uno:Copy without touching shared clipboard + ScDocument aClipDoc(SCDOCMODE_CLIP); + ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false); + + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:GoRight", {}); + checkCurrentCell(1, 0); + + // .uno:Paste without touching shared clipboard + ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", pDoc->HasNote(ScAddress(1, 0, 0))); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on B1", !pDoc->HasNote(ScAddress(1, 0, 0))); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on A1", !pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on B1", !pDoc->HasNote(ScAddress(1, 0, 0))); + + dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be a note on B1", !pDoc->HasNote(ScAddress(1, 0, 0))); + + dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_MESSAGE("There should be a note on A1", pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", pDoc->HasNote(ScAddress(1, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133342) { ScModelObj* pModelObj = createDoc("tdf133342.ods"); |