From: Francois Gouget fgouget@codeweavers.com
On Windows EM_GETSELTEXT fails to convert strings containing \xfffb to ANSI 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=54565 --- dlls/riched20/tests/richole.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 7ec6036fea6..03873920cdd 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,20 @@ static void subtest_InsertObject(struct reolecb_obj *callback) ok( !!sendres, "EM_SETOLECALLBACK should succeed\n" ); }
+ *bufferA = '\0'; + string = L"a\xfffb"; + SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)string); + SendMessageA(hwnd, EM_SETSEL, 0, -1); + 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(\xfffb) failed: gle=%lu\n", gle); + bad_getsel = (gle != 0xdeadbeef); + if (bad_getsel) + trace("EM_GETSELTEXT(%s) is broken\n", wine_dbgstr_w(string)); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
hr = IRichEditOle_InsertObject(reole, NULL); @@ -4068,9 +4084,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 +4171,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;