diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2018-02-07 21:23:42 +0530 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2018-02-08 09:44:51 +0100 |
commit | b746577d27437f9298fa111512d083eaccd4fbed (patch) | |
tree | 9d10d171d4f1e39cd643eb3e09af30d9a5c96e26 /sd/qa | |
parent | 0d0c13bfbdff85a18433aee6e94558689f0cb722 (diff) |
sd, sc lok: IME support + unit tests
Change-Id: I710ba4347977641102b89fd274a159d34bc29e72
Reviewed-on: https://gerrit.libreoffice.org/49385
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 93c76ffaa037..c32e9876971c 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -107,6 +107,7 @@ public: void testDocumentRepair(); void testLanguageStatus(); void testDefaultView(); + void testIMESupport(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -147,6 +148,7 @@ public: CPPUNIT_TEST(testDocumentRepair); CPPUNIT_TEST(testLanguageStatus); CPPUNIT_TEST(testDefaultView); + CPPUNIT_TEST(testIMESupport); CPPUNIT_TEST_SUITE_END(); @@ -1940,6 +1942,46 @@ void SdTiledRenderingTest::testDefaultView() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testIMESupport() +{ + // Load the document with notes view. + comphelper::LibreOfficeKit::setActive(); + + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdrObject* pObject = pViewShell->GetActualPage()->GetObj(0); + SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObject); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pTextObj, pView->GetSdrPageView()); + SfxStringItem aInputString(SID_ATTR_CHAR, "x"); + pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(SID_ATTR_CHAR, + SfxCallMode::SYNCHRON, { &aInputString }); + + // sequence of chineese IME compositions when 'nihao' is typed in an IME + const std::vector<OString> aUtf8Inputs{ "年", "你", "你好", "你哈", "你好", "你好" }; + std::vector<OUString> aInputs; + std::transform(aUtf8Inputs.begin(), aUtf8Inputs.end(), + std::back_inserter(aInputs), [](OString aInput) { + return OUString::fromUtf8(aInput); + }); + for (const auto& aInput: aInputs) + { + pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT, aInput); + } + pXImpressDocument->postExtTextInputEvent(LOK_EXT_TEXTINPUT_END, ""); + + // the cursor should be at position 3rd + EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), rEditView.GetSelection().nStartPos); + + ESelection aWordSelection(0, 0, 0, 3); // start para, start char, end para, end char. + rEditView.SetSelection(aWordSelection); + // content contains only the last IME composition, not all + CPPUNIT_ASSERT_EQUAL(OUString("x").concat(aInputs[aInputs.size() - 1]), rEditView.GetSelected()); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); |