summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-04-08 17:48:21 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-13 09:07:03 +0200
commit207142748b095252f5c9bfd1b418a892823304d0 (patch)
tree8b422c01ba80841c1d1fe9fe0d5db1cde67bf131
parent3e6d192b048b4742a5cf522c1414aaa6a7ed3dee (diff)
Add SwXTextDocument::postKeyEvent() testcase.
Change-Id: I76904ed9596dcb0b6aa70bccd19279573687d30c
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 23d3fe281440..67c04db7df2c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -15,6 +15,7 @@
#include <vcl/svapp.hxx>
#include <crsskip.hxx>
#include <drawdoc.hxx>
+#include <ndtxt.hxx>
#include <wrtsh.hxx>
static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
@@ -24,6 +25,7 @@ class SwTiledRenderingTest : public SwModelTestBase
{
public:
void testRegisterCallback();
+ void testPostKeyEvent();
void testPostMouseEvent();
void testSetTextSelection();
void testSetGraphicSelection();
@@ -31,6 +33,7 @@ public:
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
+ CPPUNIT_TEST(testPostKeyEvent);
CPPUNIT_TEST(testPostMouseEvent);
CPPUNIT_TEST(testSetTextSelection);
CPPUNIT_TEST(testSetGraphicSelection);
@@ -110,6 +113,21 @@ void SwTiledRenderingTest::testRegisterCallback()
#endif
}
+void SwTiledRenderingTest::testPostKeyEvent()
+{
+ SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+ SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+ SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
+ // Did we manage to go after the first character?
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), pShellCrsr->GetPoint()->nContent.GetIndex());
+
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ // Did we manage to insert the character after the first one?
+ CPPUNIT_ASSERT_EQUAL(OUString("Axaa bbb."), pShellCrsr->GetPoint()->nNode.GetNode().GetTxtNode()->GetTxt());
+}
+
void SwTiledRenderingTest::testPostMouseEvent()
{
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");