diff options
author | Dennis Francis <dennisfrancis.in@gmail.com> | 2021-07-02 19:10:31 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2021-07-05 12:58:56 +0200 |
commit | 901620d221a83236f1c1a86ab193043c3220ab92 (patch) | |
tree | 9d093eeb509c604c508d42a24a982bc21a00a9ab | |
parent | b302efec7bb3dbf1de3ef66c2f2098d6d69ba9aa (diff) |
lok: sc: unit test for non existent tab view data fix
Change-Id: I7c0ea95118448a49288ff70c8e7bcddc379df5ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118319
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 1b7eb5343560..0fa752be89fe 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -111,6 +111,7 @@ public: void testJumpToLastRowInvalidation(); void testDeleteCellMultilineContent(); void testFunctionDlg(); + void testSheetViewDataCrash(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnHeaders); @@ -153,6 +154,7 @@ public: CPPUNIT_TEST(testJumpToLastRowInvalidation); CPPUNIT_TEST(testDeleteCellMultilineContent); CPPUNIT_TEST(testFunctionDlg); + CPPUNIT_TEST(testSheetViewDataCrash); CPPUNIT_TEST_SUITE_END(); private: @@ -2028,6 +2030,47 @@ void ScTiledRenderingTest::testDeleteCellMultilineContent() SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } +void ScTiledRenderingTest::testSheetViewDataCrash() +{ + comphelper::LibreOfficeKit::setActive(); + + ScModelObj* pModelObj = createDoc("empty.ods"); + + // view #1 + int nView1 = SfxLokHelper::getView(); + SfxLokHelper::setView(nView1); + + // Imitate online while creating a new sheet on empty.ods. + uno::Sequence<beans::PropertyValue> aArgs( + comphelper::InitPropertySequence({ + { "Name", uno::Any(OUString("NewSheet")) }, + { "Index", uno::Any(sal_Int32(2)) } + })); + comphelper::dispatchCommand(".uno:Insert", aArgs); + Scheduler::ProcessEventsToIdle(); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | KEY_MOD1); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD1); + Scheduler::ProcessEventsToIdle(); + ScTabViewShell* pView1 = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView1); + + // view #2 + SfxLokHelper::createView(); + ScTabViewShell* pView2 = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView2); + Scheduler::ProcessEventsToIdle(); + + SfxLokHelper::setView(nView1); + // Delete a range. + pView1->SetCursor(1, 1); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN | KEY_SHIFT); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN | KEY_SHIFT); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DELETE); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE); + // It will crash at this point without the fix. + Scheduler::ProcessEventsToIdle(); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); |