From 1d76b4e38c93388488dbd7f32912f6f40e081721 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 5 Oct 2015 15:34:28 +0200 Subject: [PATCH 176/398] CppunitTest_sw_tiledrendering: testcase for LOK_CALLBACK_SEARCH_RESULT_COUNT Change-Id: I9f517bc2f3dfca9a2dc17a229f54c47b7790a355 (cherry picked from commit b4e75e8f52c17d02a65022303fb6a0e4f1d97592) --- sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index e7ab14942f79..c836f4bc5eab 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ public: void testSearchTextFrame(); void testSearchTextFrameWrapAround(); void testDocumentSizeChanged(); + void testSearchAll(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -56,6 +58,7 @@ public: CPPUNIT_TEST(testSearchTextFrame); CPPUNIT_TEST(testSearchTextFrameWrapAround); CPPUNIT_TEST(testDocumentSizeChanged); + CPPUNIT_TEST(testSearchAll); CPPUNIT_TEST_SUITE_END(); private: @@ -66,10 +69,12 @@ private: Size m_aDocumentSize; OString m_aTextSelection; bool m_bFound; + sal_Int32 m_nSearchResultCount; }; SwTiledRenderingTest::SwTiledRenderingTest() - : m_bFound(true) + : m_bFound(true), + m_nSearchResultCount(0) { } @@ -125,6 +130,11 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) m_bFound = false; } break; + case LOK_CALLBACK_SEARCH_RESULT_COUNT: + { + m_nSearchResultCount = OString(pPayload).toInt32(); + } + break; } } @@ -438,6 +448,26 @@ void SwTiledRenderingTest::testDocumentSizeChanged() #endif } +void SwTiledRenderingTest::testSearchAll() +{ +#if !defined(WNT) && !defined(MACOSX) + comphelper::LibreOfficeKit::setActive(); + + SwXTextDocument* pXTextDocument = createDoc("search.odt"); + pXTextDocument->registerCallback(&SwTiledRenderingTest::callback, this); + uno::Sequence aPropertyValues(comphelper::InitPropertySequence( + { + {"SearchItem.SearchString", uno::makeAny(OUString("shape"))}, + {"SearchItem.Backward", uno::makeAny(false)}, + {"SearchItem.Command", uno::makeAny(static_cast(SvxSearchCmd::FIND_ALL))}, + })); + comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); + // This was 0; should be 2 results in the body text. + CPPUNIT_ASSERT_EQUAL(static_cast(2), m_nSearchResultCount); + + comphelper::LibreOfficeKit::setActive(false); +#endif +} CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- 2.12.0