[2/2] user32/tests: tests for HTTRANSPARENT

Daniel Jelinski djelinski1 at gmail.com
Mon Aug 6 16:11:27 CDT 2012


-------------- next part --------------
From b5eba9ddf30f3df380b38a878298c4cfc35bf588 Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Fri, 27 Jul 2012 23:41:30 +0200
Subject: user32: tests for HTTRANSPARENT

---
 dlls/user32/tests/msg.c |  139 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 139 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 11830ad..33c16c0 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -11481,6 +11481,144 @@ static const struct message SetForegroundWindowSeq[] =
     { 0 }
 };
 
+static INT_PTR WINAPI bottom_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    static LONG lbutton_counter = 0;
+    static HWND hwnd_transparent = 0;
+    static HWND hwnd_middle = 0;
+    static POINT pt;
+    HWND fromPoint;
+
+    switch (message)
+    {
+        case WM_LBUTTONDOWN:
+            ok(!(lbutton_counter++), "expected exactly one click\n");
+            pt.x = 150;
+            pt.y = 250;
+            /* left click should bring the window to front */
+            fromPoint = WindowFromPoint(pt);
+            todo_wine ok(fromPoint == hwnd, "At (150,250): expected %p, got %p\n", hwnd, fromPoint);
+            break;
+        case WM_USER:
+            hwnd_transparent = CreateWindowExA (WS_EX_TOPMOST, "top_class", "tooltipWindow",
+                                              WS_POPUP, 100, 100, 200, 200, 0, 0, 0, NULL);
+            assert(hwnd_transparent);
+            ShowWindow(hwnd_transparent, SW_SHOW);
+            hwnd_middle = (HWND)lParam;
+            break;
+        case WM_USER + 1:
+            trace("bottom: %p, middle: %p, top: %p\n", hwnd, hwnd_middle, hwnd_transparent);
+            pt.x = 150;
+            pt.y = 150;
+            fromPoint = WindowFromPoint(pt);
+            ok(fromPoint == hwnd, "At (150,150): expected %p, got %p\n", hwnd, fromPoint);
+            pt.y = 250;
+            fromPoint = WindowFromPoint(pt);
+            ok(fromPoint == hwnd_middle, "At (150,250): expected %p, got %p\n", hwnd_middle, fromPoint);
+            pt.y = 350;
+            fromPoint = WindowFromPoint(pt);
+            ok(fromPoint == hwnd_middle, "At (150,350): expected %p, got %p\n", hwnd_middle, fromPoint);
+            break;
+        case WM_DESTROY:
+            ok(lbutton_counter == 1, "expected exactly one click\n");
+            DestroyWindow(hwnd_transparent);
+            PostMessageA((HWND)hwnd_middle, WM_QUIT, 0, 0);
+            break;
+    }
+    return DefWindowProcA(hwnd, message, wParam, lParam);
+}
+static INT_PTR WINAPI middle_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message)
+    {
+        case WM_LBUTTONDOWN:
+            ok(FALSE, "unexpected click\n");
+            break;
+    }
+    return DefWindowProcA(hwnd, message, wParam, lParam);
+}
+static INT_PTR WINAPI top_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    switch (message)
+    {
+        case WM_LBUTTONDOWN:
+            ok(FALSE, "unexpected click\n");
+            break;
+        case WM_NCHITTEST:
+            return HTTRANSPARENT;
+    }
+    return DefWindowProcA(hwnd, message, wParam, lParam);
+}
+static DWORD CALLBACK middle_thread( void *hwnd_bottom )
+{
+    MSG msg;
+    HWND hwnd;
+
+    hwnd = CreateWindowA ("middle_class", "middleWindow",
+                          WS_POPUP, 100, 200, 200, 200, 0, 0, 0, NULL);
+    assert(hwnd);
+    ShowWindow(hwnd, SW_SHOW);
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    PostMessageA((HWND)hwnd_bottom, WM_USER, 0, (LPARAM)hwnd);
+    while (GetMessage(&msg, 0, 0, 0)) DispatchMessage(&msg);
+    return 0;
+}
+static void test_HTTRANSPARENT(void)
+{
+    WNDCLASSA cls;
+    HWND hwnd;
+    MSG msg;
+    HANDLE thread;
+
+    cls.style = 0;
+    cls.lpfnWndProc = bottom_proc;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = GetModuleHandleA(0);
+    cls.hIcon = 0;
+    cls.hCursor = LoadCursorA(0, IDC_ARROW);
+    cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "bottom_class";
+    if(!RegisterClassA(&cls)) return;
+
+    cls.lpfnWndProc = middle_proc;
+    cls.lpszClassName = "middle_class";
+    if(!RegisterClassA(&cls)) return;
+
+    cls.lpfnWndProc = top_proc;
+    cls.lpszClassName = "top_class";
+    if(!RegisterClassA(&cls)) return;
+
+    hwnd = CreateWindowA ("bottom_class", "bottomWindow",
+                          WS_POPUP, 100, 100, 200, 200, 0, 0, 0, NULL);
+    assert(hwnd);
+    ShowWindow(hwnd, SW_SHOW);
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+
+    thread = CreateThread( NULL, 0, middle_thread, (LPVOID)hwnd, 0, NULL );
+    CloseHandle( thread );
+    while (GetMessage(&msg, 0, 0, 0))
+    {
+        DispatchMessage(&msg);
+        if(msg.message == WM_USER)
+            break;
+    }
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    /* test WindowFromPos */
+    SendMessageA(hwnd, WM_USER + 1, 0, 0);
+    SetCursorPos(150,250); /* over other thread's window */
+    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
+    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+    SetCursorPos(150,150); /* over this thread's window */
+    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
+    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
+
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    DestroyWindow(hwnd);
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+}
+
 static void test_SetForegroundWindow(void)
 {
     HWND hwnd;
@@ -13884,6 +14022,7 @@ START_TEST(msg)
     test_clipboard_viewers();
     test_keyflags();
     test_hotkey();
+    test_HTTRANSPARENT();
     /* keep it the last test, under Windows it tends to break the tests
      * which rely on active/foreground windows being correct.
      */
-- 
1.7.5.4


More information about the wine-patches mailing list