From: Alanas alanas.00@mail.ru
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57178 --- dlls/comctl32/tests/toolbar.c | 100 +++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 7c886e1f88f..b780cc401f3 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -179,11 +179,47 @@ static BOOL equal_dc(HDC hdc1, HDC hdc2, int width, int height)
static void *alloced_str;
-static LRESULT parent_wnd_notify(LPARAM lParam) +static NMHDR *test_WM_NOTIFY_nmhdr; +static enum { + TEST_WM_NOTIFY_NONE,/* not testing */ + TEST_WM_NOTIFY_SIMPLE_FORWARD,/* nmhdr.code=0xabcd0004 */ + TEST_WM_NOTIFY_CONVERT_FORWARD,/* nmhdr.code=0xfffffd17=DTN_USERSTRINGW before forwarding, nmhdr.code=0xfffffd0a=DTN_USERSTRINGA after forwarding */ + TEST_WM_NOTIFY_NO_FORWARD,/* nmhdr.code=0xfffffc69 */ + TEST_WM_NOTIFY_SIMPLE_FORWARD_DONE, + TEST_WM_NOTIFY_CONVERT_FORWARD_DONE +} test_WM_NOTIFY_state; +#define TEST_WM_NOTIFY_RETURN ((LRESULT)0xabcd0001) +#define TEST_WM_NOTIFY_HWNDFROM ((HWND)0xabcd0002) +#define TEST_WM_NOTIFY_IDFROM ((UINT_PTR)0xabcd0003) +#define TEST_WM_NOTIFY_SIMPLE_FORWARD_CODE ((UINT)0xabcd0004) +#define TEST_WM_NOTIFY_NO_FORWARD_CODE ((UINT)0xfffffc69) + +static LRESULT parent_wnd_notify(WPARAM wParam, LPARAM lParam) { NMHDR *hdr = (NMHDR *)lParam; NMTBHOTITEM *nmhi; NMTBDISPINFOA *nmdisp; + if (test_WM_NOTIFY_state) + { + ok(hdr == test_WM_NOTIFY_nmhdr, "Got unexpected header.\n"); + ok(wParam == TEST_WM_NOTIFY_IDFROM, "Got unexpected wParam 0x%Ix.\n", wParam); + ok(hdr->hwndFrom == TEST_WM_NOTIFY_HWNDFROM, "hwndFrom changed from 0x%Ix to 0x%Ix.\n", (UINT_PTR)TEST_WM_NOTIFY_HWNDFROM, (UINT_PTR)hdr->hwndFrom); + ok(hdr->idFrom == TEST_WM_NOTIFY_IDFROM, "idFrom changed from 0x%Ix to 0x%Ix.\n", TEST_WM_NOTIFY_IDFROM, hdr->idFrom); + switch (test_WM_NOTIFY_state) { + case TEST_WM_NOTIFY_SIMPLE_FORWARD: + ok(hdr->code == TEST_WM_NOTIFY_SIMPLE_FORWARD_CODE, "code changed from 0x%x to 0x%x.\n", TEST_WM_NOTIFY_SIMPLE_FORWARD_CODE, hdr->code); + test_WM_NOTIFY_state = TEST_WM_NOTIFY_SIMPLE_FORWARD_DONE; + return TEST_WM_NOTIFY_RETURN; + case TEST_WM_NOTIFY_CONVERT_FORWARD: + ok(hdr->code == DTN_USERSTRINGA, "Wrong code 0x%x, should be 0x%x=DTN_USERSTRINGA.\n", hdr->code, DTN_USERSTRINGA); + ok(strcmp("DTN_USERSTRINGW test", ((NMDATETIMESTRINGA *)lParam)->pszUserString) == 0, "pszUserString converted incorrectly.\n"); + test_WM_NOTIFY_state = TEST_WM_NOTIFY_CONVERT_FORWARD_DONE; + return TEST_WM_NOTIFY_RETURN; + default: + ok(FALSE, "Got unexpected WM_NOTIFY.\n"); + return 0; + } + } switch (hdr->code) { case TBN_HOTITEMCHANGE: @@ -428,7 +464,7 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, switch (message) { case WM_NOTIFY: - return parent_wnd_notify(lParam); + return parent_wnd_notify(wParam, lParam); }
defwndproc_counter++; @@ -2833,6 +2869,65 @@ static void test_BTNS_SEP(void) DestroyWindow(hwnd); }
+static void test_WM_NOTIFY(void) +{ + HWND toolbar = NULL; + LRESULT ret; + + rebuild_toolbar(&toolbar); + + test_WM_NOTIFY_state = TEST_WM_NOTIFY_SIMPLE_FORWARD; + { + NMHDR nm = + { + .hwndFrom = TEST_WM_NOTIFY_HWNDFROM, + .idFrom = TEST_WM_NOTIFY_IDFROM, + .code = TEST_WM_NOTIFY_SIMPLE_FORWARD_CODE + }; + test_WM_NOTIFY_nmhdr = &nm; + ret = SendMessageA(toolbar, WM_NOTIFY, 0, (LPARAM)&nm); + } + todo_wine ok(ret == TEST_WM_NOTIFY_RETURN, "SendMessageA returned 0x%Ix.\n", ret); + todo_wine ok(test_WM_NOTIFY_state == TEST_WM_NOTIFY_SIMPLE_FORWARD_DONE, "Toolbar didn't forward WM_NOTIFY to parent.\n"); + + test_WM_NOTIFY_state = TEST_WM_NOTIFY_CONVERT_FORWARD; + { + NMDATETIMESTRINGW nm = + { + .nmhdr = { + .hwndFrom = TEST_WM_NOTIFY_HWNDFROM, + .idFrom = TEST_WM_NOTIFY_IDFROM, + .code = DTN_USERSTRINGW + }, + .pszUserString = u"DTN_USERSTRINGW test" + /* .st and .dwFlags zero */ + }; + test_WM_NOTIFY_nmhdr = &nm.nmhdr; + ret = SendMessageA(toolbar, WM_NOTIFY, 0, (LPARAM)&nm); + } + todo_wine ok(ret == TEST_WM_NOTIFY_RETURN, "SendMessageA returned 0x%Ix.\n", ret); + todo_wine ok(test_WM_NOTIFY_state == TEST_WM_NOTIFY_CONVERT_FORWARD_DONE, "Toolbar didn't forward WM_NOTIFY to parent.\n"); + + test_WM_NOTIFY_state = TEST_WM_NOTIFY_NO_FORWARD; + { + NMHDR nm = + { + .hwndFrom = TEST_WM_NOTIFY_HWNDFROM, + .idFrom = TEST_WM_NOTIFY_IDFROM, + .code = TEST_WM_NOTIFY_NO_FORWARD_CODE + }; + + test_WM_NOTIFY_nmhdr = &nm; + ret = SendMessageA(toolbar, WM_NOTIFY, 0, (LPARAM)&nm); + } + ok(ret == 0, "SendMessageA returned 0x%Ix.\n", ret); + ok(test_WM_NOTIFY_state == TEST_WM_NOTIFY_NO_FORWARD, "Toolbar forwarded WM_NOTIFY to parent.\n"); + + test_WM_NOTIFY_state = TEST_WM_NOTIFY_NONE; + test_WM_NOTIFY_nmhdr = NULL; + DestroyWindow(toolbar); +} + START_TEST(toolbar) { ULONG_PTR ctx_cookie; @@ -2884,6 +2979,7 @@ START_TEST(toolbar) test_drawtext_flags(); test_imagelist(); test_BTNS_SEP(); + test_WM_NOTIFY();
if (!load_v6_module(&ctx_cookie, &ctx)) return;