Skip to content

Commit 339cfc7

Browse files
committed
[RICHED20_WINETEST] Sync to Wine-6.10. Commit before PR reactos#7611.
1 parent aebaa14 commit 339cfc7

File tree

4 files changed

+916
-454
lines changed

4 files changed

+916
-454
lines changed

modules/rostests/winetests/riched20/editor.c

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <ole2.h>
3434
#include <richedit.h>
3535
#include <richole.h>
36+
#include <imm.h>
37+
#include <textserv.h>
3638
#include <commdlg.h>
3739
#include <time.h>
3840
#include <wine/test.h>
@@ -51,12 +53,38 @@ static CHAR string1[MAX_PATH], string2[MAX_PATH], string3[MAX_PATH];
5153
static HMODULE hmoduleRichEdit;
5254
static BOOL is_lang_japanese;
5355

56+
#if defined(__i386__) && !defined(__MINGW32__) && (!defined(_MSC_VER) || !defined(__clang__))
57+
static void disable_beep( HWND hwnd )
58+
{
59+
/* don't attempt to disable beep if we don't have thiscall compiler support */
60+
}
61+
#else
62+
#define ITextServices_OnTxPropertyBitsChange(This,a,b) (This)->lpVtbl->OnTxPropertyBitsChange(This,a,b)
63+
static void disable_beep( HWND hwnd )
64+
{
65+
IRichEditOle *richole;
66+
ITextServices *services;
67+
IID *pIID_ITextServices = (IID *)GetProcAddress( hmoduleRichEdit, "IID_ITextServices" );
68+
69+
if (SendMessageW( hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&richole ))
70+
{
71+
if (SUCCEEDED( IRichEditOle_QueryInterface( richole, pIID_ITextServices, (void **)&services ) ))
72+
{
73+
ITextServices_OnTxPropertyBitsChange( services, TXTBIT_ALLOWBEEP, 0 );
74+
ITextServices_Release( services );
75+
}
76+
IRichEditOle_Release( richole );
77+
}
78+
}
79+
#endif
80+
5481
static HWND new_window(LPCSTR lpClassName, DWORD dwStyle, HWND parent) {
5582
HWND hwnd;
5683
hwnd = CreateWindowA(lpClassName, NULL, dwStyle|WS_POPUP|WS_HSCROLL|WS_VSCROLL
5784
|WS_VISIBLE, 0, 0, 200, 60, parent, NULL,
5885
hmoduleRichEdit, NULL);
5986
ok(hwnd != NULL, "class: %s, error: %d\n", lpClassName, (int) GetLastError());
87+
disable_beep( hwnd );
6088
return hwnd;
6189
}
6290

@@ -66,6 +94,7 @@ static HWND new_windowW(LPCWSTR lpClassName, DWORD dwStyle, HWND parent) {
6694
|WS_VISIBLE, 0, 0, 200, 60, parent, NULL,
6795
hmoduleRichEdit, NULL);
6896
ok(hwnd != NULL, "class: %s, error: %d\n", wine_dbgstr_w(lpClassName), (int) GetLastError());
97+
disable_beep( hwnd );
6998
return hwnd;
7099
}
71100

@@ -615,7 +644,7 @@ static void test_EM_POSFROMCHAR(void)
615644
"gg\n"
616645
"hh\n";
617646

618-
rtl = (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_FONTSIGNATURE,
647+
rtl = (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_FONTSIGNATURE,
619648
(LPSTR) &sig, sizeof(LOCALESIGNATURE)) &&
620649
(sig.lsUsb[3] & 0x08000000) != 0);
621650

@@ -772,7 +801,7 @@ static void test_EM_SETCHARFORMAT(void)
772801
BOOL rtl;
773802
DWORD expect_effects;
774803

775-
rtl = (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_FONTSIGNATURE,
804+
rtl = (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_FONTSIGNATURE,
776805
(LPSTR) &sig, sizeof(LOCALESIGNATURE)) &&
777806
(sig.lsUsb[3] & 0x08000000) != 0);
778807

@@ -1791,8 +1820,8 @@ static void test_EM_GETTEXTRANGE(void)
17911820
textRange.chrg.cpMin = 4;
17921821
textRange.chrg.cpMax = 8;
17931822
result = SendMessageA(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
1794-
todo_wine ok(result == 5, "EM_GETTEXTRANGE returned %ld\n", result);
1795-
todo_wine ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
1823+
ok(result == 5, "EM_GETTEXTRANGE returned %ld\n", result);
1824+
ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
17961825
}
17971826

17981827
DestroyWindow(hwndRichEdit);
@@ -1829,8 +1858,8 @@ static void test_EM_GETSELTEXT(void)
18291858
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"abcdef\x8e\xf0ghijk");
18301859
SendMessageA(hwndRichEdit, EM_SETSEL, 4, 8);
18311860
result = SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
1832-
todo_wine ok(result == 5, "EM_GETSELTEXT returned %ld\n", result);
1833-
todo_wine ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETSELTEXT filled %s\n", buffer);
1861+
ok(result == 5, "EM_GETSELTEXT returned %ld\n", result);
1862+
ok(!strcmp("ef\x8e\xf0g", buffer), "EM_GETSELTEXT filled %s\n", buffer);
18341863
}
18351864

