From b652ba2ef1b4ce4cb83021424cc2baa38c740e49 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 20 Jul 2015 22:58:24 +0000 Subject: [PATCH] [SHLWAPI_WINETEST] Sync with Wine Staging 1.7.47. CORE-9924 svn path=/trunk/; revision=68502 --- rostests/winetests/shlwapi/istream.c | 3 +- rostests/winetests/shlwapi/ordinal.c | 98 +++++++++++++++++++++++++++- rostests/winetests/shlwapi/path.c | 15 +++-- rostests/winetests/shlwapi/url.c | 2 +- 4 files changed, 108 insertions(+), 10 deletions(-) diff --git a/rostests/winetests/shlwapi/istream.c b/rostests/winetests/shlwapi/istream.c index bf116b3de0e..a1c90181f69 100644 --- a/rostests/winetests/shlwapi/istream.c +++ b/rostests/winetests/shlwapi/istream.c @@ -489,7 +489,8 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm) static const CHAR testEx_txt[] = "\\testEx.txt"; BOOL delret; - trace("SHCreateStreamOnFileEx: testing mode %d, STGM flags %08x\n", mode, stgm); + if (winetest_debug > 1) + trace("SHCreateStreamOnFileEx: testing mode %d, STGM flags %08x\n", mode, stgm); /* Don't used a fixed path for the testEx.txt file */ GetTempPathA(MAX_PATH, test_fileA); diff --git a/rostests/winetests/shlwapi/ordinal.c b/rostests/winetests/shlwapi/ordinal.c index 7f76cb504cd..dac2f2ad583 100755 --- a/rostests/winetests/shlwapi/ordinal.c +++ b/rostests/winetests/shlwapi/ordinal.c @@ -75,6 +75,7 @@ static HRESULT (WINAPI *pSKSetValueW)(DWORD, LPCWSTR, LPCWSTR, DWORD, void*, DWO static HRESULT (WINAPI *pSKDeleteValueW)(DWORD, LPCWSTR, LPCWSTR); static HRESULT (WINAPI *pSKAllocValueW)(DWORD, LPCWSTR, LPCWSTR, DWORD*, void**, DWORD*); static HWND (WINAPI *pSHSetParentHwnd)(HWND, HWND); +static HRESULT (WINAPI *pIUnknown_GetClassID)(IUnknown*, CLSID*); static HMODULE hmlang; static HRESULT (WINAPI *pLcidToRfc1766A)(LCID, LPSTR, INT); @@ -553,10 +554,10 @@ static void test_alloc_shared_remote(DWORD procid, HANDLE hmem) hmem2 = pSHMapHandle(hmem, procid, GetCurrentProcessId(), 0, 0); /* It seems like Windows Vista/2008 uses a different internal implementation - * for shared memory, and calling SHMapHandle fails with ERROR_INVALID_HANDLE. */ - ok(hmem2 != NULL || broken(hmem2 == NULL && GetLastError() == ERROR_INVALID_HANDLE), + * for shared memory, and calling SHMapHandle fails. */ + ok(hmem2 != NULL || broken(hmem2 == NULL), "SHMapHandle failed: %u\n", GetLastError()); - if (hmem2 == NULL && GetLastError() == ERROR_INVALID_HANDLE) + if (hmem2 == NULL) { win_skip("Subprocess failed to map shared memory, skipping test\n"); return; @@ -3053,6 +3054,7 @@ static void init_pointers(void) MAKEFUNC(SHSetWindowBits, 165); MAKEFUNC(SHSetParentHwnd, 167); MAKEFUNC(ConnectToConnectionPoint, 168); + MAKEFUNC(IUnknown_GetClassID, 175); MAKEFUNC(SHSearchMapInt, 198); MAKEFUNC(SHCreateWorkerWindowA, 257); MAKEFUNC(GUIDFromStringA, 269); @@ -3158,6 +3160,95 @@ static void test_SHSetParentHwnd(void) DestroyWindow(hwnd2); } +static HRESULT WINAPI testpersist_QI(IPersist *iface, REFIID riid, void **obj) +{ + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPersist)) { + *obj = iface; + IPersist_AddRef(iface); + return S_OK; + } + + *obj = NULL; + return E_NOINTERFACE; +} + +static HRESULT WINAPI testpersist_QI2(IPersist *iface, REFIID riid, void **obj) +{ + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPersistFolder)) { + *obj = iface; + IPersist_AddRef(iface); + return S_OK; + } + + *obj = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI testpersist_AddRef(IPersist *iface) +{ + return 2; +} + +static ULONG WINAPI testpersist_Release(IPersist *iface) +{ + return 1; +} + +static HRESULT WINAPI testpersist_GetClassID(IPersist *iface, CLSID *clsid) +{ + memset(clsid, 0xab, sizeof(*clsid)); + return 0x8fff2222; +} + +static IPersistVtbl testpersistvtbl = { + testpersist_QI, + testpersist_AddRef, + testpersist_Release, + testpersist_GetClassID +}; + +static IPersistVtbl testpersist2vtbl = { + testpersist_QI2, + testpersist_AddRef, + testpersist_Release, + testpersist_GetClassID +}; + +static IPersist testpersist = { &testpersistvtbl }; +static IPersist testpersist2 = { &testpersist2vtbl }; + +static void test_IUnknown_GetClassID(void) +{ + CLSID clsid, clsid2, clsid3; + HRESULT hr; + +if (0) /* crashes on native systems */ + hr = pIUnknown_GetClassID(NULL, NULL); + + memset(&clsid, 0xcc, sizeof(clsid)); + memset(&clsid3, 0xcc, sizeof(clsid3)); + hr = pIUnknown_GetClassID(NULL, &clsid); + ok(hr == E_FAIL, "got 0x%08x\n", hr); + ok(IsEqualCLSID(&clsid, &CLSID_NULL) || broken(IsEqualCLSID(&clsid, &clsid3)) /* win2k, winxp, win2k3 */, + "got wrong clsid %s\n", wine_dbgstr_guid(&clsid)); + + memset(&clsid, 0xcc, sizeof(clsid)); + memset(&clsid2, 0xab, sizeof(clsid2)); + hr = pIUnknown_GetClassID((IUnknown*)&testpersist, &clsid); + ok(hr == 0x8fff2222, "got 0x%08x\n", hr); + ok(IsEqualCLSID(&clsid, &clsid2) || broken(IsEqualCLSID(&clsid, &clsid3)) /* win2k3 */, + "got wrong clsid %s\n", wine_dbgstr_guid(&clsid)); + + /* IPersistFolder is also supported */ + memset(&clsid, 0xcc, sizeof(clsid)); + memset(&clsid2, 0xab, sizeof(clsid2)); + memset(&clsid3, 0xcc, sizeof(clsid3)); + hr = pIUnknown_GetClassID((IUnknown*)&testpersist2, &clsid); + ok(hr == 0x8fff2222, "got 0x%08x\n", hr); + ok(IsEqualCLSID(&clsid, &clsid2) || broken(IsEqualCLSID(&clsid, &clsid3)) /* win2k3 */, + "got wrong clsid %s\n", wine_dbgstr_guid(&clsid)); +} + START_TEST(ordinal) { char **argv; @@ -3212,6 +3303,7 @@ START_TEST(ordinal) test_SHSetIniString(); test_SHGetShellKey(); test_SHSetParentHwnd(); + test_IUnknown_GetClassID(); FreeLibrary(hshell32); FreeLibrary(hmlang); diff --git a/rostests/winetests/shlwapi/path.c b/rostests/winetests/shlwapi/path.c index a8c229c6df7..9483350e50a 100755 --- a/rostests/winetests/shlwapi/path.c +++ b/rostests/winetests/shlwapi/path.c @@ -188,13 +188,18 @@ static const struct { /* ################ */ -static LPWSTR GetWideString(const char* szString) +static LPWSTR GetWideString(const char *src) { - LPWSTR wszString = HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR)); - - MultiByteToWideChar(CP_ACP, 0, szString, -1, wszString, INTERNET_MAX_URL_LENGTH); + WCHAR *ret; - return wszString; + if (!src) + return NULL; + + ret = HeapAlloc(GetProcessHeap(), 0, (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR)); + + MultiByteToWideChar(CP_ACP, 0, src, -1, ret, INTERNET_MAX_URL_LENGTH); + + return ret; } static void FreeWideString(LPWSTR wszString) diff --git a/rostests/winetests/shlwapi/url.c b/rostests/winetests/shlwapi/url.c index 5d34d5f9abc..18fc820978a 100644 --- a/rostests/winetests/shlwapi/url.c +++ b/rostests/winetests/shlwapi/url.c @@ -1150,7 +1150,7 @@ static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFla if (todo) { - todo_wine ok(dwSize == dwExpectLen && (!SUCCEEDED(hr) || strcmp(szReturnUrl, szExpectUrl)==0), + todo_wine ok(dwSize == dwExpectLen && (FAILED(hr) || strcmp(szReturnUrl, szExpectUrl)==0), "Expected %s (len=%d), but got %s (len=%d)\n", szExpectUrl, dwExpectLen, SUCCEEDED(hr) ? szReturnUrl : "(null)", dwSize); } else