Conformance tests for IsDialogMessage etc

Bill Medland billmedland at mercuryspeed.com
Tue Jan 6 14:45:54 CST 2004


Bill Medland (billmedland at mercuryspeed.com)
Conformance tests for IsDialogMessage (and associated functions).
This first version addresses the issue for which I submitted a patch yesterday.

Index: wine/dlls/user/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/Makefile.in,v
retrieving revision 1.6
diff -u -r1.6 Makefile.in
--- wine/dlls/user/tests/Makefile.in	28 Oct 2003 00:18:40 -0000	1.6
+++ wine/dlls/user/tests/Makefile.in	6 Jan 2004 20:32:03 -0000
@@ -9,6 +9,7 @@
 	class.c \
 	generated.c \
 	input.c \
+        IsDlgMsg.c \
 	listbox.c \
 	msg.c \
 	sysparams.c \
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ wine/dlls/user/tests/IsDlgMsg.c	2004-01-06 12:28:03.000000000 -0800
@@ -0,0 +1,153 @@
+/* Unit test suite for the IsDialogMessage function etc.
+ *
+ * Copyright 2004 Bill Medland
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <assert.h>
+#include <stdarg.h>
+
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+
+/* Global handles */
+HINSTANCE g_hinst;                          /* This application's HINSTANCE */
+HWND g_hwndLastFocus;
+HWND g_hwndMain, g_hwndButton1, g_hwndButtonCancel;
+
+/* Form the lParam of a WM_KEYDOWN message */
+static DWORD KeyDownData (int repeat, int scancode, int extended, int wasdown)
+{
+    return ((repeat & 0x0000FFFF) | ((scancode & 0x00FF) >> 16) | (extended ? 0x01000000 : 0) | (wasdown ? 0x40000000 : 0));
+}
+
+/* Form a WM_KEYDOWN message to the specified window */
+static void FormTabMsg (MSG *pMsg, HWND hwnd)
+{
+    pMsg->hwnd = hwnd;
+    pMsg->message = WM_KEYDOWN;
+    pMsg->wParam = VK_TAB;
+    pMsg->lParam = KeyDownData (1, 0x0F, 0, 0);
+    /* pMsg->time is not set.  It shouldn't be needed */
+    /* pMsg->pt is ignored */
+}
+
+/*
+ *  OnMainWindowCreate
+ */
+BOOL OnMainWindowCreate(HWND hwnd, LPCREATESTRUCT lpcs)
+{
+    g_hwndButton1 =
+        CreateWindow(
+        TEXT("button"),                 /* Class Name */
+        TEXT("Button &1"),              /* Title */
+        WS_CHILD | WS_VISIBLE | WS_TABSTOP |
+        BS_DEFPUSHBUTTON | BS_PUSHBUTTON | BS_TEXT,        /* Style */
+        0, 0, 100, 100,                 /* Position and size */
+        hwnd,                           /* Parent */
+        (HMENU)100,                     /* Child ID */
+        g_hinst,                        /* Instance */
+        0);                             /* No special parameters */
+    if (!g_hwndButton1) return FALSE;
+    g_hwndLastFocus = g_hwndButton1;
+
+    g_hwndButtonCancel =
+        CreateWindow(
+        TEXT("button"),                 /* Class Name */
+        TEXT("Cancel"),                 /* Title */
+        WS_CHILD | WS_VISIBLE | WS_TABSTOP |
+        BS_PUSHBUTTON | BS_TEXT,        /* Style */
+        100, 0, 100, 100,               /* Position and size */
+        hwnd,                           /* Parent */
+        (HMENU)IDCANCEL,                /* Child ID */
+        g_hinst,                        /* Instance */
+        0);                             /* No special parameters */
+    if (!g_hwndButtonCancel) return FALSE;
+
+    return TRUE;
+}
+
+LRESULT CALLBACK main_window_procA(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{
+    LRESULT result;
+    switch (uiMsg) {
+        // Add blank case statements for these to ensure we don't use them
+        // by mistake.
+        case DM_GETDEFID: break;
+        case DM_SETDEFID: break;
+
+        case WM_CREATE: return (OnMainWindowCreate(hwnd, (LPCREATESTRUCTA) lParam) ? 0 : (LRESULT) -1);
+    }
+
+    result=DefWindowProcA(hwnd, uiMsg, wParam, lParam);
+    return result;
+}
+
+static BOOL RegisterWindowClasses(void)
+{
+    WNDCLASSA cls;
+
+    cls.style = 0;
+    cls.lpfnWndProc = main_window_procA;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = g_hinst;
+    cls.hIcon = NULL;
+    cls.hCursor = LoadCursorA(NULL, IDC_ARROW);
+    cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "MainWindowClass";
+
+    if (!RegisterClassA(&cls)) return FALSE;
+
+    return TRUE;
+}
+
+static void IsDialogMessageWTest(void)
+{
+    MSG msg;
+
+    /* The focus should initially be nowhere.  The first TAB should take it
+     * to the first button.  The second TAB should take it to the Cancel
+     * button.
+     */
+    FormTabMsg (&msg, g_hwndMain);
+    ok (IsDialogMessage(g_hwndMain, &msg), "Did not handle first TAB");
+    ok ((GetFocus() == g_hwndButton1), "Focus did not move to first button");
+    FormTabMsg (&msg, g_hwndButton1);
+    ok (IsDialogMessage(g_hwndMain, &msg), "Did not handle second TAB");
+    ok ((GetFocus() == g_hwndButtonCancel), "Focus did not move to cancel button");
+}
+
+START_TEST(IsDlgMsg)
+{
+    if (!RegisterWindowClasses()) assert(0);
+
+    g_hinst = GetModuleHandleA(0);
+
+    g_hwndMain = CreateWindow( "MainWindowClass", "MainWindowClass",
+            WS_OVERLAPPEDWINDOW,
+            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+            NULL, NULL, g_hinst, 0);
+
+    assert (g_hwndMain);
+    assert (g_hwndButton1);
+    assert (g_hwndButtonCancel);
+
+    IsDialogMessageWTest();
+}





More information about the wine-patches mailing list