sd/CppunitTest_sd_tiledrendering.mk            |    1 
 sd/qa/unit/sdmodeltestbase.hxx                 |    2 
 sd/qa/unit/tiledrendering/CallbackRecorder.hxx |  142 +++++++++++++++
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |  233 +++++++++++++++++++++++++
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |  140 +--------------
 5 files changed, 388 insertions(+), 130 deletions(-)

New commits:
commit b40f1d657affbe87f60bfd358199a91c9fea7454
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri May 29 18:18:40 2020 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Wed Jun 3 07:42:03 2020 +0200

    sd: move LOK search tests out of tiledrendering.cxx
    
    Change-Id: I76ff3e251afc877b0dcf54d772da95bb7a60e823
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95351
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sd/CppunitTest_sd_tiledrendering.mk 
b/sd/CppunitTest_sd_tiledrendering.mk
index 9b643c869a84..3b555860f963 100644
--- a/sd/CppunitTest_sd_tiledrendering.mk
+++ b/sd/CppunitTest_sd_tiledrendering.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sd_tiledrendering))
 $(eval $(call gb_CppunitTest_use_common_precompiled_header,sd_tiledrendering))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sd_tiledrendering, \
+    sd/qa/unit/tiledrendering/LOKitSearchTest \
     sd/qa/unit/tiledrendering/tiledrendering \
 ))
 
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 9cdb3214f353..6469eba789fe 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -73,7 +73,7 @@ pFilterName: <node oor:Name="...">
 pTypeName: <prop oor:Name="Type">...</prop>
 nFormatType: <prop oor:name="Flags">...</prop>
 */
