summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-04-03 16:52:44 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-07 09:18:17 +0200
commita2222ba2febf572d223142d824200c56d4f4c450 (patch)
tree15986b399ab51ecd7b3bcd42e770dfa40b28f9ae
parentd4a39c158bdf67fe10d12b97f779f95568e51a98 (diff)
Add SdXImpressDocument::setTextSelection() testcase.
Also, avoid early dispose in testRegisterCallback(), that was just a hack as I did not find SdrBeginTextEdit(). Change-Id: Ic0576306297b4081979c2409c376867c7f530e2c
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx42
1 files changed, 36 insertions, 6 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 7356a7ca7194..0a4665c97611 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -38,11 +38,13 @@ public:
void testRegisterCallback();
void testPostMouseEvent();
+ void testSetTextSelection();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
#if !defined(WNT) && !defined(MACOSX)
CPPUNIT_TEST(testRegisterCallback);
CPPUNIT_TEST(testPostMouseEvent);
+ CPPUNIT_TEST(testSetTextSelection);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -109,16 +111,16 @@ void SdTiledRenderingTest::callbackImpl(int nType, const char* pPayload)
void SdTiledRenderingTest::testRegisterCallback()
{
- // Tests sd::Window::LogicInvalidate().
SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
pXImpressDocument->registerCallback(&SdTiledRenderingTest::callback, this);
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
- // Append a character to the empty title shape.
- vcl::KeyCode aKeyCode(0, 0);
- KeyEvent aKeyEvent(static_cast<sal_Unicode>('x'), aKeyCode, 0);
- pViewShell->KeyInput(aKeyEvent, 0);
- mxComponent->dispose();
+ // Start text edit of the empty title shape.
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->SdrBeginTextEdit(pObject);
+ CPPUNIT_ASSERT(pView->GetTextEditObject());
// Check that the top left 256x256px tile would be invalidated.
CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty());
@@ -153,6 +155,34 @@ void SdTiledRenderingTest::testPostMouseEvent()
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rEditView.GetSelection().nStartPos);
}
+void SdTiledRenderingTest::testSetTextSelection()
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+ xShape->setString("Aaa bbb.");
+ // Create a selection on the second word.
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ SdrView* pView = pViewShell->GetView();
+ pView->SdrBeginTextEdit(pObject);
+ CPPUNIT_ASSERT(pView->GetTextEditObject());
+ EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+ ESelection aWordSelection(0, 4, 0, 7);
+ rEditView.SetSelection(aWordSelection);
+ // Did we indeed manage to select the second word?
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb"), rEditView.GetSelected());
+
+ // Now use setTextSelection() to move the end of the selection 1000 twips right.
+ vcl::Cursor* pCursor = rEditView.GetCursor();
+ Point aEnd = pCursor->GetPos();
+ aEnd.setX(aEnd.getX() + 1000);
+ pXImpressDocument->setTextSelection(LOK_SETTEXTSELECTION_END, aEnd.getX(), aEnd.getY());
+ // The new selection must include the ending dot, too -- but not the first word.
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb."), rEditView.GetSelected());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();