diff options
Diffstat (limited to 'sw/qa/core/doc/doc.cxx')
-rw-r--r-- | sw/qa/core/doc/doc.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 14f724328fe0..bda78bda8e48 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -18,6 +18,7 @@ #include <editeng/langitem.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> +#include <vcl/scheduler.hxx> #include <wrtsh.hxx> #include <fmtanchr.hxx> @@ -29,6 +30,7 @@ #include <swdtflvr.hxx> #include <cmdid.h> #include <unotxdoc.hxx> +#include <UndoManager.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/doc/data/"; @@ -165,6 +167,36 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextBoxMakeFlyFrame) assertXPath(pLayout, "/root/page/body/txt/anchored/fly", 1); } +CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testIMEGrouping) +{ +// TODO figure out why the ext text input in this test code reaches the wrong window on +// non-headless. +#if !defined MACOSX && !defined _WIN32 + // Given an empty document: + SwDoc* pDoc = createSwDoc(); + // Make sure no idle is in action, so the ExtTextInput events go to SwEditWin. + Scheduler::ProcessEventsToIdle(); + + // When pressing two keys via IME: + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin(); + rEditWin.PostExtTextInputEvent(VclEventId::ExtTextInput, "a"); + rEditWin.PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + rEditWin.PostExtTextInputEvent(VclEventId::ExtTextInput, "b"); + rEditWin.PostExtTextInputEvent(VclEventId::EndExtTextInput, ""); + + // Then make sure that gets grouped together to a single undo action: + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode(); + CPPUNIT_ASSERT_EQUAL(OUString("ab"), pTextNode->GetText()); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 2 + // i.e. 2 subsequent IME events got their own undo actions. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDoc->GetUndoManager().GetUndoActionCount()); +#endif +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |