[PATCH 6/6] comctl32/tests: Test WINDOWPOS structure contents (v2).

Stefan Dösinger stefan at codeweavers.com
Fri Apr 7 09:02:06 CDT 2017


In particular show that PGM_SETPOS changes the Z order (no SWP_NOZORDER
flag).

Version 2: Do not use memcmp to compare WINDOWPOS structures.

Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
 dlls/comctl32/tests/msg.h   | 41 +++++++++++++++++++++++++++
 dlls/comctl32/tests/pager.c | 69 +++++++++++++++++++++++++++++++++------------
 2 files changed, 92 insertions(+), 18 deletions(-)

diff --git a/dlls/comctl32/tests/msg.h b/dlls/comctl32/tests/msg.h
index 5f246b7..b57a471 100644
--- a/dlls/comctl32/tests/msg.h
+++ b/dlls/comctl32/tests/msg.h
@@ -41,6 +41,7 @@ typedef enum
     id = 0x400,
     custdraw = 0x800,
     todo_extra = 0x1000,
+    windowpos = 0x2000
 } msg_flags_t;
 
 struct message
@@ -52,6 +53,7 @@ struct message
     UINT id;            /* extra message data: id of the window,
                            notify code etc. */
     DWORD stage;        /* custom draw stage */
+    WINDOWPOS wp;       /* expected WINDOWPOS structure in lparam */
 };
 
 struct msg_sequence
@@ -295,6 +297,45 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                 if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
             }
 
+            if (expected->flags & windowpos)
+            {
+                /* Do not use memcmp, the structure has alignment holes on Win64. Also
+                 * ignore hwnd - it is only known at runtime and is checked through other
+                 * means anyway. */
+                BOOL equal = expected->wp.hwndInsertAfter == actual->wp.hwndInsertAfter
+                    && expected->wp.x == actual->wp.x && expected->wp.y == actual->wp.y
+                    && expected->wp.cx == actual->wp.cx && expected->wp.cy == actual->wp.cy
+                    && expected->wp.flags == actual->wp.flags;
+                if (!equal && todo)
+                {
+                    todo_wine
+                    {
+                        failcount++;
+                        dump++;
+                        ok_(file, line) (FALSE,
+                            "%s: in msg 0x%04x got incorrect WINDOWPOS contents "
+                            "{x=%d, y=%d, cx=%d cy=%d, hwndInsertAfter=%p, flags=%#x}, expected "
+                            "{x=%d, y=%d, cx=%d cy=%d, hwndInsertAfter=%p, flags=%#x}\n",
+                            context, expected->message, actual->wp.x, actual->wp.y, actual->wp.cx,
+                            actual->wp.cy, actual->wp.hwndInsertAfter, actual->wp.flags,
+                            expected->wp.x, expected->wp.y, expected->wp.cx,
+                            expected->wp.cy, expected->wp.hwndInsertAfter, expected->wp.flags);
+                    }
+                }
+                else
+                {
+                    ok_(file, line) (equal,
+                        "%s: in msg 0x%04x got incorrect WINDOWPOS contents "
+                        "{x=%d, y=%d, cx=%d cy=%d, hwndInsertAfter=%p, flags=%#x}, expected "
+                        "{x=%d, y=%d, cx=%d cy=%d, hwndInsertAfter=%p, flags=%#x}\n",
+                        context, expected->message, actual->wp.x, actual->wp.y, actual->wp.cx,
+                        actual->wp.cy, actual->wp.hwndInsertAfter, actual->wp.flags,
+                        expected->wp.x, expected->wp.y, expected->wp.cx,
+                        expected->wp.cy, expected->wp.hwndInsertAfter, expected->wp.flags);
+                    if (!equal) dump++;
+                }
+            }
+
             ok_(file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
                 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
                 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
diff --git a/dlls/comctl32/tests/pager.c b/dlls/comctl32/tests/pager.c
index 971f0ae..64c0c26 100644
--- a/dlls/comctl32/tests/pager.c
+++ b/dlls/comctl32/tests/pager.c
@@ -43,7 +43,7 @@ static const struct message set_child_seq[] = {
     { WM_NOTIFY, sent|id|parent, 0, 0, PGN_CALCSIZE },
     { WM_WINDOWPOSCHANGED, sent },
     { WM_NOTIFY, sent|parent|todo_extra },
-    { WM_WINDOWPOSCHANGING, sent|id, 0, 0, CHILD1_ID },
+    { WM_WINDOWPOSCHANGING, sent|id|windowpos, 0, 0, CHILD1_ID, 0, {NULL, HWND_TOP, 0, 0, 98, 98, 0} },
     { WM_NCCALCSIZE, sent|wparam|id|optional, TRUE, 0, CHILD1_ID },
     { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD1_ID },
     { WM_WINDOWPOSCHANGED, sent|id, 0, 0, CHILD1_ID },
@@ -62,7 +62,7 @@ static const struct message switch_child_seq[] = {
     { WM_NOTIFY, sent|id|parent, 0, 0, PGN_CALCSIZE },
     { WM_WINDOWPOSCHANGED, sent },
     { WM_NOTIFY, sent|parent|todo_extra },
-    { WM_WINDOWPOSCHANGING, sent|id, 0, 0, CHILD2_ID },
+    { WM_WINDOWPOSCHANGING, sent|id|windowpos, 0, 0, CHILD2_ID, 0, {NULL, HWND_TOP, 0, 0, 98, 98, 0} },
     { WM_NCCALCSIZE, sent|wparam|id, TRUE, 0, CHILD2_ID },
     { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD2_ID },
     { WM_WINDOWPOSCHANGED, sent|id, 0, 0, CHILD2_ID },
@@ -70,27 +70,40 @@ static const struct message switch_child_seq[] = {
     { 0 }
 };
 
-static const struct message set_pos_seq[] = {
+static const struct message set_pos_10_seq[] = {
     { PGM_SETPOS, sent },
     { WM_WINDOWPOSCHANGING, sent },
     { WM_NCCALCSIZE, sent|wparam, TRUE },
     { WM_NOTIFY, sent|id|parent, 0, 0, PGN_CALCSIZE },
     { WM_WINDOWPOSCHANGED, sent },
-    { WM_MOVE, sent|optional },
-    /* The WM_SIZE handler sends WM_WINDOWPOSCHANGING, WM_CHILDACTIVATE
+    { WM_MOVE, sent },
+    /* The pager's WM_SIZE handler sends WM_WINDOWPOSCHANGING, WM_CHILDACTIVATE
      * and WM_WINDOWPOSCHANGED (which sends WM_MOVE) to the child.
-     * Another WM_WINDOWPOSCHANGING is sent afterwards.
+     * Another WM_WINDOWPOSCHANGING is sent afterwards independently.
      *
-     * The 2nd WM_WINDOWPOSCHANGING is unconditional, but the comparison
-     * function is too simple to roll back an accepted message, so we have
-     * to mark the 2nd message optional. */
-    { WM_SIZE, sent|optional },
-    { WM_WINDOWPOSCHANGING, sent|id, 0, 0, CHILD1_ID }, /* Actually optional. */
-    { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD1_ID }, /* Actually optional. */
-    { WM_WINDOWPOSCHANGED, sent|id|optional, TRUE, 0, CHILD1_ID},
-    { WM_MOVE, sent|id|optional|defwinproc, 0, 0, CHILD1_ID },
-    { WM_WINDOWPOSCHANGING, sent|id|optional, 0, 0, CHILD1_ID }, /* Actually not optional. */
-    { WM_CHILDACTIVATE, sent|id|optional, 0, 0, CHILD1_ID }, /* Actually not optional. */
+     * WM_SIZE is only triggered in the first PGM_SETPOS message, so the sequence
+     * below doesn't expect it and the messages it generates. */
+    { WM_SIZE, sent },
+    { WM_WINDOWPOSCHANGING, sent|id|windowpos, 0, 0, CHILD1_ID, 0, {NULL, HWND_TOP, -10, 0, 98, 98, 0} },
+    { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD1_ID },
+    { WM_WINDOWPOSCHANGED, sent|id, TRUE, 0, CHILD1_ID },
+    { WM_MOVE, sent|id|defwinproc, 0, 0, CHILD1_ID },
+    { WM_WINDOWPOSCHANGING, sent|id|windowpos, 0, 0, CHILD1_ID, 0, {NULL, HWND_TOP, -10, 0, 98, 98, 0} },
+    { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD1_ID },
+    { 0 }
+};
+
+static const struct message set_pos_9_seq[] = {
+    { PGM_SETPOS, sent },
+    { WM_WINDOWPOSCHANGING, sent },
+    { WM_NCCALCSIZE, sent|wparam, TRUE },
+    { WM_NOTIFY, sent|id|parent, 0, 0, PGN_CALCSIZE },
+    { WM_WINDOWPOSCHANGED, sent },
+    { WM_MOVE, sent|optional },
+    { WM_WINDOWPOSCHANGING, sent|id|windowpos, 0, 0, CHILD1_ID, 0, {NULL, HWND_TOP, -9, 0, 98, 98, 0} },
+    { WM_CHILDACTIVATE, sent|id, 0, 0, CHILD1_ID },
+    { WM_WINDOWPOSCHANGED, sent|id, TRUE, 0, CHILD1_ID },
+    { WM_MOVE, sent|id|defwinproc, 0, 0, CHILD1_ID },
     { 0 }
 };
 
@@ -145,6 +158,12 @@ static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LP
                 ;
         }
     }
+    else if (message == WM_WINDOWPOSCHANGED || message == WM_WINDOWPOSCHANGING)
+    {
+        const WINDOWPOS *wp = (WINDOWPOS *)lParam;
+        msg.wp = *wp;
+        msg.wp.hwnd = NULL;
+    }
 
     defwndproc_counter++;
     ret = DefWindowProcA(hwnd, message, wParam, lParam);
@@ -185,6 +204,13 @@ static LRESULT WINAPI pager_subclass_proc(HWND hwnd, UINT message, WPARAM wParam
     WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
     struct message msg = { 0 };
 
+    if (message == WM_WINDOWPOSCHANGED || message == WM_WINDOWPOSCHANGING)
+    {
+        const WINDOWPOS *wp = (WINDOWPOS *)lParam;
+        msg.wp = *wp;
+        msg.wp.hwnd = NULL;
+    }
+
     msg.message = message;
     msg.flags = sent|wparam|lparam;
     msg.wParam = wParam;
@@ -227,6 +253,13 @@ static LRESULT WINAPI child_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
     else
         msg.id = 0;
 
+    if (message == WM_WINDOWPOSCHANGED || message == WM_WINDOWPOSCHANGING)
+    {
+        const WINDOWPOS *wp = (WINDOWPOS *)lParam;
+        msg.wp = *wp;
+        msg.wp.hwnd = NULL;
+    }
+
     add_message(sequences, PAGER_SEQ_INDEX, &msg);
 
     defwndproc_counter++;
@@ -296,7 +329,7 @@ static void test_pager(void)
 
     flush_sequences( sequences, NUM_MSG_SEQUENCES );
     SendMessageA( pager, PGM_SETPOS, 0, 10 );
-    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_seq, "set pos", TRUE);
+    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_10_seq, "set pos 10", TRUE);
     GetWindowRect( pager, &rect );
     ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
         "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top );
@@ -307,7 +340,7 @@ static void test_pager(void)
 
     flush_sequences( sequences, NUM_MSG_SEQUENCES );
     SendMessageA( pager, PGM_SETPOS, 0, 9 );
-    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_seq, "set pos", TRUE);
+    ok_sequence(sequences, PAGER_SEQ_INDEX, set_pos_9_seq, "set pos 9", TRUE);
 
     DestroyWindow( pager );
 
-- 
2.10.2




More information about the wine-patches mailing list