sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp |binary
 sd/qa/unit/uiimpress.cxx                                 |   43 ++++++++++++---
 2 files changed, 36 insertions(+), 7 deletions(-)

New commits:
commit b7d5ff4bbf41094b6579ae26023fbd686b060ce9
Author:     Justin Luth <[email protected]>
AuthorDate: Fri Jan 21 11:08:46 2022 +0200
Commit:     Justin Luth <[email protected]>
CommitDate: Mon Jan 31 10:43:12 2022 +0100

    tdf#123658 sd search: partial UI unit test
    
    Windows and Mac OS are failing this unit test
    at an early stage, before the code change should
    even hit. So I am decoupling the unit test and
    running it prior to my patch to ensure that it
    really is some pre-existing issue and not
    related to my code.
    
    [Because lcl_search() was is not used in MAC/WIN,
    I was getting errors about an unused function,
    so I also used it in another test (where I
    got the code from in the first place).
    I verified that test still failed when
    the associated commit was reverted.
    I also made it bBackwards just to make sure
    the variable is used, even though irrelevant here.]
    
    Change-Id: I2413fa54b881d8e8eb8c6c8907fbc0d13c352e10
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128729
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <[email protected]>

diff --git a/sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp 
b/sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp
new file mode 100644
index 000000000000..cfd296700a1a
Binary files /dev/null and 
b/sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp differ
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 5a773aa8ced6..fcaa970cc929 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -20,6 +20,7 @@
 #include <com/sun/star/text/WritingMode2.hpp>
 #include <com/sun/star/view/XSelectionSupplier.hpp>
 
+#include <comphelper/dispatchcommand.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <sfx2/dispatch.hxx>
@@ -189,6 +190,21 @@ void SdUiImpressTest::save(sd::DrawDocShell* pShell, 
FileFormat const* pFormat,
     pShell->DoClose();
 }
 
+static void lcl_search(const OUString& rKey, bool bFindAll = false, bool 
bBackwards = false)
+{
+    Scheduler::ProcessEventsToIdle();
+    SvxSearchCmd eSearch = bFindAll ? SvxSearchCmd::FIND_ALL : 
SvxSearchCmd::FIND;
+
+    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence({
+        { "SearchItem.SearchString", uno::makeAny(rKey) },
+        { "SearchItem.Backward", uno::makeAny(bBackwards) },
+        { "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
+    }));
+
+    comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+}
+
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
 {
     // Load the document and create two new windows.
@@ -833,16 +849,29 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, 
testSearchAllInDocumentAndNotes)
     sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
     CPPUNIT_ASSERT(pViewShell);
 
-    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence({
-        { "SearchItem.SearchString", uno::makeAny(OUString("Crash")) },
-        { "SearchItem.Backward", uno::makeAny(false) },
-        { "SearchItem.Command", 
uno::makeAny(sal_uInt16(SvxSearchCmd::FIND_ALL)) },
-    }));
+    lcl_search("Crash", /*bFindAll=*/true, /*bBackwards=*/true);
+}
 
-    dispatchCommand(mxComponent, ".uno:ExecuteSearch", aPropertyValues);
+#if !defined(_WIN32) && !defined(MACOSX)
+// for some reason, the search for "second" (or "Second") didn't return page 2 
in WIN and MACOS
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf123658_SearchAfterSlideChange)
+{
+    mxComponent = loadFromDesktop(
+        
m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf123658_SearchAfterSlideChange.odp"));
 
-    Scheduler::ProcessEventsToIdle();
+    auto pXImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+
+    lcl_search("second");
+    checkCurrentPageNumber(2);
+
+    pXImpressDocument->setPart(0); // Switch to 1st page
+
+    lcl_search("of");
+    // Instead of finding this on the 1st page (or on the 2nd page would be 
acceptable too)
+    // it was going to the third page.
+    //checkCurrentPageNumber(1);
 }
+#endif
 
 CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf142589)
 {

Reply via email to