summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-04-01 16:43:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-07 09:18:09 +0200
commit21bc58db192459313669ae7ca58d2e003c8c8a20 (patch)
tree7452315a6cbd7cad32fec1fa6e0bd951be3288c7 /sd
parent2502121e5e16888e92cc2da93da8d930ca01b348 (diff)
Add SdXImpressDocument::postMouseEvent() testcase.
Change-Id: I1bb371a897e71044d4acd05d7482b6a1c4bdcb4b
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index d1e924db3c39..7356a7ca7194 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -12,12 +12,18 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
#include <test/bootstrapfixture.hxx>
#include <test/xmltesttools.hxx>
#include <unotest/macros_test.hxx>
#include <DrawDocShell.hxx>
#include <ViewShell.hxx>
+#include <sdpage.hxx>
#include <unomodel.hxx>
using namespace css;
@@ -31,10 +37,12 @@ public:
virtual void tearDown() SAL_OVERRIDE;
void testRegisterCallback();
+ void testPostMouseEvent();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
#if !defined(WNT) && !defined(MACOSX)
CPPUNIT_TEST(testRegisterCallback);
+ CPPUNIT_TEST(testPostMouseEvent);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -118,6 +126,33 @@ void SdTiledRenderingTest::testRegisterCallback()
CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft));
}
+void SdTiledRenderingTest::testPostMouseEvent()
+{
+ SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_TITLETEXT), pObject->GetObjIdentifier());
+ SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObject);
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pTextObj, pView->GetSdrPageView());
+ SfxStringItem aInputString(SID_ATTR_CHAR, "x");
+ pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR, SfxCallMode::SYNCHRON, &aInputString, 0);
+ CPPUNIT_ASSERT(pView->GetTextEditObject());
+ EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+ // Did we manage to go after the first character?
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), rEditView.GetSelection().nStartPos);
+
+ vcl::Cursor* pCursor = rEditView.GetCursor();
+ Point aPosition = pCursor->GetPos();
+ aPosition.setX(aPosition.getX() - 1000);
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, convertMm100ToTwip(aPosition.getX()), convertMm100ToTwip(aPosition.getY()), 1);
+ pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, convertMm100ToTwip(aPosition.getX()), convertMm100ToTwip(aPosition.getY()), 1);
+ CPPUNIT_ASSERT(pView->GetTextEditObject());
+ // The new cursor position must be before the first word.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rEditView.GetSelection().nStartPos);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();