Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/txtsrv.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 0f6fc44cee6..38d3c6b128d 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1217,6 +1217,61 @@ static void test_notifications( void ) ITextHost_Release( host ); }
+static void test_TxSendMesssage_gettext(void) +{ + const WCHAR *expected_string; + IOleClientSite *clientsite; + ITextServices *txtserv; + IRichEditOle *reole; + GETTEXTEX gettextex; + WCHAR buffer[1024]; + REOBJECT reobject; + ITextHost *host; + LRESULT result; + HRESULT hr; + + init_texthost(&txtserv, &host); + + hr = ITextServices_TxSetText(txtserv, L"abcdefg"); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + hr = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&reole); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + fill_reobject_struct(&reobject, 3, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); + hr = IRichEditOle_InsertObject(reole, &reobject); + ok(hr == S_OK, "Got hr: %#x.\n", hr); + + expected_string = L"abc defg"; + hr = ITextServices_TxSendMessage(txtserv, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + expected_string = L"abc\xfffc""defg"; + gettextex.cb = sizeof(buffer); + gettextex.flags = GT_DEFAULT; + gettextex.codepage = 1200; + gettextex.lpDefaultChar = NULL; + gettextex.lpUsedDefChar = NULL; + memset(buffer, 0, sizeof(buffer)); + hr = ITextServices_TxSendMessage(txtserv, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + gettextex.flags = GT_RAWTEXT; + memset(buffer, 0, sizeof(buffer)); + hr = ITextServices_TxSendMessage(txtserv, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer, &result); + ok(result == lstrlenW(expected_string), "Got wrong length: %ld.\n", result); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + IOleClientSite_Release(clientsite); + IRichEditOle_Release(reole); + ITextServices_Release(txtserv); + ITextHost_Release(host); +} + START_TEST( txtsrv ) { ITextServices *txtserv; @@ -1250,6 +1305,7 @@ START_TEST( txtsrv ) test_default_format(); test_TxGetScroll(); test_notifications(); + test_TxSendMesssage_gettext(); } if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE); }