From d08e2f3daa126f4487d75e06330a56e8b998e7e7 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 7 Jun 2021 10:01:55 +0900 Subject: tdf#142478 add test that triggers find all and crashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit String "Crash" in document and notes, then trigger "find all", which produced a crash without the fix in-place. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116769 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl (cherry picked from commit 7f059ce157da0de40a98f63f61d923cc67d93884) Change-Id: I8e6e4a9da1afc85643648aee36a03c1fb39ca16d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117146 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna --- sd/qa/unit/data/odp/search-all-notes.odp | Bin 0 -> 12018 bytes sd/qa/unit/uiimpress.cxx | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 sd/qa/unit/data/odp/search-all-notes.odp (limited to 'sd') diff --git a/sd/qa/unit/data/odp/search-all-notes.odp b/sd/qa/unit/data/odp/search-all-notes.odp new file mode 100644 index 000000000000..6c38ecabb0ea Binary files /dev/null and b/sd/qa/unit/data/odp/search-all-notes.odp differ diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 81ec6e4bf321..274160105156 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -346,6 +347,30 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSpellOnlineParameter) CPPUNIT_ASSERT_EQUAL(!bSet, pImpressDocument->GetDoc()->GetOnlineSpell()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSearchAllInDocumentAndNotes) +{ + // tdf#142478 + // "find all" produces a crash when the search string exists in notes + // and the document + + mxComponent = loadFromDesktop( + m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/search-all-notes.odp")); + + auto pXImpressDocument = dynamic_cast(mxComponent.get()); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + uno::Sequence aPropertyValues(comphelper::InitPropertySequence({ + { "SearchItem.SearchString", uno::makeAny(OUString("Crash")) }, + { "SearchItem.Backward", uno::makeAny(false) }, + { "SearchItem.Command", uno::makeAny(sal_uInt16(SvxSearchCmd::FIND_ALL)) }, + })); + + dispatchCommand(mxComponent, ".uno:ExecuteSearch", aPropertyValues); + + Scheduler::ProcessEventsToIdle(); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit