From: Rodrigo Rivas Subject: [1/4] user32: Add test case for basic {Begin,,End}DeferWindowPos() (try 2) Message-Id: Date: Wed, 2 Sep 2015 15:37:57 +0200 As requested in (try 1) I've split the patch in 4 parts: 1/4: It adds a basic test case for the DWP functions when all goes well. 2/4: It adds a test case (todo_wine) for the error handling of using an invalid HWND. 3/4: It adds a test case (todo_wine) for the error handling of a HWND that is destroyed just before callind EDWP. 4/4: It fixes the error handling to match the Windows behaviour and removes the todo_wine's. Basically, all that this fix does is moving the HWND checks from EDWP to DWP. This fixes bug #23187. --- dlls/user32/tests/win.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 10aa545..bc5735f 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -8158,6 +8158,44 @@ static void test_GetMessagePos(void) DestroyWindow(button); } +static void test_DeferWindowPos(void) +{ + HWND hwnds[3]; + int i; + BOOL res; + HDWP hdwp, hdwp2; + RECT rect; + + for (i = 0; i < 3; ++i) + { + hwnds[i] = CreateWindowExA(0, "button", "button", WS_VISIBLE, + 0, 0, 100, 100, 0, 0, 0, NULL); + } + + hdwp = BeginDeferWindowPos(1); + ok(hdwp != NULL, "BeginDeferWindowPos failed\n"); + for (i = 0; i < 3; ++i) + { + hdwp2 = DeferWindowPos(hdwp, hwnds[i], NULL, 0, 100, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE); + if (hdwp2) + hdwp = hdwp2; + ok(hdwp != NULL, "DeferWindowPos failed\n"); + } + res = EndDeferWindowPos(hdwp); + ok(res, "EndDeferWindowPos failed\n"); + + for (i = 0; i < 3; ++i) + { + GetWindowRect(hwnds[i], &rect); + ok(rect.top == 100, "Deferred movement failed\n"); + } + + for (i = 0; i < 3; ++i) + { + DestroyWindow(hwnds[i]); + } +} + START_TEST(win) { char **argv; @@ -8291,6 +8329,8 @@ START_TEST(win) test_smresult(); test_GetMessagePos(); + test_DeferWindowPos(); + /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook);