From: Francois Gouget fgouget@codeweavers.com
On Windows EM_GETSELTEXT fails with an invalid parameter error in the Hindi locale but works in most other locales, including UTF-8 ones. So check for this issue and adjust the expected results accordingly.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54559 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54565 --- dlls/riched20/tests/editor.c | 29 +++++++++++++++++++++++++---- dlls/riched20/tests/richole.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index e7e79db1805..f282c64f39c 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -1891,20 +1891,41 @@ static void test_EM_GETSELTEXT(void) const char * expect = "bar\rfoo"; char buffer[1024] = {0}; LRESULT result; + BOOL bad_getsel; + DWORD gle; + + SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"a"); + SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1); + SetLastError(0xdeadbeef); + result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); + gle = GetLastError(); + ok((result > 0 && gle == 0xdeadbeef) || + broken(result == 0 && gle == ERROR_INVALID_PARAMETER /* Hindi */), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + bad_getsel = (gle != 0xdeadbeef); + if (bad_getsel) + trace("EM_GETSELTEXT is broken, some tests will be ignored\n");
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
SendMessageA(hwndRichEdit, EM_SETSEL, 4, 11); + SetLastError(0xdeadbeef); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); - ok(result == 7, "EM_GETSELTEXT returned %Id\n", result); - ok(!strcmp(expect, buffer), "EM_GETSELTEXT filled %s\n", buffer); + gle = GetLastError(); + ok(result == 7 || broken(bad_getsel && result == 0), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + ok(!strcmp(expect, buffer) || broken(bad_getsel && !*buffer), + "EM_GETSELTEXT filled %s gle=%lu\n", buffer, gle);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2);
SendMessageA(hwndRichEdit, EM_SETSEL, 4, 11); + SetLastError(0xdeadbeef); result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer); - ok(result == 7, "EM_GETSELTEXT returned %Id\n", result); - ok(!strcmp(expect, buffer), "EM_GETSELTEXT filled %s\n", buffer); + ok(result == 7 || broken(bad_getsel && result == 0), + "EM_GETSELTEXT returned %Id gle=%lu\n", result, gle); + ok(!strcmp(expect, buffer) || broken(bad_getsel && !*buffer), + "EM_GETSELTEXT filled %s gle=%lu\n", buffer, gle);
/* Test with multibyte character */ if (!is_lang_japanese) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 7ec6036fea6..7402541ed6e 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3881,6 +3881,8 @@ static void subtest_InsertObject(struct reolecb_obj *callback) struct testoleobj *testobj; IOleClientSite *clientsite; REOBJECT reobj; + BOOL bad_getsel; + DWORD gle;
create_interfaces(&hwnd, &reole, &doc, &selection); if (callback) @@ -3889,6 +3891,19 @@ static void subtest_InsertObject(struct reolecb_obj *callback) ok( !!sendres, "EM_SETOLECALLBACK should succeed\n" ); }
+ SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"a"); + SendMessageA(hwnd, EM_SETSEL, 0, -1); + *bufferA = '\0'; + SetLastError(0xdeadbeef); + result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); + gle = GetLastError(); + ok((result > 0 && gle == 0xdeadbeef) || + broken(result == 0 && gle == ERROR_INVALID_PARAMETER /* Hindi */), + "EM_GETSELTEXT returned %ld gle=%lu\n", result, gle); + bad_getsel = (gle != 0xdeadbeef); + if (bad_getsel) + trace("EM_GETSELTEXT is broken, some tests will be ignored\n"); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
hr = IRichEditOle_InsertObject(reole, NULL); @@ -4068,9 +4083,13 @@ static void subtest_InsertObject(struct reolecb_obj *callback) expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); SendMessageA(hwnd, EM_SETSEL, 0, -1); + SetLastError(0xdeadbeef); result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); - ok(result == strlen(expected_stringA), "Got wrong length: %ld.\n", result); - ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + gle = GetLastError(); + ok(result == strlen(expected_stringA) || broken(bad_getsel && result == 0), + "Got wrong length: %ld (gle %lu)\n", result, gle); + ok(!strcmp(bufferA, expected_stringA) || broken(bad_getsel && !*bufferA), + "Got wrong content: %s (gle %lu)\n", bufferA, gle);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; @@ -4151,9 +4170,13 @@ static void subtest_InsertObject(struct reolecb_obj *callback) expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); SendMessageA(hwnd, EM_SETSEL, 0, -1); + SetLastError(0xdeadbeef); result = SendMessageA(hwnd, EM_GETSELTEXT, 0, (LPARAM)bufferA); - ok(result == strlen(expected_stringA), "Got wrong length: %ld.\n", result); - ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + gle = GetLastError(); + ok(result == strlen(expected_stringA) || broken(bad_getsel && result == 0), + "Got wrong length: %ld (gle %lu)\n", result, gle); + ok(!strcmp(bufferA, expected_stringA) || broken(bad_getsel && !*bufferA), + "Got wrong content: %s (gle %lu)\n", bufferA, gle);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA;