summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-10-08 10:56:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-10-08 10:56:49 +0200
commit97c414758d3d8aa3cc2233d52612cf0a33c24c34 (patch)
treee9ee04bb4c2e2179fe070419f7170202a8899289
parentde1f156c6a35757d74b0e337b02743f1962ff0ae (diff)
CppunitTest_desktop_lib: add Calc find-all testcase
Fails without commit a31f95b180728c1c671930913b4b4ad96ebcda5f (sc tiled rendering: fix showing all search results, 2015-10-07). Change-Id: Ibc01d468168367f789b3f5046808104fa3f5ef18
-rw-r--r--desktop/CppunitTest_desktop_lib.mk3
-rw-r--r--desktop/qa/data/search.odsbin0 -> 7636 bytes
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx76
3 files changed, 76 insertions, 3 deletions
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
index be394600ddf0..0c963f9088c2 100644
--- a/desktop/CppunitTest_desktop_lib.mk
+++ b/desktop/CppunitTest_desktop_lib.mk
@@ -56,11 +56,14 @@ $(eval $(call gb_CppunitTest_use_components,desktop_lib,\
svtools/util/svt \
sw/util/sw \
sw/util/swd \
+ sc/util/sc \
+ sc/util/scd \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
unoxml/source/service/unoxml \
xmloff/util/xo \
+ i18npool/source/search/i18nsearch \
))
$(eval $(call gb_CppunitTest_use_configuration,desktop_lib))
diff --git a/desktop/qa/data/search.ods b/desktop/qa/data/search.ods
new file mode 100644
index 000000000000..ea1d73153828
--- /dev/null
+++ b/desktop/qa/data/search.ods
Binary files differ
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a7696d824bee..3e00e597c314 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -16,6 +16,11 @@
#include <sfx2/objsh.hxx>
#include <sfx2/lokhelper.hxx>
#include <test/unoapi_test.hxx>
+#include <comphelper/lok.hxx>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <svl/srchitem.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include "../../inc/lib/init.hxx"
@@ -45,14 +50,17 @@ public:
UnoApiTest::tearDown();
};
- LibLODocument_Impl* loadDoc(const char* pName);
+ LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType eType = LOK_DOCTYPE_TEXT);
void closeDoc();
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
void testGetStyles();
void testGetFonts();
void testCreateView();
void testGetFilterTypes();
void testGetPartPageRectangles();
+ void testSearchCalc();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -60,16 +68,31 @@ public:
CPPUNIT_TEST(testCreateView);
CPPUNIT_TEST(testGetFilterTypes);
CPPUNIT_TEST(testGetPartPageRectangles);
+ CPPUNIT_TEST(testSearchCalc);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
+ OString m_aTextSelection;
};
-LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName)
+LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
{
OUString aFileURL;
createFileURL(OUString::createFromAscii(pName), aFileURL);
- mxComponent = loadFromDesktop(aFileURL, "com.sun.star.text.TextDocument");
+ OUString aService;
+ switch (eType)
+ {
+ case LOK_DOCTYPE_TEXT:
+ aService = "com.sun.star.text.TextDocument";
+ break;
+ case LOK_DOCTYPE_SPREADSHEET:
+ aService = "com.sun.star.sheet.SpreadsheetDocument";
+ break;
+ default:
+ CPPUNIT_ASSERT(false);
+ break;
+ }
+ mxComponent = loadFromDesktop(aFileURL, aService);
if (!mxComponent.is())
{
CPPUNIT_ASSERT(false);
@@ -86,6 +109,23 @@ void DesktopLOKTest::closeDoc()
}
}
+void DesktopLOKTest::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<DesktopLOKTest*>(pData)->callbackImpl(nType, pPayload);
+}
+
+void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
+{
+ switch (nType)
+ {
+ case LOK_CALLBACK_TEXT_SELECTION:
+ {
+ m_aTextSelection = pPayload;
+ }
+ break;
+ }
+}
+
void DesktopLOKTest::testGetStyles()
{
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
@@ -191,6 +231,36 @@ void DesktopLOKTest::testGetFilterTypes()
free(pJSON);
}
+void DesktopLOKTest::testSearchCalc()
+{
+ LibLibreOffice_Impl aOffice;
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("search.ods");
+ pDocument->pClass->initializeForRendering(pDocument);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("foo"))},
+ {"SearchItem.Backward", uno::makeAny(false)},
+ {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))},
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+
+ std::vector<OString> aSelections;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ OString aToken = m_aTextSelection.getToken(0, ';', nIndex);
+ aSelections.push_back(aToken);
+ } while (nIndex >= 0);
+ // This was 1, find-all only found one match.
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aSelections.size());
+
+ closeDoc();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();