-FileFormat aFileFormats[] =
+static FileFormat aFileFormats[] =
 {
     { "odp",  "impress8", "impress8", "", ODP_FORMAT_TYPE },
     { "ppt",  "MS PowerPoint 97", "impress_MS_PowerPoint_97", "sdfilt", 
PPT_FORMAT_TYPE },
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx 
b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
new file mode 100644
index 000000000000..fc5117cce6dc
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/json_parser.hpp>
+#include <comphelper/string.hxx>
+#include <osl/conditn.hxx>
+#include <sfx2/viewsh.hxx>
+
+namespace
+{
+std::vector<OUString> lcl_convertSeparated(const OUString& rString, 
sal_Unicode nSeparator)
+{
+    std::vector<OUString> aRet;
+
+    sal_Int32 nIndex = 0;
+    do
+    {
+        OUString aToken = rString.getToken(0, nSeparator, nIndex);
+        aToken = aToken.trim();
+        if (!aToken.isEmpty())
+            aRet.push_back(aToken);
+    } while (nIndex >= 0);
+
+    return aRet;
+}
+
+void lcl_convertRectangle(const OUString& rString, tools::Rectangle& 
rRectangle)
+{
+    uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(rString);
+    CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+    rRectangle.setX(aSeq[0].toInt32());
+    rRectangle.setY(aSeq[1].toInt32());
+    rRectangle.setWidth(aSeq[2].toInt32());
+    rRectangle.setHeight(aSeq[3].toInt32());
+}
+}
+
+struct CallbackRecorder
+{
+    CallbackRecorder()
+        : m_bFound(true)
+        , m_nPart(0)
+        , m_nSelectionBeforeSearchResult(0)
+        , m_nSelectionAfterSearchResult(0)
+    {
+    }
+
+    tools::Rectangle m_aInvalidation;
+    std::vector<::tools::Rectangle> m_aSelection;
+    bool m_bFound;
+    sal_Int32 m_nPart;
+    std::vector<OString> m_aSearchResultSelection;
+    std::vector<int> m_aSearchResultPart;
+    int m_nSelectionBeforeSearchResult;
+    int m_nSelectionAfterSearchResult;
+    /// For document size changed callback.
+    osl::Condition m_aDocumentSizeCondition;
+
+    static void callback(int nType, const char* pPayload, void* pData)
+    {
+        static_cast<CallbackRecorder*>(pData)->processCallback(nType, 
pPayload);
+    }
+
+    void processCallback(int nType, const char* pPayload)
+    {
+        switch (nType)
+        {
+            case LOK_CALLBACK_INVALIDATE_TILES:
+            {
+                OUString aPayload = OUString::createFromAscii(pPayload);
+                if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
+                    lcl_convertRectangle(aPayload, m_aInvalidation);
+            }
+            break;
+            case LOK_CALLBACK_TEXT_SELECTION:
+            {
+                OUString aPayload = OUString::createFromAscii(pPayload);
+                m_aSelection.clear();
+                for (const OUString& rString : lcl_convertSeparated(aPayload, 
u';'))
+                {
+                    ::tools::Rectangle aRectangle;
+                    lcl_convertRectangle(rString, aRectangle);
+                    m_aSelection.push_back(aRectangle);
+                }
+                if (m_aSearchResultSelection.empty())
+                    ++m_nSelectionBeforeSearchResult;
+                else
+                    ++m_nSelectionAfterSearchResult;
+            }
+            break;
+            case LOK_CALLBACK_SEARCH_NOT_FOUND:
+            {
+                m_bFound = false;
+            }
+            break;
+            case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+            {
+                m_aDocumentSizeCondition.set();
+            }
+            break;
+            case LOK_CALLBACK_SET_PART:
+            {
+                OUString aPayload = OUString::createFromAscii(pPayload);
+                m_nPart = aPayload.toInt32();
+            }
+            break;
+            case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
+            {
+                m_aSearchResultSelection.clear();
+                m_aSearchResultPart.clear();
+                boost::property_tree::ptree aTree;
+                std::stringstream aStream(pPayload);
+                boost::property_tree::read_json(aStream, aTree);
+                for (const boost::property_tree::ptree::value_type& rValue :
+                     aTree.get_child("searchResultSelection"))
+                {
+                    m_aSearchResultSelection.emplace_back(
+                        rValue.second.get<std::string>("rectangles").c_str());
+                    m_aSearchResultPart.push_back(
+                        
std::atoi(rValue.second.get<std::string>("part").c_str()));
+                }
+            }
+            break;
+        }
+    }
+
+    void registerCallbacksFor(SfxViewShell& rViewShell)
+    {
+        
rViewShell.registerLibreOfficeKitViewCallback(&CallbackRecorder::callback, 
this);
+    }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
new file mode 100644
index 000000000000..4474bd8e4751
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -0,0 +1,233 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../sdmodeltestbase.hxx"
+#include "CallbackRecorder.hxx"
+
+#include <test/bootstrapfixture.hxx>
+#include <test/helper/transferable.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/string.hxx>
+#include <comphelper/lok.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/srchitem.hxx>
+#include <svl/stritem.hxx>
+#include <ViewShellBase.hxx>
+#include <ViewShell.hxx>
+#include <unomodel.hxx>
+
+#include <com/sun/star/frame/Desktop.hpp>
+
+using namespace css;
+
+class LOKitSearchTest : public SdModelTestBase, public XmlTestTools
+{
+private:
+    static constexpr char DATA_DIRECTORY[] = 
"/sd/qa/unit/tiledrendering/data/";
+
+public:
+    LOKitSearchTest() {}
+
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    void testSearch();
+    void testSearchAll();
+    void testSearchAllSelections();
+    void testSearchAllNotifications();
+    void testSearchAllFollowedBySearch();
+    void testDontSearchInMasterPages();
+
+    CPPUNIT_TEST_SUITE(LOKitSearchTest);
+    CPPUNIT_TEST(testSearch);
+    CPPUNIT_TEST(testSearchAll);
+    CPPUNIT_TEST(testSearchAllSelections);
+    CPPUNIT_TEST(testSearchAllNotifications);
+    CPPUNIT_TEST(testSearchAllFollowedBySearch);
+    CPPUNIT_TEST(testDontSearchInMasterPages);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    SdXImpressDocument* createDoc(const char* pName,
+                                  const uno::Sequence<beans::PropertyValue>& 
rArguments
+                                  = uno::Sequence<beans::PropertyValue>());
+
+    uno::Reference<lang::XComponent> mxComponent;
+    std::unique_ptr<CallbackRecorder> mpCallbackRecorder;
+};
+
+void LOKitSearchTest::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    // prevent showing warning message box
+    setenv("OOX_NO_SMARTART_WARNING", "1", 1);
+    comphelper::LibreOfficeKit::setActive(true);
+
+    mxDesktop.set(
+        
css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+    mpCallbackRecorder = std::make_unique<CallbackRecorder>();
+}
+
+void LOKitSearchTest::tearDown()
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+
+    comphelper::LibreOfficeKit::setActive(false);
+
+    test::BootstrapFixture::tearDown();
+}
+
+SdXImpressDocument*
+LOKitSearchTest::createDoc(const char* pName, const 
uno::Sequence<beans::PropertyValue>& rArguments)
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+    mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY)
+                                      + OUString::createFromAscii(pName),
+                                  
"com.sun.star.presentation.PresentationDocument");
+    SdXImpressDocument* pImpressDocument = 
dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pImpressDocument);
+    pImpressDocument->initializeForTiledRendering(rArguments);
+    return pImpressDocument;
+}
+
+namespace
+{
+void lcl_search(const OUString& rKey, bool bFindAll = false)
+{
+    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence({
+        { "SearchItem.SearchString", uno::makeAny(rKey) },
+        { "SearchItem.Backward", uno::makeAny(false) },
+        { "SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(
+                                    bFindAll ? SvxSearchCmd::FIND_ALL : 
SvxSearchCmd::FIND)) },
+    }));
+    comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+}
+}
+
+void LOKitSearchTest::testSearch()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+    uno::Reference<container::XIndexAccess> xDrawPage(
+        pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
+    xShape->setString("Aaa bbb.");
+
+    lcl_search("bbb");
+
+    SdrView* pView = pViewShell->GetView();
+    EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+    // Did we indeed manage to select the second word?
+    CPPUNIT_ASSERT_EQUAL(OUString("bbb"), rEditView.GetSelected());
+
+    // Did the selection callback fire?
+    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), 
mpCallbackRecorder->m_aSelection.size());
+
+    // Search for something on the second slide, and make sure that the 
set-part callback fired.
+    lcl_search("bbb");
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
mpCallbackRecorder->m_nPart);
+    CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+    // This was 0; should be 1 match for "find".
+    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1),
+                         mpCallbackRecorder->m_aSearchResultSelection.size());
+    // Result is on the second slide.
+    CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
+
+    // This should trigger the not-found callback.
+    lcl_search("ccc");
+    CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+}
+
+void LOKitSearchTest::testSearchAll()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+    lcl_search("match", /*bFindAll=*/true);
+
+    // This was empty: find-all did not highlight the first match.
+    CPPUNIT_ASSERT_EQUAL(OString("match"),
+                         apitest::helper::transferable::getTextSelection(
+                             pXImpressDocument->getSelection(), 
"text/plain;charset=utf-8"));
+
+    // We're on the first slide, search for something on the second slide and 
make sure we get a SET_PART.
+    mpCallbackRecorder->m_nPart = 0;
+    lcl_search("second", /*bFindAll=*/true);
+    // This was 0: no SET_PART was emitted.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), 
mpCallbackRecorder->m_nPart);
+}
+
+void LOKitSearchTest::testSearchAllSelections()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+    lcl_search("third", /*bFindAll=*/true);
+    // Make sure this is found on the 3rd slide.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), 
mpCallbackRecorder->m_nPart);
+    // This was 1: only the first match was highlighted.
+    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), 
mpCallbackRecorder->m_aSelection.size());
+}
+
+void LOKitSearchTest::testSearchAllNotifications()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+    lcl_search("third", /*bFindAll=*/true);
+    // Make sure that we get no notifications about selection changes during 
search.
+    CPPUNIT_ASSERT_EQUAL(0, 
mpCallbackRecorder->m_nSelectionBeforeSearchResult);
+    // But we do get the selection of the first hit.
+    CPPUNIT_ASSERT(mpCallbackRecorder->m_nSelectionAfterSearchResult > 0);
+}
+
+void LOKitSearchTest::testSearchAllFollowedBySearch()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+    lcl_search("third", /*bFindAll=*/true);
+    lcl_search("match" /*,bFindAll=false*/);
+
+    // This used to give wrong result: 'search' after 'search all' still
+    // returned 'third'
+    CPPUNIT_ASSERT_EQUAL(OString("match"),
+                         apitest::helper::transferable::getTextSelection(
+                             pXImpressDocument->getSelection(), 
"text/plain;charset=utf-8"));
+}
+
+void LOKitSearchTest::testDontSearchInMasterPages()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+    // This should trigger the not-found callback ("date" is present only on
+    // the master page)
+    lcl_search("date");
+    CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 2bd405ff6b26..e2f88363bc48 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -59,7 +59,10 @@
 
 using namespace css;
 
