USER32: add a short test for child windows

Mike McCormack mike at codeweavers.com
Fri Oct 29 00:30:26 CDT 2004


ChangeLog:
* add a short test for child windows
-------------- next part --------------
? dlls/user/tests/child.c
? dlls/user/tests/child.ok
Index: dlls/user/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/Makefile.in,v
retrieving revision 1.11
diff -u -r1.11 Makefile.in
--- dlls/user/tests/Makefile.in	20 Jul 2004 22:09:14 -0000	1.11
+++ dlls/user/tests/Makefile.in	29 Oct 2004 05:24:23 -0000
@@ -6,6 +6,7 @@
 IMPORTS   = user32 gdi32 advapi32
 
 CTESTS = \
+	child.c \
 	class.c \
 	clipboard.c \
 	dde.c \
--- /dev/null	1994-07-18 08:46:18.000000000 +0900
+++ dlls/user/tests/child.c	2004-10-29 14:26:49.000000000 +0900
@@ -0,0 +1,106 @@
+/* Unit test for Child Popup windows
+ *
+ * Copyright 2002 Mike McCormack
+ *
+ * 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 <stdlib.h>
+#include <stdio.h>
+
+#include "wine/test.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+
+START_TEST(child)
+{
+    WNDCLASSA cls,child_cls;
+    char className[] = "parentclass";  /* To make sure className >= 0x10000 */
+    char winName[]   = "parent window";
+    char childclassName[] = "childclass";  /* To make sure className >= 0x10000 */
+    char childwinName[]   = "child window";
+    HWND hWnd, hChild;
+    HINSTANCE hInstance = GetModuleHandleA( NULL );
+
+    cls.style         = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
+    cls.lpfnWndProc   = DefWindowProcA;
+    cls.cbClsExtra    = 0;
+    cls.cbWndExtra    = 0;
+    cls.hInstance     = 0;
+    cls.hIcon         = LoadIconA (0, (LPSTR)IDI_APPLICATION);
+    cls.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
+    cls.hbrBackground = GetStockObject (WHITE_BRUSH);
+    cls.lpszMenuName  = 0;
+    cls.lpszClassName = className;
+
+    ok (RegisterClassA (&cls), "unable to register class") ;
+
+    hWnd = CreateWindowA (className, winName, 
+       WS_OVERLAPPEDWINDOW ,
+       CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
+	   0, 
+       hInstance, 0);
+
+    ok(hWnd != 0, "Couldn't create parent window");
+
+    child_cls.style         = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
+    child_cls.lpfnWndProc   = DefWindowProcA;
+    child_cls.cbClsExtra    = 0;
+    child_cls.cbWndExtra    = 0;
+    child_cls.hInstance     = 0;
+    child_cls.hIcon         = LoadIconA (0, (LPSTR)IDI_APPLICATION);
+    child_cls.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
+    child_cls.hbrBackground = GetStockObject (GRAY_BRUSH);
+    child_cls.lpszMenuName  = 0;
+    child_cls.lpszClassName = childclassName;
+
+    ok (RegisterClassA (&child_cls) , "unable to register child class");
+
+    /* NOTE:    WS_POPUP should override WS_CHILD */
+
+    hChild = CreateWindowExA (
+	   0, childclassName, childwinName, 
+       WS_POPUP | WS_CHILD | WS_CLIPCHILDREN,
+       50, 50, 50, 100, hWnd, 
+	   0, hInstance, 0);
+
+    ok(hChild != 0, "Couldn't create child window");
+
+    ok(!SetActiveWindow(hChild),
+        "Can activate without parent window");
+
+    ok(GetAncestor(hChild, GA_PARENT) == GetDesktopWindow(),
+        "ancestor is not the desktop window");
+
+    ShowWindow (hWnd, SW_SHOW);
+    UpdateWindow (hWnd);
+
+    ok(SetActiveWindow(hChild) != 0,
+        "Can't activate window with parent active");
+
+    ShowWindow (hChild, SW_SHOW);
+    UpdateWindow (hChild);
+    
+    ok(SetActiveWindow(hChild) != 0,
+        "Can't activate window with parent active");
+
+    DestroyWindow(hChild);
+    DestroyWindow(hWnd);
+}
+


More information about the wine-patches mailing list