[PATCH 2/4] user32/tests: Add tests for EnableWindow().

Zebediah Figura z.figura12 at gmail.com
Sun Mar 5 13:21:31 CST 2017


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/user32/tests/win.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 70c1370..2562e81 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -6556,6 +6556,58 @@ static void test_ShowWindow(void)
     ok(!IsWindow(hwnd), "window should not exist\n");
 }
 
+static DWORD CALLBACK enablewindow_thread(LPVOID arg)
+{
+    HWND hwnd = arg;
+    EnableWindow(hwnd, FALSE);
+    return 0;
+}
+
+static void test_EnableWindow(void)
+{
+    HWND hwnd;
+    HANDLE hthread;
+    DWORD tid;
+    MSG msg;
+
+    hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_OVERLAPPEDWINDOW,
+                           0, 0, 100, 100, 0, 0, 0, NULL);
+    assert(hwnd);
+    ok(IsWindowEnabled(hwnd), "window should be enabled\n");
+    SetFocus(hwnd);
+    SetCapture(hwnd);
+
+    EnableWindow(hwnd, FALSE);
+    check_wnd_state(hwnd, hwnd, 0, 0);
+    ok(!IsWindowEnabled(hwnd), "window should not be enabled\n");
+
+    SetFocus(hwnd);
+    SetCapture(hwnd);
+    check_wnd_state(hwnd, hwnd, 0, hwnd);
+
+    EnableWindow(hwnd, TRUE);
+    SetFocus(hwnd);
+    check_wnd_state(hwnd, hwnd, hwnd, hwnd);
+    ok(IsWindowEnabled(hwnd), "window should be enabled\n");
+
+    /* test disabling from thread */
+    hthread = CreateThread(NULL, 0, enablewindow_thread, hwnd, 0, &tid);
+
+    while (MsgWaitForMultipleObjects(1, &hthread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
+    {
+        while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE))
+            DispatchMessageA(&msg);
+    }
+
+    ok(!IsWindowEnabled(hwnd), "window should not be enabled\n");
+    todo_wine
+        check_active_state(hwnd, hwnd, hwnd);
+    ok(0 == GetCapture(), "GetCapture() = %p\n", GetCapture());
+
+    CloseHandle(hthread);
+    DestroyWindow(hwnd);
+}
+
 static DWORD CALLBACK gettext_msg_thread( LPVOID arg )
 {
     HWND hwnd = arg;
@@ -9780,6 +9832,7 @@ START_TEST(win)
     test_SetWindowLong();
     test_set_window_style();
     test_ShowWindow();
+    test_EnableWindow();
     test_gettext();
     test_GetUpdateRect();
     test_Expose();
-- 
2.7.4




More information about the wine-patches mailing list