summaryrefslogtreecommitdiff
path: root/sd/qa
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-30 15:47:35 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-04 00:41:49 +0200
commit18f8340a697be7c076fe111d0bc42faf877b9202 (patch)
tree8baec1dd8735dd15128a6fff123ffed6231f0f20 /sd/qa
parent95e5d37b6e62eb39f2d5337e124e86b3d0c3f399 (diff)
sd: fix issue when PDF search doesn't send a search result + test
This fixes the issue when PDF search doesn't send the search result, because of premature exit. Also add test which reproduces this issue and tests the behavior of searching in multiple objects. Change-Id: I3a676eeac36bde88c67e90a49583444b8595a346 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95454 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd/qa')
-rw-r--r--sd/qa/unit/tiledrendering/LOKitSearchTest.cxx86
-rw-r--r--sd/qa/unit/tiledrendering/data/MixedTest1.odgbin0 -> 25083 bytes
2 files changed, 86 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8d8b11e43fa1..24037a0780ba 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,6 +55,7 @@ public:
void testDontSearchInMasterPages();
void testSearchInPDFNonExisting();
void testSearchInPDF();
+ void testSearchInMixedObject();
CPPUNIT_TEST_SUITE(LOKitSearchTest);
CPPUNIT_TEST(testSearch);
@@ -65,6 +66,7 @@ public:
CPPUNIT_TEST(testDontSearchInMasterPages);
CPPUNIT_TEST(testSearchInPDFNonExisting);
CPPUNIT_TEST(testSearchInPDF);
+ CPPUNIT_TEST(testSearchInMixedObject);
CPPUNIT_TEST_SUITE_END();
private:
@@ -317,6 +319,90 @@ void LOKitSearchTest::testSearchInPDF()
mpCallbackRecorder->m_aSelection[0]);
}
+void LOKitSearchTest::testSearchInMixedObject()
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ CPPUNIT_ASSERT(pViewShell);
+ SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT(pDocument);
+ mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+ // Check we have one page
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pDocument->GetSdPageCount(PageKind::Standard));
+
+ SdPage* pPage = pViewShell->GetActualPage();
+ CPPUNIT_ASSERT(pPage);
+
+ // Check page hase 2 objects only
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
+
+ // Check Object 1
+ {
+ SdrObject* pObject = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject);
+
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), pObject->GetObjIdentifier());
+ }
+
+ // Check Object 2
+ {
+ SdrObject* pObject = pPage->GetObj(1);
+ CPPUNIT_ASSERT(pObject);
+
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), pObject->GetObjIdentifier());
+
+ SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject);
+ CPPUNIT_ASSERT(pGraphicObject);
+
+ Graphic aGraphic = pGraphicObject->GetGraphic();
+ auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+ CPPUNIT_ASSERT(pVectorGraphicData);
+
+ CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+ }
+
+ // Let's try to search now
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+ // Search next
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+ // Search next again - we should get the first object again
+
+ lcl_search("ABC");
+
+ CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+ CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size());
+
+ CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/tiledrendering/data/MixedTest1.odg b/sd/qa/unit/tiledrendering/data/MixedTest1.odg
new file mode 100644
index 000000000000..db952318c735
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/MixedTest1.odg
Binary files differ