-static char const DATA_DIRECTORY[] = "/sd/qa/unit/tiledrendering/data/";
+namespace
+{
+    char const DATA_DIRECTORY[] = "/sd/qa/unit/tiledrendering/data/";
+}
 
 static std::ostream& operator<<(std::ostream& os, ViewShellId id)
 {
@@ -84,12 +87,6 @@ public:
     void testSetGraphicSelection();
     void testUndoShells();
     void testResetSelection();
-    void testSearch();
-    void testSearchAll();
-    void testSearchAllSelections();
-    void testSearchAllNotifications();
-    void testSearchAllFollowedBySearch();
-    void testDontSearchInMasterPages();
     void testInsertDeletePage();
     void testInsertTable();
     void testPartHash();
@@ -140,12 +137,6 @@ public:
     CPPUNIT_TEST(testSetGraphicSelection);
     CPPUNIT_TEST(testUndoShells);
     CPPUNIT_TEST(testResetSelection);
-    CPPUNIT_TEST(testSearch);
-    CPPUNIT_TEST(testSearchAll);
-    CPPUNIT_TEST(testSearchAllSelections);
-    CPPUNIT_TEST(testSearchAllNotifications);
-    CPPUNIT_TEST(testSearchAllFollowedBySearch);
-    CPPUNIT_TEST(testDontSearchInMasterPages);
     CPPUNIT_TEST(testInsertDeletePage);
     CPPUNIT_TEST(testInsertTable);
     CPPUNIT_TEST(testPartHash);
@@ -257,7 +248,10 @@ void SdTiledRenderingTest::callback(int nType, const char* 
pPayload, void* pData
     static_cast<SdTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
 }
 
-static std::vector<OUString> lcl_convertSeparated(const OUString& rString, 
sal_Unicode nSeparator)
+namespace
+{
+
+std::vector<OUString> lcl_convertSeparated(const OUString& rString, 
sal_Unicode nSeparator)
 {
     std::vector<OUString> aRet;
 
@@ -274,7 +268,7 @@ static std::vector<OUString> lcl_convertSeparated(const 
OUString& rString, sal_U
     return aRet;
 }
 
-static void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& 
rRectangle)
+void lcl_convertRectangle(const OUString& rString, ::tools::Rectangle& 
rRectangle)
 {
     uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(rString);
     CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
@@ -284,6 +278,8 @@ static void lcl_convertRectangle(const OUString& rString, 
::tools::Rectangle& rR
     rRectangle.setHeight(aSeq[3].toInt32());
 }
 
+} // end anonymouse namespace
+
 void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
 {
     switch (nType)
@@ -590,120 +586,6 @@ void SdTiledRenderingTest::testResetSelection()
     CPPUNIT_ASSERT(!pView->GetTextEditObject());
 }
 
-static void lcl_search(const OUString& rKey, bool bFindAll = false)
-{
-    uno::Sequence<beans::PropertyValue> 
aPropertyValues(comphelper::InitPropertySequence(
-    {
-        {"SearchItem.SearchString", uno::makeAny(rKey)},
-        {"SearchItem.Backward", uno::makeAny(false)},
-        {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(bFindAll ? 
SvxSearchCmd::FIND_ALL : SvxSearchCmd::FIND))},
-    }));
-    comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
-}
-
-void SdTiledRenderingTest::testSearch()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-    uno::Reference<container::XIndexAccess> 
xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
-    uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), 
uno::UNO_QUERY);
-    xShape->setString("Aaa bbb.");
-
-    lcl_search("bbb");
-
-    SdrView* pView = pViewShell->GetView();
-    EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
-    // Did we indeed manage to select the second word?
-    CPPUNIT_ASSERT_EQUAL(OUString("bbb"), rEditView.GetSelected());
-
-    // Did the selection callback fire?
-    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), m_aSelection.size());
-
-    // Search for something on the second slide, and make sure that the 
set-part callback fired.
-    lcl_search("bbb");
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
-    CPPUNIT_ASSERT_EQUAL(true, m_bFound);
-    // This was 0; should be 1 match for "find".
-    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), 
m_aSearchResultSelection.size());
-    // Result is on the second slide.
-    CPPUNIT_ASSERT_EQUAL(1, m_aSearchResultPart[0]);
-
-    // This should trigger the not-found callback.
-    lcl_search("ccc");
-    CPPUNIT_ASSERT_EQUAL(false, m_bFound);
-}
-
-void SdTiledRenderingTest::testSearchAll()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-
-    lcl_search("match", /*bFindAll=*/true);
-
-    // This was empty: find-all did not highlight the first match.
-    CPPUNIT_ASSERT_EQUAL(OString("match"), 
apitest::helper::transferable::getTextSelection(pXImpressDocument->getSelection(),
 "text/plain;charset=utf-8"));
