diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-20 17:56:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-05-20 18:40:34 +0200 |
commit | 01d422d8659d1b19676de16b199c3438a148506f (patch) | |
tree | 6f36c8078eda2421c25049c59f8a1c333c6766d6 /sw | |
parent | 186b1e00017c163fdef5e8ceb1221c2d416b32cf (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/data/search.odt | bin | 0 -> 10750 bytes | |||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 41 |
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 Binary files differnew file mode 100644 index 000000000000..5fb02fa1705d --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/search.odt 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(); |