[PATCH 2/6] comctl32/tests: Test messages sent to the pager child.

Stefan Dösinger stefan at codeweavers.com
Wed Apr 5 02:15:40 CDT 2017


---
 dlls/comctl32/tests/msg.h   | 19 ++++++++++--
 dlls/comctl32/tests/pager.c | 70 ++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/dlls/comctl32/tests/msg.h b/dlls/comctl32/tests/msg.h
index b30b5d8..a3c789b 100644
--- a/dlls/comctl32/tests/msg.h
+++ b/dlls/comctl32/tests/msg.h
@@ -39,7 +39,8 @@ typedef enum
     hook = 0x100,
     winevent_hook =0x200,
     id = 0x400,
-    custdraw = 0x800
+    custdraw = 0x800,
+    child1 = 0x1000,
 } msg_flags_t;
 
 struct message
@@ -182,6 +183,8 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
     {
         if (expected->message == actual->message)
         {
+            const char *expected_win = NULL;
+
             if (expected->flags & wparam)
             {
                 if (expected->wParam != actual->wParam && todo)
@@ -304,11 +307,23 @@ static void ok_sequence_(struct msg_sequence **seq, int sequence_index,
                 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
             if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
 
+            if (expected->flags & parent)
+                expected_win = "parent";
+            else if (expected->flags & child1)
+                expected_win = "child 1";
+            else
+                expected_win = "pager";
+
             ok_(file, line) ((expected->flags & parent) == (actual->flags & parent),
                 "%s: the msg 0x%04x was expected in %s\n",
-                context, expected->message, (expected->flags & parent) ? "parent" : "child");
+                context, expected->message, expected_win);
             if ((expected->flags & parent) != (actual->flags & parent)) dump++;
 
+            ok_(file, line) ((expected->flags & child1) == (actual->flags & child1),
+                "%s: the msg 0x%04x was expected in %s\n",
+                context, expected->message, expected_win);
+            if ((expected->flags & child1) != (actual->flags & child1)) dump++;
+
             ok_(file, line) ((expected->flags & hook) == (actual->flags & hook),
                 "%s: the msg 0x%04x should have been sent by a hook\n",
                 context, expected->message);
diff --git a/dlls/comctl32/tests/pager.c b/dlls/comctl32/tests/pager.c
index 372b227..74fb42d 100644
--- a/dlls/comctl32/tests/pager.c
+++ b/dlls/comctl32/tests/pager.c
@@ -27,7 +27,7 @@
 #define NUM_MSG_SEQUENCES   1
 #define PAGER_SEQ_INDEX     0
 
-static HWND parent_wnd;
+static HWND parent_wnd, child1_wnd;
 
 static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
 
@@ -39,6 +39,11 @@ static const struct message set_child_seq[] = {
     { WM_NCCALCSIZE, sent|wparam, TRUE },
     { WM_NOTIFY, sent|id|parent, 0, 0, PGN_CALCSIZE },
     { WM_WINDOWPOSCHANGED, sent },
+    { WM_WINDOWPOSCHANGING, sent|child1 },
+    { WM_NCCALCSIZE, sent|wparam|child1, TRUE },
+    { WM_CHILDACTIVATE, sent|child1 },
+    { WM_WINDOWPOSCHANGED, sent|child1 },
+    { WM_SIZE, sent|child1|defwinproc },
     { 0 }
 };
 
@@ -49,7 +54,20 @@ static const struct message set_pos_seq[] = {
     { 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
+     * and WM_WINDOWPOSCHANGED (which sends WM_MOVE) to the child.
+     * Another WM_WINDOWPOSCHANGING is sent afterwards.
+     *
+     * 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|child1 }, /* Actually optional. */
+    { WM_CHILDACTIVATE, sent|child1 }, /* Actually optional. */
+    { WM_WINDOWPOSCHANGED, sent|child1|optional, TRUE },
+    { WM_MOVE, sent|child1|optional|defwinproc },
+    { WM_WINDOWPOSCHANGING, sent|child1|optional }, /* Actually not optional. */
+    { WM_CHILDACTIVATE, sent|child1|optional }, /* Actually not optional. */
     { 0 }
 };
 
@@ -166,9 +184,50 @@ static HWND create_pager_control( DWORD style )
     return hwnd;
 }
 
+static LRESULT WINAPI child_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    struct message msg;
+    static LONG defwndproc_counter;
+    LRESULT ret;
+
+    msg.message = message;
+    msg.flags = sent | wparam | lparam;
+    if (hwnd == child1_wnd)
+        msg.flags |= child1;
+    if (defwndproc_counter)
+        msg.flags |= defwinproc;
+    msg.wParam = wParam;
+    msg.lParam = lParam;
+    msg.id = 0;
+    add_message(sequences, PAGER_SEQ_INDEX, &msg);
+
+    defwndproc_counter++;
+    ret = DefWindowProcA(hwnd, message, wParam, lParam);
+    defwndproc_counter--;
+
+    return ret;
+}
+
+static BOOL register_child_wnd_class(void)
+{
+    WNDCLASSA cls;
+
+    cls.style = 0;
+    cls.lpfnWndProc = child_proc;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = GetModuleHandleA(NULL);
+    cls.hIcon = 0;
+    cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
+    cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "Pager test child class";
+    return RegisterClassA(&cls);
+}
+
 static void test_pager(void)
 {
-    HWND pager, child;
+    HWND pager;
     RECT rect, rect2;
 
     pager = create_pager_control( PGS_HORZ );
@@ -177,11 +236,14 @@ static void test_pager(void)
         win_skip( "Pager control not supported\n" );
         return;
     }
-    child = CreateWindowA( "BUTTON", "button", WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 300, 300,
+
+    register_child_wnd_class();
+
+    child1_wnd = CreateWindowA( "Pager test child class", "button", WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, 300, 300,
                            pager, 0, GetModuleHandleA(0), 0 );
 
     flush_sequences( sequences, NUM_MSG_SEQUENCES );
-    SendMessageA( pager, PGM_SETCHILD, 0, (LPARAM)child );
+    SendMessageA( pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd );
     ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "set child", TRUE);
     GetWindowRect( pager, &rect );
     ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
-- 
2.10.2




More information about the wine-patches mailing list