From 51aabdd6ed2e371b683929fb001f78cb33ccfd08 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 9 Jul 2008 21:44:21 -0700 Subject: [PATCH 1/2] user32: Add more tests for SetWindowPos. --- dlls/user32/tests/msg.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 190 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index dfb6108..4da8fe3 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1777,6 +1777,25 @@ static void ok_sequence_(const struct message *expected, const char *context, in flush_sequence(); } +static UINT sequence_contains(UINT msg) +{ + static const struct message end_of_sequence = { 0, 0, 0, 0 }; + const struct message *actual; + UINT num = 0; + + add_message(&end_of_sequence); + actual = sequence; + + while (actual->message) + { + if (actual->message == msg) num++; + actual++; + } + return num; +} + +#define expectI(NUM, EXPECTED,GOT) ok((GOT)==(EXPECTED), "[%d] Expected %d, got %d\n", (NUM), (EXPECTED), (GOT)) + /******************************** MDI test **********************************/ /* CreateWindow for MDI frame window, initially visible */ @@ -4544,6 +4563,176 @@ static void test_messages(void) flush_sequence(); } +struct wmsize_test { + POINT old_size; + POINT new_size; + UINT flags; + UINT num_wmsize; + RECT window; + int todo[9]; +}; + +static void test_wmsize(void) +{ + HWND hwnd; + UINT num; + RECT rc; + int i; + const INT sysX = GetSystemMetrics(SM_CXMINTRACK); + const INT sysY = GetSystemMetrics(SM_CYMINTRACK); + const struct wmsize_test wm[] = { + { + { 100, 50 }, { 100, 50 }, 0, 1, { 0, 0, sysX, 50 }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 150, 5 }, { 150, 5 }, 0, 1, { 0, 0, 150, sysY }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 160, 150 }, { 160, 150 }, 0, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, 0, 2, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 100, 50 }, { 100, 50 }, SWP_NOSIZE, 1, { 0, 0, sysX, 50 }, + { 0, 0, 0, 1, 0, 0, 0, 1, 0 } + }, + { + { 150, 5 }, { 150, 5 }, SWP_NOSIZE, 1, { 0, 0, 150, sysY }, + { 0, 0, 0, 0, 1, 0, 0, 0, 1 } + }, + { + { 160, 150 }, { 160, 150 }, SWP_NOSIZE, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, SWP_NOSIZE, 1, { 0, 0, 140, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 100, 50 }, { 100, 50 }, SWP_NOZORDER, 1, { 0, 0, sysX, 50 }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 150, 5 }, { 150, 5 }, SWP_NOZORDER, 1, { 0, 0, 150, sysY }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 160, 150 }, { 160, 150 }, SWP_NOZORDER, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, SWP_NOZORDER, 2, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 100, 50 }, { 100, 50 }, SWP_NOZORDER|SWP_NOSIZE, 1, { 0, 0, sysX, 50 }, + { 0, 0, 0, 1, 0, 0, 0, 1, 0 } + }, + { + { 150, 5 }, { 150, 5 }, SWP_NOZORDER|SWP_NOSIZE, 1, { 0, 0, 150, sysY }, + { 0, 0, 0, 0, 1, 0, 0, 0, 1 } + }, + { + { 160, 150 }, { 160, 150 }, SWP_NOZORDER|SWP_NOSIZE, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, SWP_NOZORDER|SWP_NOSIZE, 1, { 0, 0, 140, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 100, 50 }, { 100, 50 }, SWP_NOMOVE, 1, { 0, 0, sysX, 50 }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 150, 5 }, { 150, 5 }, SWP_NOMOVE, 1, { 0, 0, 150, sysY }, + { 1, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 160, 150 }, { 160, 150 }, SWP_NOMOVE, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, SWP_NOMOVE, 2, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 100, 50 }, { 100, 50 }, SWP_NOMOVE|SWP_NOSIZE, 1, { 0, 0, sysX, 50 }, + { 0, 0, 0, 1, 0, 0, 0, 1, 0 } + }, + { + { 150, 5 }, { 150, 5 }, SWP_NOMOVE|SWP_NOSIZE, 1, { 0, 0, 150, sysY }, + { 0, 0, 0, 0, 1, 0, 0, 0, 1 } + }, + { + { 160, 150 }, { 160, 150 }, SWP_NOMOVE|SWP_NOSIZE, 1, { 0, 0, 160, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + { + { 140, 150 }, { 160, 150 }, SWP_NOMOVE|SWP_NOSIZE, 1, { 0, 0, 140, 150 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0 } + }, + }; + + for (i = 0; i < sizeof(wm)/sizeof(wm[0]); i++) + { + hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0, + 0, 0, wm[i].old_size.x, wm[i].old_size.y, 0, + NULL, NULL, 0); + flush_events(); + flush_sequence(); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, wm[i].new_size.x, wm[i].new_size.y, wm[i].flags); + num = sequence_contains(WM_SIZE); + + if (wm[i].todo[0]) + todo_wine expectI(i, wm[i].num_wmsize, num); + else + expectI(i, wm[i].num_wmsize, num); + + GetWindowRect(hwnd, &rc); + if (wm[i].todo[1]) + todo_wine expectI(i, wm[i].window.left, rc.left); + else + expectI(i, wm[i].window.left, rc.left); + if (wm[i].todo[2]) + todo_wine expectI(i, wm[i].window.top, rc.top); + else + expectI(i, wm[i].window.top, rc.top); + if (wm[i].todo[3]) + todo_wine expectI(i, wm[i].window.right, rc.right); + else + expectI(i, wm[i].window.right, rc.right); + if (wm[i].todo[4]) + todo_wine expectI(i, wm[i].window.bottom, rc.bottom); + else + expectI(i, wm[i].window.bottom, rc.bottom); + + GetClientRect(hwnd, &rc); + if (wm[i].todo[5]) + todo_wine expectI(i, wm[i].window.left, rc.left); + else + expectI(i, wm[i].window.left, rc.left); + if (wm[i].todo[6]) + todo_wine expectI(i, wm[i].window.top, rc.top); + else + expectI(i, wm[i].window.top, rc.top); + if (wm[i].todo[7]) + todo_wine expectI(i, wm[i].window.right - 6, rc.right); + else + expectI(i, wm[i].window.right - 6, rc.right); + if (wm[i].todo[8]) + todo_wine expectI(i, wm[i].window.bottom - 25, rc.bottom); + else + expectI(i, wm[i].window.bottom - 25, rc.bottom); + DestroyWindow(hwnd); + } +} + static void invisible_parent_tests(void) { HWND hparent, hchild; @@ -10962,6 +11151,7 @@ START_TEST(msg) test_PeekMessage2(); test_scrollwindowex(); test_messages(); + test_wmsize(); test_showwindow(); invisible_parent_tests(); test_mdi_messages(); -- 1.5.2.5