summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2022-04-07 13:14:59 +0530
committerMichael Meeks <michael.meeks@collabora.com>2022-04-13 21:54:48 +0200
commit3c9cbc43b0cdb12e0bdfb95e797357de5b7c74db (patch)
treedfed812dafc430934687f62bec1b75decd779a06
parentHandle "addfont" from Collabora Online (diff)
downloadcore-3c9cbc43b0cdb12e0bdfb95e797357de5b7c74db.tar.gz
core-3c9cbc43b0cdb12e0bdfb95e797357de5b7c74db.zip
lok: unit test for invalid entry save
Unit test related to the fix lok: avoid validation-dialog yield when saving e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593 The test ensures that the document is marked unmodified after save has been executed in the middle of entering partial data to a validation cell. Change-Id: Idffd6d647034e128d0d800fe8e29efc333c03db6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132653 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--sc/qa/unit/tiledrendering/data/validity.xlsxbin0 -> 5702 bytes
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx57
2 files changed, 52 insertions, 5 deletions
diff --git a/sc/qa/unit/tiledrendering/data/validity.xlsx b/sc/qa/unit/tiledrendering/data/validity.xlsx
new file mode 100644
index 000000000000..54a92acd5979
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/data/validity.xlsx
Binary files differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 3364e049c22f..9894da18e018 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -127,6 +127,7 @@ public:
void testSheetViewDataCrash();
void testTextBoxInsert();
void testCommentCellCopyPaste();
+ void testInvalidEntrySave();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnHeaders);
@@ -182,6 +183,7 @@ public:
CPPUNIT_TEST(testSheetViewDataCrash);
CPPUNIT_TEST(testTextBoxInsert);
CPPUNIT_TEST(testCommentCellCopyPaste);
+ CPPUNIT_TEST(testInvalidEntrySave);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2701,18 +2703,25 @@ void ScTiledRenderingTest::testSortAscendingDescending()
CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry);
}
-void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, ScTabViewShell* pView, ScModelObj* pModelObj)
+void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, ScTabViewShell* pView,
+ ScModelObj* pModelObj, bool bInEdit = false, bool bCommit = true)
{
- pView->SetCursor(nCol, nRow);
+ if (!bInEdit)
+ pView->SetCursor(nCol, nRow);
+
for (const char& cChar : aStr)
{
pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, cChar, 0);
pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, cChar, 0);
Scheduler::ProcessEventsToIdle();
}
- pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
- pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
- Scheduler::ProcessEventsToIdle();
+
+ if (bCommit)
+ {
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+ Scheduler::ProcessEventsToIdle();
+ }
}
void ScTiledRenderingTest::testAutoInputExactMatch()
@@ -3019,6 +3028,44 @@ void ScTiledRenderingTest::testCommentCellCopyPaste()
comphelper::LibreOfficeKit::setTiledAnnotations(true);
}
+void ScTiledRenderingTest::testInvalidEntrySave()
+{
+ // Load a document
+ comphelper::LibreOfficeKit::setActive();
+
+ ScModelObj* pModelObj = createDoc("validity.xlsx");
+ const ScDocument* pDoc = pModelObj->GetDocument();
+ ViewCallback aView;
+ int nView = SfxLokHelper::getView();
+
+ SfxLokHelper::setView(nView);
+
+ ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() );
+ ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ CPPUNIT_ASSERT(pTabViewShell);
+
+ // Type partial date "7/8" of "7/8/2013" that
+ // the validation cell at A8 can accept
+ lcl_typeCharsInCell("7/8", 0, 7, pTabViewShell, pModelObj,
+ false /* bInEdit */, false /* bCommit */); // Type "7/8" in A8
+
+ uno::Sequence<beans::PropertyValue> aArgs;
+ comphelper::dispatchCommand(".uno:Save", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ CPPUNIT_ASSERT_MESSAGE("Should not be marked modified after save", !pDocSh->IsModified());
+
+ // Complete the date in A8 by appending "/2013" and commit.
+ lcl_typeCharsInCell("/2013", 0, 7, pTabViewShell, pModelObj,
+ true /* bInEdit */, true /* bCommit */);
+
+ // This would hang if the date entered "7/8/2013" is not acceptable.
+ Scheduler::ProcessEventsToIdle();
+
+ // Ensure that the correct date is recorded in the document.
+ CPPUNIT_ASSERT_EQUAL(double(41463), pDoc->GetValue(ScAddress(0, 7, 0)));
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);