Author: akhaldi Date: Sun Mar 29 13:36:03 2015 New Revision: 66954 URL: http://svn.reactos.org/svn/reactos?rev=66954&view=rev Log: [WSHOM_WINETEST] Sync with Wine Staging 1.7.37. CORE-9246
Modified: trunk/rostests/winetests/wshom/CMakeLists.txt trunk/rostests/winetests/wshom/wshom.c trunk/rostests/winetests/wshom/wshom.idl Modified: trunk/rostests/winetests/wshom/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wshom/CMakeLists.txt?rev=66954&r1=66953&r2=66954&view=diff ============================================================================== --- trunk/rostests/winetests/wshom/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/wshom/CMakeLists.txt [iso-8859-1] Sun Mar 29 13:36:03 2015 @@ -1,8 +1,11 @@ +add_definitions(-DUSE_WINE_TODOS) -add_definitions(-DUSE_WINE_TODOS) +remove_definitions(-D_WIN32_WINNT=0x502) +add_definitions(-D_WIN32_WINNT=0x600) + add_idl_headers(wshom_winetest_idlheaders wshom.idl) add_executable(wshom_winetest wshom.c testlist.c) set_module_type(wshom_winetest win32cui) -add_importlibs(wshom_winetest oleaut32 ole32 msvcrt kernel32) +add_importlibs(wshom_winetest oleaut32 ole32 advapi32 msvcrt kernel32) add_dependencies(wshom_winetest stdole2 wshom_winetest_idlheaders) add_cd_file(TARGET wshom_winetest DESTINATION reactos/bin FOR all) Modified: trunk/rostests/winetests/wshom/wshom.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wshom/wshom.c?rev=66954&r1=66953&r2=66954&view=diff ============================================================================== --- trunk/rostests/winetests/wshom/wshom.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wshom/wshom.c [iso-8859-1] Sun Mar 29 13:36:03 2015 @@ -23,6 +23,7 @@ #include <windef.h> #include <winbase.h> +#include <winreg.h> #include <initguid.h> #include <dispex.h> #include <wshom.h> @@ -35,6 +36,7 @@ static void test_wshshell(void) { + static const WCHAR notepadW[] = {'n','o','t','e','p','a','d','.','e','x','e',0}; static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0}; static const WCHAR lnk1W[] = {'f','i','l','e','.','l','n','k',0}; static const WCHAR pathW[] = {'%','P','A','T','H','%',0}; @@ -45,7 +47,7 @@ IDispatchEx *dispex; IWshCollection *coll; IDispatch *disp, *shortcut; - IUnknown *shell; + IUnknown *shell, *unk; IFolderCollection *folders; IWshShortcut *shcut; ITypeInfo *ti; @@ -53,16 +55,14 @@ TYPEATTR *tattr; DISPPARAMS dp; EXCEPINFO ei; - VARIANT arg, res; + VARIANT arg, res, arg2; BSTR str, ret; + DWORD retval; UINT err; hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, &IID_IDispatch, (void**)&disp); - if(FAILED(hr)) { - win_skip("Could not create WshShell object: %08x\n", hr); - return; - } + ok(hr == S_OK, "got 0x%08x\n", hr); hr = IDispatch_QueryInterface(disp, &IID_IWshShell3, (void**)&shell); EXPECT_HR(hr, S_OK); @@ -73,6 +73,17 @@ hr = IUnknown_QueryInterface(shell, &IID_IWshShell3, (void**)&sh3); EXPECT_HR(hr, S_OK); + + hr = IWshShell3_QueryInterface(sh3, &IID_IObjectWithSite, (void**)&unk); + ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr); + + hr = IWshShell3_QueryInterface(sh3, &IID_IWshShell, (void**)&unk); + ok(hr == S_OK, "got 0x%08x\n", hr); + IUnknown_Release(unk); + + hr = IWshShell3_QueryInterface(sh3, &IID_IWshShell2, (void**)&unk); + ok(hr == S_OK, "got 0x%08x\n", hr); + IUnknown_Release(unk); hr = IWshShell3_get_SpecialFolders(sh3, &coll); EXPECT_HR(hr, S_OK); @@ -173,17 +184,324 @@ IWshEnvironment_Release(env); + V_VT(&arg) = VT_I2; + V_I2(&arg) = 0; + V_VT(&arg2) = VT_ERROR; + V_ERROR(&arg2) = DISP_E_PARAMNOTFOUND; + + str = SysAllocString(notepadW); + hr = IWshShell3_Run(sh3, str, &arg, &arg2, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + retval = 10; + hr = IWshShell3_Run(sh3, str, NULL, &arg2, &retval); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + ok(retval == 10, "got %u\n", retval); + + retval = 10; + hr = IWshShell3_Run(sh3, str, &arg, NULL, &retval); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + ok(retval == 10, "got %u\n", retval); + + retval = 10; + V_VT(&arg2) = VT_ERROR; + V_ERROR(&arg2) = 0; + hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval); + ok(hr == DISP_E_TYPEMISMATCH, "got 0x%08x\n", hr); + ok(retval == 10, "got %u\n", retval); + + SysFreeString(str); + IWshCollection_Release(coll); IDispatch_Release(disp); IWshShell3_Release(sh3); IUnknown_Release(shell); } +/* delete key and all its subkeys */ +static DWORD delete_key(HKEY hkey) +{ + char name[MAX_PATH]; + DWORD ret; + + while (!(ret = RegEnumKeyA(hkey, 0, name, sizeof(name)))) { + HKEY tmp; + if (!(ret = RegOpenKeyExA(hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp))) { + ret = delete_key(tmp); + RegCloseKey(tmp); + } + if (ret) break; + } + if (ret != ERROR_NO_MORE_ITEMS) return ret; + RegDeleteKeyA(hkey, ""); + return 0; +} + +static void test_registry(void) +{ + static const WCHAR keypathW[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\', + 'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','T','e','s','t','\\',0}; + + static const WCHAR regszW[] = {'r','e','g','s','z',0}; + static const WCHAR regdwordW[] = {'r','e','g','d','w','o','r','d',0}; + static const WCHAR regbinaryW[] = {'r','e','g','b','i','n','a','r','y',0}; + static const WCHAR regmultiszW[] = {'r','e','g','m','u','l','t','i','s','z',0}; + + static const WCHAR regsz1W[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','\\', + 'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','T','e','s','t','\\','r','e','g','s','z','1',0}; + static const WCHAR foobarW[] = {'f','o','o','b','a','r',0}; + static const WCHAR fooW[] = {'f','o','o',0}; + static const WCHAR brokenW[] = {'H','K','E','Y','_','b','r','o','k','e','n','_','k','e','y',0}; + static const WCHAR broken2W[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R','a',0}; + WCHAR pathW[MAX_PATH]; + DWORD dwvalue, type; + VARIANT value, v; + IWshShell3 *sh3; + VARTYPE vartype; + LONG bound; + HRESULT hr; + BSTR name; + HKEY root; + LONG ret; + UINT dim; + + hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + &IID_IWshShell3, (void**)&sh3); + ok(hr == S_OK, "got 0x%08x\n", hr); + + /* RegRead() */ + V_VT(&value) = VT_I2; + hr = IWshShell3_RegRead(sh3, NULL, &value); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_I2, "got %d\n", V_VT(&value)); + + name = SysAllocString(brokenW); + hr = IWshShell3_RegRead(sh3, name, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + V_VT(&value) = VT_I2; + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_I2, "got %d\n", V_VT(&value)); + SysFreeString(name); + + name = SysAllocString(broken2W); + V_VT(&value) = VT_I2; + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_I2, "got %d\n", V_VT(&value)); + SysFreeString(name); + + ret = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &root); + ok(ret == 0, "got %d\n", ret); + + ret = RegSetValueExA(root, "regsz", 0, REG_SZ, (const BYTE*)"foobar", 7); + ok(ret == 0, "got %d\n", ret); + + ret = RegSetValueExA(root, "regmultisz", 0, REG_MULTI_SZ, (const BYTE*)"foo\0bar\0", 9); + ok(ret == 0, "got %d\n", ret); + + dwvalue = 10; + ret = RegSetValueExA(root, "regdword", 0, REG_DWORD, (const BYTE*)&dwvalue, sizeof(dwvalue)); + ok(ret == 0, "got %d\n", ret); + + dwvalue = 11; + ret = RegSetValueExA(root, "regbinary", 0, REG_BINARY, (const BYTE*)&dwvalue, sizeof(dwvalue)); + ok(ret == 0, "got %d\n", ret); + + /* REG_SZ */ + lstrcpyW(pathW, keypathW); + lstrcatW(pathW, regszW); + name = SysAllocString(pathW); + VariantInit(&value); + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_BSTR, "got %d\n", V_VT(&value)); + ok(!lstrcmpW(V_BSTR(&value), foobarW), "got %s\n", wine_dbgstr_w(V_BSTR(&value))); + VariantClear(&value); + SysFreeString(name); + + /* REG_DWORD */ + lstrcpyW(pathW, keypathW); + lstrcatW(pathW, regdwordW); + name = SysAllocString(pathW); + VariantInit(&value); + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_I4, "got %d\n", V_VT(&value)); + ok(V_I4(&value) == 10, "got %d\n", V_I4(&value)); + SysFreeString(name); + + /* REG_BINARY */ + lstrcpyW(pathW, keypathW); + lstrcatW(pathW, regbinaryW); + name = SysAllocString(pathW); + VariantInit(&value); + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&value) == (VT_ARRAY|VT_VARIANT), "got 0x%x\n", V_VT(&value)); + dim = SafeArrayGetDim(V_ARRAY(&value)); + ok(dim == 1, "got %u\n", dim); + + hr = SafeArrayGetLBound(V_ARRAY(&value), 1, &bound); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bound == 0, "got %u\n", bound); + + hr = SafeArrayGetUBound(V_ARRAY(&value), 1, &bound); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bound == 3, "got %u\n", bound); + + hr = SafeArrayGetVartype(V_ARRAY(&value), &vartype); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(vartype == VT_VARIANT, "got %d\n", vartype); + + bound = 0; + hr = SafeArrayGetElement(V_ARRAY(&value), &bound, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&v) == VT_UI1, "got %d\n", V_VT(&v)); + ok(V_UI1(&v) == 11, "got %u\n", V_UI1(&v)); + VariantClear(&v); + VariantClear(&value); + SysFreeString(name); + + /* REG_MULTI_SZ */ + lstrcpyW(pathW, keypathW); + lstrcatW(pathW, regmultiszW); + name = SysAllocString(pathW); + VariantInit(&value); + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&value) == (VT_ARRAY|VT_VARIANT), "got 0x%x\n", V_VT(&value)); + + dim = SafeArrayGetDim(V_ARRAY(&value)); + ok(dim == 1, "got %u\n", dim); + + hr = SafeArrayGetLBound(V_ARRAY(&value), 1, &bound); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bound == 0, "got %u\n", bound); + + hr = SafeArrayGetUBound(V_ARRAY(&value), 1, &bound); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(bound == 1, "got %u\n", bound); + + hr = SafeArrayGetVartype(V_ARRAY(&value), &vartype); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(vartype == VT_VARIANT, "got %d\n", vartype); + + bound = 0; + hr = SafeArrayGetElement(V_ARRAY(&value), &bound, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v)); + ok(!lstrcmpW(V_BSTR(&v), fooW), "got %s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + VariantClear(&value); + + name = SysAllocString(regsz1W); + V_VT(&value) = VT_I2; + hr = IWshShell3_RegRead(sh3, name, &value); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); + ok(V_VT(&value) == VT_I2, "got %d\n", V_VT(&value)); + VariantClear(&value); + SysFreeString(name); + + delete_key(root); + + /* RegWrite() */ + ret = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Test", &root); + ok(ret == 0, "got %d\n", ret); + + hr = IWshShell3_RegWrite(sh3, NULL, NULL, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + lstrcpyW(pathW, keypathW); + lstrcatW(pathW, regszW); + name = SysAllocString(pathW); + + hr = IWshShell3_RegWrite(sh3, name, NULL, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + VariantInit(&value); + hr = IWshShell3_RegWrite(sh3, name, &value, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + hr = IWshShell3_RegWrite(sh3, name, &value, &value); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + /* type is optional */ + V_VT(&v) = VT_ERROR; + V_ERROR(&v) = DISP_E_PARAMNOTFOUND; + hr = IWshShell3_RegWrite(sh3, name, &value, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + + /* default type is REG_SZ */ + V_VT(&value) = VT_I4; + V_I4(&value) = 12; + hr = IWshShell3_RegWrite(sh3, name, &value, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + + type = REG_NONE; + ret = RegGetValueA(root, NULL, "regsz", RRF_RT_ANY, &type, NULL, NULL); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + ok(type == REG_SZ, "got %d\n", type); + + ret = RegDeleteValueA(root, "regsz"); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + V_VT(&value) = VT_BSTR; + V_BSTR(&value) = SysAllocString(regszW); + hr = IWshShell3_RegWrite(sh3, name, &value, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + VariantClear(&value); + + type = REG_NONE; + ret = RegGetValueA(root, NULL, "regsz", RRF_RT_ANY, &type, NULL, NULL); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + ok(type == REG_SZ, "got %d\n", type); + + ret = RegDeleteValueA(root, "regsz"); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + V_VT(&value) = VT_R4; + V_R4(&value) = 1.2; + hr = IWshShell3_RegWrite(sh3, name, &value, &v); + ok(hr == S_OK, "got 0x%08x\n", hr); + VariantClear(&value); + + type = REG_NONE; + ret = RegGetValueA(root, NULL, "regsz", RRF_RT_ANY, &type, NULL, NULL); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + ok(type == REG_SZ, "got %d\n", type); + + ret = RegDeleteValueA(root, "regsz"); + ok(ret == ERROR_SUCCESS, "got %d\n", ret); + V_VT(&value) = VT_R4; + V_R4(&value) = 1.2; + V_VT(&v) = VT_I2; + V_I2(&v) = 1; + hr = IWshShell3_RegWrite(sh3, name, &value, &v); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + VariantClear(&value); + + SysFreeString(name); + + delete_key(root); + IWshShell3_Release(sh3); +} + START_TEST(wshom) { + IUnknown *unk; + HRESULT hr; + CoInitialize(NULL); + hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + &IID_IUnknown, (void**)&unk); + if (FAILED(hr)) { + win_skip("Could not create WshShell object: %08x\n", hr); + return; + } + IUnknown_Release(unk); + test_wshshell(); + test_registry(); CoUninitialize(); } Modified: trunk/rostests/winetests/wshom/wshom.idl URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wshom/wshom.idl?rev=66954&r1=66953&r2=66954&view=diff ============================================================================== --- trunk/rostests/winetests/wshom/wshom.idl [iso-8859-1] (original) +++ trunk/rostests/winetests/wshom/wshom.idl [iso-8859-1] Sun Mar 29 13:36:03 2015 @@ -526,7 +526,7 @@ [in] BSTR Command, [in, optional] VARIANT* WindowStyle, [in, optional] VARIANT* WaitOnReturn, - [out, retval] int* out_ExitCode); + [out, retval] DWORD* out_ExitCode); [id(0x03e9)] HRESULT Popup(