From 609b0c530702311e3707c6bbf84be2863f419de9 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Sun, 7 Nov 2004 22:19:07 +0000 Subject: [PATCH] Added Wine ole32 tests. As of 2004-10-7 we pass all of the tests except the one marked todo in Wine. It has been disabled. svn path=/trunk/; revision=11585 --- reactos/lib/ole32/tests/.cvsignore | 5 + reactos/lib/ole32/tests/Makefile | 28 ++++ reactos/lib/ole32/tests/propvariant.c | 211 ++++++++++++++++++++++++++ reactos/lib/ole32/tests/storage32.c | 74 +++++++++ reactos/lib/ole32/tests/testlist.c | 27 ++++ 5 files changed, 345 insertions(+) create mode 100644 reactos/lib/ole32/tests/.cvsignore create mode 100644 reactos/lib/ole32/tests/Makefile create mode 100644 reactos/lib/ole32/tests/propvariant.c create mode 100644 reactos/lib/ole32/tests/storage32.c create mode 100644 reactos/lib/ole32/tests/testlist.c diff --git a/reactos/lib/ole32/tests/.cvsignore b/reactos/lib/ole32/tests/.cvsignore new file mode 100644 index 00000000000..4214d70a7b6 --- /dev/null +++ b/reactos/lib/ole32/tests/.cvsignore @@ -0,0 +1,5 @@ +*.o +*.a +*.exe +*.map +*.sym \ No newline at end of file diff --git a/reactos/lib/ole32/tests/Makefile b/reactos/lib/ole32/tests/Makefile new file mode 100644 index 00000000000..675c78c43a3 --- /dev/null +++ b/reactos/lib/ole32/tests/Makefile @@ -0,0 +1,28 @@ +# $Id: Makefile,v 1.1 2004/11/07 22:19:07 sedwards Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +# require os code to explicitly request A/W version of structs/functions +TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API -D_WIN32_IE=0x0600 \ + -D_WIN32_WINNT=0x0501 -D__REACTOS__ + +TARGET_NAME = ole32_test + +TARGET_SDKLIBS = oleaut32.a ole32.a ntdll.a + +TARGET_OBJECTS = \ + testlist.o \ + propvariant.o \ + storage32.o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF \ No newline at end of file diff --git a/reactos/lib/ole32/tests/propvariant.c b/reactos/lib/ole32/tests/propvariant.c new file mode 100644 index 00000000000..9cb71adf8f9 --- /dev/null +++ b/reactos/lib/ole32/tests/propvariant.c @@ -0,0 +1,211 @@ +/* + * PropVariant Tests + * + * Copyright 2004 Robert Shearman + * + * 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 "windows.h" + +HRESULT WINAPI PropVariantCopy(PROPVARIANT*,const PROPVARIANT*); +HRESULT WINAPI PropVariantClear(PROPVARIANT*); + +#include "wine/test.h" + +#ifdef NONAMELESSUNION +# define U(x) (x).u +#else +# define U(x) (x) +#endif + +struct valid_mapping +{ + BOOL simple; + BOOL with_array; + BOOL with_vector; + BOOL byref; +} valid_types[] = +{ + { TRUE , FALSE, FALSE, FALSE }, /* VT_EMPTY */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_NULL */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_I2 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_I4 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_R4 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_R8 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_CY */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_DATE */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_BSTR */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_DISPATCH */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_ERROR */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_BOOL */ + { FALSE, FALSE, TRUE , FALSE }, /* VT_VARIANT */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_UNKNOWN */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_DECIMAL */ + { FALSE, FALSE, FALSE, FALSE }, /* 15 */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_I1 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_UI1 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_UI2 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_UI4 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_I8 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_UI8 */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_INT */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_UINT */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_VOID */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_HRESULT */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_PTR */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_SAFEARRAY */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_CARRAY */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_USERDEFINED */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_LPSTR */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_LPWSTR */ + { FALSE, FALSE, FALSE, FALSE }, /* 32 */ + { FALSE, FALSE, FALSE, FALSE }, /* 33 */ + { FALSE, FALSE, FALSE, FALSE }, /* 34 */ + { FALSE, FALSE, FALSE, FALSE }, /* 35 */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_RECORD */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_INT_PTR */ + { FALSE, FALSE, FALSE, FALSE }, /* VT_UINT_PTR */ + { FALSE, FALSE, FALSE, FALSE }, /* 39 */ + { FALSE, FALSE, FALSE, FALSE }, /* 40 */ + { FALSE, FALSE, FALSE, FALSE }, /* 41 */ + { FALSE, FALSE, FALSE, FALSE }, /* 42 */ + { FALSE, FALSE, FALSE, FALSE }, /* 43 */ + { FALSE, FALSE, FALSE, FALSE }, /* 44 */ + { FALSE, FALSE, FALSE, FALSE }, /* 45 */ + { FALSE, FALSE, FALSE, FALSE }, /* 46 */ + { FALSE, FALSE, FALSE, FALSE }, /* 47 */ + { FALSE, FALSE, FALSE, FALSE }, /* 48 */ + { FALSE, FALSE, FALSE, FALSE }, /* 49 */ + { FALSE, FALSE, FALSE, FALSE }, /* 50 */ + { FALSE, FALSE, FALSE, FALSE }, /* 51 */ + { FALSE, FALSE, FALSE, FALSE }, /* 52 */ + { FALSE, FALSE, FALSE, FALSE }, /* 53 */ + { FALSE, FALSE, FALSE, FALSE }, /* 54 */ + { FALSE, FALSE, FALSE, FALSE }, /* 55 */ + { FALSE, FALSE, FALSE, FALSE }, /* 56 */ + { FALSE, FALSE, FALSE, FALSE }, /* 57 */ + { FALSE, FALSE, FALSE, FALSE }, /* 58 */ + { FALSE, FALSE, FALSE, FALSE }, /* 59 */ + { FALSE, FALSE, FALSE, FALSE }, /* 60 */ + { FALSE, FALSE, FALSE, FALSE }, /* 61 */ + { FALSE, FALSE, FALSE, FALSE }, /* 62 */ + { FALSE, FALSE, FALSE, FALSE }, /* 63 */ + { TRUE , FALSE, TRUE , FALSE }, /* VT_FILETIME */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_BLOB */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_STREAM */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_STORAGE */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_STREAMED_OBJECT */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_STORED_OBJECT */ + { TRUE , FALSE, FALSE, FALSE }, /* VT_BLOB_OBJECT */ + { TRUE , FALSE, TRUE , FALSE } /* VT_CF */ +}; + +static const char* wine_vtypes[VT_CLSID+1] = +{ + "VT_EMPTY","VT_NULL","VT_I2","VT_I4","VT_R4","VT_R8","VT_CY","VT_DATE", + "VT_BSTR","VT_DISPATCH","VT_ERROR","VT_BOOL","VT_VARIANT","VT_UNKNOWN", + "VT_DECIMAL","15","VT_I1","VT_UI1","VT_UI2","VT_UI4","VT_I8","VT_UI8", + "VT_INT","VT_UINT","VT_VOID","VT_HRESULT","VT_PTR","VT_SAFEARRAY", + "VT_CARRAY","VT_USERDEFINED","VT_LPSTR","VT_LPWSTR","32","33","34","35", + "VT_RECORD","VT_INT_PTR","VT_UINT_PTR","39","40","41","42","43","44","45", + "46","47","48","49","50","51","52","53","54","55","56","57","58","59","60", + "61","62","63","VT_FILETIME","VT_BLOB","VT_STREAM","VT_STORAGE", + "VT_STREAMED_OBJECT","VT_STORED_OBJECT","VT_BLOB_OBJECT","VT_CF","VT_CLSID" +}; + +static void test_validtypes() +{ + PROPVARIANT propvar; + HRESULT hr; + unsigned int i; + + memset(&propvar, 0, sizeof(propvar)); + + for (i = 0; i < sizeof(valid_types)/sizeof(valid_types[0]); i++) + { + propvar.vt = i; + hr = PropVariantClear(&propvar); + ok(valid_types[i].simple == !(hr == STG_E_INVALIDPARAMETER), + "PropVariantClear(%s) should have returned 0x%08lx, but returned 0x%08lx\n", + wine_vtypes[i], + valid_types[i].simple ? S_OK : STG_E_INVALIDPARAMETER, hr); + + propvar.vt = i | VT_ARRAY; + hr = PropVariantClear(&propvar); + ok(valid_types[i].with_array == !(hr == STG_E_INVALIDPARAMETER), + "PropVariantClear(%s|VT_ARRAY) should have returned 0x%08lx, but returned 0x%08lx\n", + wine_vtypes[i], + valid_types[i].with_array ? S_OK : STG_E_INVALIDPARAMETER, hr); + + propvar.vt = i | VT_VECTOR; + hr = PropVariantClear(&propvar); + ok(valid_types[i].with_vector == !(hr == STG_E_INVALIDPARAMETER), + "PropVariantClear(%s|VT_VECTOR) should have returned 0x%08lx, but returned 0x%08lx\n", + wine_vtypes[i], + valid_types[i].with_vector ? S_OK : STG_E_INVALIDPARAMETER, hr); + + propvar.vt = i | VT_BYREF; + hr = PropVariantClear(&propvar); + ok(valid_types[i].byref == !(hr == STG_E_INVALIDPARAMETER), + "PropVariantClear(%s|VT_BYREF) should have returned 0x%08lx, but returned 0x%08lx\n", + wine_vtypes[i], + valid_types[i].byref ? S_OK : STG_E_INVALIDPARAMETER, hr); + } +} + +static void test_copy() +{ + static const char szTestString[] = "Test String"; + static const WCHAR wszTestString[] = {'T','e','s','t',' ','S','t','r','i','n','g',0}; + PROPVARIANT propvarSrc; + PROPVARIANT propvarDst; + HRESULT hr; + + propvarSrc.vt = VT_BSTR; + U(propvarSrc).bstrVal = SysAllocString(wszTestString); + + hr = PropVariantCopy(&propvarDst, &propvarSrc); + ok(hr == S_OK, "PropVariantCopy(...VT_BSTR...) failed\n"); + ok(!lstrcmpW(U(propvarSrc).bstrVal, U(propvarDst).bstrVal), "BSTR not copied properly\n"); + hr = PropVariantClear(&propvarSrc); + ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n"); + hr = PropVariantClear(&propvarDst); + ok(hr == S_OK, "PropVariantClear(...VT_BSTR...) failed\n"); + + propvarSrc.vt = VT_LPWSTR; + U(propvarSrc).pwszVal = (LPWSTR)wszTestString; + hr = PropVariantCopy(&propvarDst, &propvarSrc); + ok(hr == S_OK, "PropVariantCopy(...VT_LPWSTR...) failed\n"); + ok(!lstrcmpW(U(propvarSrc).pwszVal, U(propvarDst).pwszVal), "Wide string not copied properly\n"); + hr = PropVariantClear(&propvarDst); + ok(hr == S_OK, "PropVariantClear(...VT_LPWSTR...) failed\n"); + memset(&propvarSrc, 0, sizeof(propvarSrc)); + + propvarSrc.vt = VT_LPSTR; + U(propvarSrc).pszVal = (LPSTR)szTestString; + hr = PropVariantCopy(&propvarDst, &propvarSrc); + ok(hr == S_OK, "PropVariantCopy(...VT_LPSTR...) failed\n"); + ok(!strcmp(U(propvarSrc).pszVal, U(propvarDst).pszVal), "String not copied properly\n"); + hr = PropVariantClear(&propvarDst); + ok(hr == S_OK, "PropVariantClear(...VT_LPSTR...) failed\n"); + memset(&propvarSrc, 0, sizeof(propvarSrc)); +} + +START_TEST(propvariant) +{ + test_validtypes(); + test_copy(); +} diff --git a/reactos/lib/ole32/tests/storage32.c b/reactos/lib/ole32/tests/storage32.c new file mode 100644 index 00000000000..24cb512852e --- /dev/null +++ b/reactos/lib/ole32/tests/storage32.c @@ -0,0 +1,74 @@ +/* + * Unit tests for OLE storage + * + * Copyright (c) 2004 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 + +#define COBJMACROS + +#include "wine/test.h" +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "ole2.h" +#include "objidl.h" +#include "initguid.h" + +DEFINE_GUID( test_stg_cls, 0x88888888, 0x0425, 0x0000, 0,0,0,0,0,0,0,0); + +void test_hglobal_storage_stat(void) +{ + ILockBytes *ilb = NULL; + IStorage *stg = NULL; + HRESULT r; + STATSTG stat; + DWORD mode, refcount; + + r = CreateILockBytesOnHGlobal( NULL, TRUE, &ilb ); + ok( r == S_OK, "CreateILockBytesOnHGlobal failed\n"); + + mode = STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE;/*0x1012*/ + r = StgCreateDocfileOnILockBytes( ilb, mode, 0, &stg ); + ok( r == S_OK, "CreateILockBytesOnHGlobal failed\n"); + + r = WriteClassStg( stg, &test_stg_cls ); + ok( r == S_OK, "WriteClassStg failed\n"); + + memset( &stat, 0, sizeof stat ); + r = IStorage_Stat( stg, &stat, 0 ); + + ok( stat.pwcsName == NULL, "storage name not null\n"); + ok( stat.type == 1, "type is wrong\n"); +#ifndef __REACTOS__ + todo_wine { + ok( stat.grfMode == 0x12, "grf mode is incorrect\n"); + } +#endif + ok( !memcmp(&stat.clsid, &test_stg_cls, sizeof test_stg_cls), "CLSID is wrong\n"); + + refcount = IStorage_Release( stg ); + ok( refcount == 0, "IStorage refcount is wrong\n"); + refcount = ILockBytes_Release( ilb ); + ok( refcount == 0, "ILockBytes refcount is wrong\n"); +} + +START_TEST(storage32) +{ + test_hglobal_storage_stat(); +} diff --git a/reactos/lib/ole32/tests/testlist.c b/reactos/lib/ole32/tests/testlist.c new file mode 100644 index 00000000000..8d3b343b864 --- /dev/null +++ b/reactos/lib/ole32/tests/testlist.c @@ -0,0 +1,27 @@ +/* Automatically generated file; DO NOT EDIT!! */ + +/* stdarg.h is needed for Winelib */ +#include +#include +#include +#include "windef.h" +#include "winbase.h" + +extern void func_propvariant(void); +extern void func_storage32(void); + +struct test +{ + const char *name; + void (*func)(void); +}; + +static const struct test winetest_testlist[] = +{ + { "propvariant", func_propvariant }, + { "storage32", func_storage32 }, + { 0, 0 } +}; + +#define WINETEST_WANT_MAIN +#include "wine/test.h"