summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/tiledrendering/data/search.odtbin0 -> 10750 bytes
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx41
2 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt
new file mode 100644
index 000000000000..5fb02fa1705d
--- /dev/null
+++ b/sw/qa/extras/tiledrendering/data/search.odt
Binary files differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index da6fdb5235ec..3ba4dbd94fde 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/string.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
@@ -30,6 +32,7 @@ public:
void testSetTextSelection();
void testSetGraphicSelection();
void testResetSelection();
+ void testSearch();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -38,6 +41,7 @@ public:
CPPUNIT_TEST(testSetTextSelection);
CPPUNIT_TEST(testSetGraphicSelection);
CPPUNIT_TEST(testResetSelection);
+ CPPUNIT_TEST(testSearch);
CPPUNIT_TEST_SUITE_END();
private:
@@ -221,6 +225,43 @@ void SwTiledRenderingTest::testResetSelection()
CPPUNIT_ASSERT(!pWrtShell->IsSelFrmMode());
}
+void lcl_search()
+{
+ uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ {"SearchItem.SearchString", uno::makeAny(OUString("shape"))},
+ {"SearchItem.Backward", uno::makeAny(false)}
+ }));
+ comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+}
+
+void SwTiledRenderingTest::testSearch()
+{
+ SwXTextDocument* pXTextDocument = createDoc("search.odt");
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ size_t nNode = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex();
+
+ // First hit, in the second paragraph, before the shape.
+ lcl_search();
+ CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject());
+ size_t nActual = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex();
+ CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual);
+
+ // Next hit, in the shape.
+ lcl_search();
+ CPPUNIT_ASSERT(pWrtShell->GetDrawView()->GetTextEditObject());
+
+ // Next hit, in the shape, still.
+ lcl_search();
+ CPPUNIT_ASSERT(pWrtShell->GetDrawView()->GetTextEditObject());
+
+ // Last hit, in the last paragraph, after the shape.
+ lcl_search();
+ CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject());
+ nActual = pWrtShell->getShellCrsr(false)->Start()->nNode.GetNode().GetIndex();
+ CPPUNIT_ASSERT_EQUAL(nNode + 7, nActual);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();