18361865
DestroyWindow(hwndRichEdit);
@@ -1863,6 +1892,7 @@ static void test_EM_SETOPTIONS(void)
18631892
hmoduleRichEdit, NULL);
18641893
ok(hwndRichEdit != NULL, "class: %s, error: %d\n",
18651894
RICHEDIT_CLASS20A, (int) GetLastError());
1895+
disable_beep( hwndRichEdit );
18661896
options = SendMessageA(hwndRichEdit, EM_GETOPTIONS, 0, 0);
18671897
/* WS_[VH]SCROLL cause the ECO_AUTO[VH]SCROLL options to be set */
18681898
ok(options == (ECO_AUTOVSCROLL|ECO_AUTOHSCROLL),
@@ -3110,11 +3140,9 @@ static void test_scrollbar_visibility(void)
31103140
GetScrollInfo(hwndRichEdit, SB_VERT, &si);
31113141
ok (((GetWindowLongA(hwndRichEdit, GWL_STYLE) & WS_VSCROLL) != 0),
31123142
"Vertical scrollbar is invisible, should be visible.\n");
3113-
todo_wine {
31143143
ok(si.nPage == 0 && si.nMin == 0 && si.nMax == 100,
31153144
"reported page/range is %d (%d..%d) expected 0 (0..100)\n",
31163145
si.nPage, si.nMin, si.nMax);
3117-
}
31183146

31193147
/* Ditto, see above */
31203148
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0);
@@ -3124,11 +3152,9 @@ static void test_scrollbar_visibility(void)
31243152
GetScrollInfo(hwndRichEdit, SB_VERT, &si);
31253153
ok (((GetWindowLongA(hwndRichEdit, GWL_STYLE) & WS_VSCROLL) != 0),
31263154
"Vertical scrollbar is invisible, should be visible.\n");
3127-
todo_wine {
31283155
ok(si.nPage == 0 && si.nMin == 0 && si.nMax == 100,
31293156
"reported page/range is %d (%d..%d) expected 0 (0..100)\n",
31303157
si.nPage, si.nMin, si.nMax);
3131-
}
31323158

31333159
/* Ditto, see above */
31343160
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"a");
@@ -3138,11 +3164,9 @@ static void test_scrollbar_visibility(void)
31383164
GetScrollInfo(hwndRichEdit, SB_VERT, &si);
31393165
ok (((GetWindowLongA(hwndRichEdit, GWL_STYLE) & WS_VSCROLL) != 0),
31403166
"Vertical scrollbar is invisible, should be visible.\n");
3141-
todo_wine {
31423167
ok(si.nPage == 0 && si.nMin == 0 && si.nMax == 100,
31433168
"reported page/range is %d (%d..%d) expected 0 (0..100)\n",
31443169
si.nPage, si.nMin, si.nMax);
3145-
}
31463170

31473171
/* Ditto, see above */
31483172
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"a\na");
@@ -3152,11 +3176,9 @@ static void test_scrollbar_visibility(void)
31523176
GetScrollInfo(hwndRichEdit, SB_VERT, &si);
31533177
ok (((GetWindowLongA(hwndRichEdit, GWL_STYLE) & WS_VSCROLL) != 0),
31543178
"Vertical scrollbar is invisible, should be visible.\n");
3155-
todo_wine {
31563179
ok(si.nPage == 0 && si.nMin == 0 && si.nMax == 100,
31573180
"reported page/range is %d (%d..%d) expected 0 (0..100)\n",
31583181
si.nPage, si.nMin, si.nMax);
3159-
}
31603182

31613183
/* Ditto, see above */
31623184
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0);
@@ -3166,11 +3188,9 @@ static void test_scrollbar_visibility(void)
31663188
GetScrollInfo(hwndRichEdit, SB_VERT, &si);
31673189
ok (((GetWindowLongA(hwndRichEdit, GWL_STYLE) & WS_VSCROLL) != 0),
31683190
"Vertical scrollbar is invisible, should be visible.\n");
3169-
todo_wine {
31703191
ok(si.nPage == 0 && si.nMin == 0 && si.nMax == 100,
31713192
"reported page/range is %d (%d..%d) expected 0 (0..100)\n",
31723193
si.nPage, si.nMin, si.nMax);
3173-
}
31743194

31753195
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text);
31763196
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, 0);
@@ -5610,7 +5630,7 @@ static void test_EM_FORMATRANGE(void)
56105630
{"WINE\r\n\r\nwine\r\nwine", 5, 6}
56115631
};
56125632

5613-
skip_non_english = (PRIMARYLANGID(GetUserDefaultLangID()) != LANG_ENGLISH);
5633+
skip_non_english = (PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_ENGLISH);
56145634
if (skip_non_english)
56155635
skip("Skipping some tests on non-English platform\n");
56165636