-
-    // We're on the first slide, search for something on the second slide and 
make sure we get a SET_PART.
-    m_nPart = 0;
-    lcl_search("second", /*bFindAll=*/true);
-    // This was 0: no SET_PART was emitted.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), m_nPart);
-}
-
-void SdTiledRenderingTest::testSearchAllSelections()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-
-    lcl_search("third", /*bFindAll=*/true);
-    // Make sure this is found on the 3rd slide.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), m_nPart);
-    // This was 1: only the first match was highlighted.
-    CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), m_aSelection.size());
-}
-
-void SdTiledRenderingTest::testSearchAllNotifications()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-
-    lcl_search("third", /*bFindAll=*/true);
-    // Make sure that we get no notifications about selection changes during 
search.
-    CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
-    // But we do get the selection of the first hit.
-    CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
-}
-
-void SdTiledRenderingTest::testSearchAllFollowedBySearch()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-
-    lcl_search("third", /*bFindAll=*/true);
-    lcl_search("match" /*,bFindAll=false*/);
-
-    // This used to give wrong result: 'search' after 'search all' still
-    // returned 'third'
-    CPPUNIT_ASSERT_EQUAL(OString("match"), 
apitest::helper::transferable::getTextSelection(pXImpressDocument->getSelection(),
 "text/plain;charset=utf-8"));
-}
-
-void SdTiledRenderingTest::testDontSearchInMasterPages()
-{
-    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
-    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
-    
pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback,
 this);
-
-    // This should trigger the not-found callback ("date" is present only on
-    // the master page)
-    lcl_search("date");
-    CPPUNIT_ASSERT_EQUAL(false, m_bFound);
-}
-
 namespace
 {
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to