Added user32 regression tests that we pass to the regtests system. Working on reviewi...
authorSteven Edwards <winehacker@gmail.com>
Thu, 9 Sep 2004 04:18:30 +0000 (04:18 +0000)
committerSteven Edwards <winehacker@gmail.com>
Thu, 9 Sep 2004 04:18:30 +0000 (04:18 +0000)
svn path=/trunk/; revision=10805

reactos/regtests/user32/.cvsignore [new file with mode: 0755]
reactos/regtests/user32/Makefile [new file with mode: 0755]
reactos/regtests/user32/dde.c [new file with mode: 0644]
reactos/regtests/user32/testlist.c [new file with mode: 0644]
reactos/regtests/user32/wsprintf.c [new file with mode: 0644]

diff --git a/reactos/regtests/user32/.cvsignore b/reactos/regtests/user32/.cvsignore
new file mode 100755 (executable)
index 0000000..4ffa79b
--- /dev/null
@@ -0,0 +1,8 @@
+*.o
+*.d
+*.dll
+*.coff
+*.sym
+*.map
+_regtests.c
+Makefile.tests
diff --git a/reactos/regtests/user32/Makefile b/reactos/regtests/user32/Makefile
new file mode 100755 (executable)
index 0000000..2719987
--- /dev/null
@@ -0,0 +1,26 @@
+# $Id: Makefile,v 1.1 2004/09/09 04:18:30 sedwards Exp $
+
+PATH_TO_TOP = ../..
+
+TARGET_NORC = yes
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = console
+
+TARGET_NAME = user32_test
+
+TARGET_SDKLIBS = ntdll.a kernel32.a user32.a
+
+TARGET_CFLAGS = -D__USE_W32API -I../shared -Wall
+
+TARGET_OBJECTS = \
+  dde.o \
+  testlist.o \
+  wsprintf.o
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+# EOF
diff --git a/reactos/regtests/user32/dde.c b/reactos/regtests/user32/dde.c
new file mode 100644 (file)
index 0000000..c0b8696
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Unit tests for DDE functions
+ *
+ * Copyright (c) 2004 Dmitry Timoshkov
+ *
+ * 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 "wine/test.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ddeml.h"
+#include "winerror.h"
+
+static HDDEDATA CALLBACK DdeCallback(UINT uType, UINT uFmt, HCONV hconv,
+                                     HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
+                                     ULONG_PTR dwData1, ULONG_PTR dwData2)
+{
+    return 0;
+}
+
+static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage)
+{
+    static const WCHAR dde_string[] = {'D','D','E',' ','S','t','r','i','n','g',0};
+    HSZ str_handle;
+    WCHAR bufW[256];
+    char buf[256];
+    int ret;
+
+    str_handle = DdeCreateStringHandleW(dde_inst, dde_string, codepage);
+    ok(str_handle != 0, "DdeCreateStringHandleW failed with error %08x\n",
+       DdeGetLastError(dde_inst));
+
+    ret = DdeQueryStringW(dde_inst, str_handle, NULL, 0, codepage);
+    if (codepage == CP_WINANSI)
+        ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
+    else
+        ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
+
+    ret = DdeQueryStringW(dde_inst, str_handle, bufW, 256, codepage);
+    if (codepage == CP_WINANSI)
+    {
+        ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
+        ok(!lstrcmpA("D", (LPCSTR)bufW), "DdeQueryStringW returned wrong string\n");
+    }
+    else
+    {
+        ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
+        ok(!lstrcmpW(dde_string, bufW), "DdeQueryStringW returned wrong string\n");
+    }
+
+    ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINANSI);
+    if (codepage == CP_WINANSI)
+    {
+        ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
+        ok(!lstrcmpA("D", buf), "DdeQueryStringW returned wrong string\n");
+    }
+    else
+    {
+        ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
+        ok(!lstrcmpA("DDE String", buf), "DdeQueryStringA returned wrong string %s\n", buf);
+    }
+
+    ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINUNICODE);
+    if (codepage == CP_WINANSI)
+    {
+        ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
+        ok(!lstrcmpA("D", buf), "DdeQueryStringA returned wrong string %s\n", buf);
+    }
+    else
+    {
+        ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
+        ok(!lstrcmpW(dde_string, (LPCWSTR)buf), "DdeQueryStringW returned wrong string\n");
+    }
+
+    ok(DdeFreeStringHandle(dde_inst, str_handle), "DdeFreeStringHandle failed\n");
+}
+
+START_TEST(dde)
+{
+    DWORD dde_inst, ret;
+
+    dde_inst = 0xdeadbeef;
+    SetLastError(0xdeadbeef);
+    ret = DdeInitializeW(&dde_inst, DdeCallback, APPCMD_CLIENTONLY, 0);
+    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+    {
+        trace("Skipping the DDE test on a Win9x platform\n");
+        return;
+    }
+
+    ok(ret == DMLERR_INVALIDPARAMETER, "DdeInitializeW should fail, but got %04lx instead\n", ret);
+    ok(DdeGetLastError(dde_inst) == DMLERR_INVALIDPARAMETER, "expected DMLERR_INVALIDPARAMETER\n");
+
+    dde_inst = 0;
+    ret = DdeInitializeW(&dde_inst, DdeCallback, APPCMD_CLIENTONLY, 0);
+    ok(ret == DMLERR_NO_ERROR, "DdeInitializeW failed with error %04lx (%08x)\n",
+       ret, DdeGetLastError(dde_inst));
+
+    test_DdeCreateStringHandleW(dde_inst, 0);
+    test_DdeCreateStringHandleW(dde_inst, CP_WINUNICODE);
+    test_DdeCreateStringHandleW(dde_inst, CP_WINANSI);
+
+    ok(DdeUninitialize(dde_inst), "DdeUninitialize failed\n");
+}
diff --git a/reactos/regtests/user32/testlist.c b/reactos/regtests/user32/testlist.c
new file mode 100644 (file)
index 0000000..b1c73e0
--- /dev/null
@@ -0,0 +1,49 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+/* stdarg.h is needed for Winelib */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "windef.h"
+#include "winbase.h"
+
+//extern void func_class(void);
+//extern void func_clipboard(void);
+extern void func_dde(void);
+//extern void func_dialog(void);
+//extern void func_generated(void);
+//extern void func_input(void);
+//extern void func_listbox(void);
+//extern void func_msg(void);
+//extern void func_resource(void);
+//extern void func_sysparams(void);
+//extern void func_text(void);
+//extern void func_win(void);
+extern void func_wsprintf(void);
+
+struct test
+{
+    const char *name;
+    void (*func)(void);
+};
+
+static const struct test winetest_testlist[] =
+{
+//    { "class", func_class },
+//    { "clipboard", func_clipboard },
+    { "dde", func_dde },
+//    { "dialog", func_dialog },
+//    { "generated", func_generated },
+//    { "input", func_input },
+//    { "listbox", func_listbox },
+//    { "msg", func_msg },
+//    { "resource", func_resource },
+//    { "sysparams", func_sysparams },
+//    { "text", func_text },
+//    { "win", func_win },
+    { "wsprintf", func_wsprintf },
+    { 0, 0 }
+};
+
+#define WINETEST_WANT_MAIN
+#include "wine/test.h"
diff --git a/reactos/regtests/user32/wsprintf.c b/reactos/regtests/user32/wsprintf.c
new file mode 100644 (file)
index 0000000..bbebdd7
--- /dev/null
@@ -0,0 +1,57 @@
+ /* Unit test suite for the wsprintf functions
+ *
+ * Copyright 2002 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 <stdarg.h>
+
+#include "wine/test.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+
+static void wsprintfATest(void)
+{
+    char buf[25];
+    int rc;
+
+    rc=wsprintfA(buf, "%010ld", -1);
+    ok(rc == 10, "wsPrintfA length failure: rc=%d error=%ld\n",rc,GetLastError());
+    ok((lstrcmpA(buf, "-000000001") == 0),
+       "wsprintfA zero padded negative value failure: buf=[%s]\n",buf);
+}
+
+static void wsprintfWTest(void)
+{
+    static const WCHAR fmt[] = {'%','0','1','0','l','d','\0'};
+    static const WCHAR target[] = {'-','0','0','0','0','0','0','0','0','1', '\0'};
+    WCHAR buf[25];
+    int rc;
+
+    rc=wsprintfW(buf, fmt, -1);
+    if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
+        return;
+    ok(rc == 10, "wsPrintfW length failure: rc=%d error=%ld\n",rc,GetLastError());
+    ok((lstrcmpW(buf, target) == 0),
+       "wsprintfW zero padded negative value failure\n");
+}
+
+START_TEST(wsprintf)
+{
+    wsprintfATest();
+    wsprintfWTest();
+}