@@ -6348,6 +6368,7 @@ static void test_WM_CHAR(void)
63486368
hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP,
63496369
0, 0, 200, 60, 0, 0, 0, 0);
63506370
ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError());
6371+
disable_beep( hwnd );
63516372

63526373
p = char_list;
63536374
while (*p != '\0') {
@@ -6951,6 +6972,7 @@ static void test_undo_coalescing(void)
69516972
hwnd = CreateWindowExA(0, "RichEdit20W", NULL, WS_POPUP|ES_MULTILINE,
69526973
0, 0, 200, 60, 0, 0, 0, 0);
69536974
ok(hwnd != 0, "CreateWindowExA error %u\n", GetLastError());
6975+
disable_beep( hwnd );
69546976

69556977
result = SendMessageA(hwnd, EM_CANUNDO, 0, 0);
69566978
ok (result == FALSE, "Can undo after window creation.\n");
@@ -7461,12 +7483,25 @@ static void test_format_rect(void)
74617483
ok(EqualRect(&rc, &expected), "rect %s != %s\n", wine_dbgstr_rect(&rc),
74627484
wine_dbgstr_rect(&expected));
74637485

7486+
/* reset back to client rect and now try adding selection bar */
7487+
SendMessageA(hwnd, EM_SETRECT, 0, 0);
7488+
expected = clientRect;
7489+
InflateRect(&expected, -1, 0);
7490+
SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc);
7491+
ok(EqualRect(&rc, &expected), "rect %s != %s\n", wine_dbgstr_rect(&rc),
7492+
wine_dbgstr_rect(&expected));
7493+
SendMessageA(hwnd, EM_SETOPTIONS, ECOOP_OR, ECO_SELECTIONBAR);
7494+
SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc);
7495+
ok(EqualRect(&rc, &expected), "rect %s != %s\n", wine_dbgstr_rect(&rc),
7496+
wine_dbgstr_rect(&expected));
7497+
SendMessageA(hwnd, EM_SETOPTIONS, ECOOP_AND, ~ECO_SELECTIONBAR);
7498+
74647499
/* Set the absolute value of the formatting rectangle. */
74657500
rc = clientRect;
74667501
SendMessageA(hwnd, EM_SETRECT, 0, (LPARAM)&rc);
74677502
expected = clientRect;
74687503
SendMessageA(hwnd, EM_GETRECT, 0, (LPARAM)&rc);
7469-
ok(EqualRect(&rc, &expected), "[n=%d] rect %s != %s\n", n, wine_dbgstr_rect(&rc),
7504+
ok(EqualRect(&rc, &expected), "rect %s != %s\n", wine_dbgstr_rect(&rc),
74707505
wine_dbgstr_rect(&expected));
74717506

74727507
/* MSDN documents the EM_SETRECT message as using the rectangle provided in
@@ -8987,48 +9022,15 @@ static void test_EM_SELECTIONTYPE(void)
89879022
DestroyWindow(hwnd);
89889023
}
89899024

8990-
static void test_window_classes(void)
8991-
{
8992-
static const struct
8993-
{
8994-
const char *class;
8995-
BOOL success;
8996-
} test[] =
8997-
{
8998-
{ "RichEdit", FALSE },
8999-
{ "RichEdit20A", TRUE },
9000-
{ "RichEdit20W", TRUE },
9001-
{ "RichEdit50A", FALSE },
9002-
{ "RichEdit50W", FALSE }
9003-
};
9004-
int i;
9005-
HWND hwnd;
9006-
9007-
for (i = 0; i < sizeof(test)/sizeof(test[0]); i++)
9008-
{
9009-
SetLastError(0xdeadbeef);
9010-
hwnd = CreateWindowExA(0, test[i].class, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL);
9011-
todo_wine_if(!strcmp(test[i].class, "RichEdit50A") || !strcmp(test[i].class, "RichEdit50W"))
9012-
ok(!hwnd == !test[i].success, "CreateWindow(%s) should %s\n",
9013-
test[i].class, test[i].success ? "succeed" : "fail");
9014-
if (!hwnd)
9015-
todo_wine
9016-
ok(GetLastError() == ERROR_CANNOT_FIND_WND_CLASS, "got %d\n", GetLastError());
9017-
else
9018-
DestroyWindow(hwnd);
9019-
}
9020-
}
9021-
90229025
START_TEST( editor )
90239026
{
90249027
BOOL ret;
90259028
/* Must explicitly LoadLibrary(). The test has no references to functions in
90269029
* RICHED20.DLL, so the linker doesn't actually link to it. */
90279030
hmoduleRichEdit = LoadLibraryA("riched20.dll");
90289031
ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
9029-
is_lang_japanese = (PRIMARYLANGID(GetUserDefaultLangID()) == LANG_JAPANESE);
9032+
is_lang_japanese = (PRIMARYLANGID(GetSystemDefaultLangID()) == LANG_JAPANESE);
90309033

9031-
test_window_classes();
90329034
test_WM_CHAR();
90339035
test_EM_FINDTEXT(FALSE);
90349036
test_EM_FINDTEXT(TRUE);

0 commit comments

Comments
 (0)