[Libreoffice-commits] core.git: sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Wed May 20 09:41:14 PDT 2015


 sw/qa/extras/tiledrendering/data/search.odt    |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   41 +++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

New commits:
commit 01d422d8659d1b19676de16b199c3438a148506f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed May 20 17:56:33 2015 +0200

    Add SwTiledRenderingTest::testSearch() testcase.
    
    Fails if the last hunk of commit
    bdc1824ea7acfa2fe9d71cdbe57882acce155577 (SwPaM::Find: search in shapes
    anchored to the range, 2015-05-19) is reverted.
    
    Change-Id: Id239e781ce493ee8952bcd9a018aa78146933433

diff --git a/sw/qa/extras/tiledrendering/data/search.odt b/sw/qa/extras/tiledrendering/data/search.odt
new file mode 100644
index 0000000..5fb02fa
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/search.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index da6fdb5..3ba4dbd 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();


More information about the Libreoffice-commits mailing list