[SHLWAPI_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 5 Mar 2016 10:21:38 +0000 (10:21 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 5 Mar 2016 10:21:38 +0000 (10:21 +0000)
svn path=/trunk/; revision=70933

rostests/winetests/shlwapi/ordinal.c
rostests/winetests/shlwapi/url.c

index c045cc7..8b516aa 100755 (executable)
@@ -76,6 +76,24 @@ 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 HRESULT (WINAPI *pSKAllocValueW)(DWORD, LPCWSTR, LPCWSTR, DWORD*, void**, DWORD*);
 static HWND    (WINAPI *pSHSetParentHwnd)(HWND, HWND);
 static HRESULT (WINAPI *pIUnknown_GetClassID)(IUnknown*, CLSID*);
+static HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO2*);
+
+typedef struct SHELL_USER_SID {
+    SID_IDENTIFIER_AUTHORITY sidAuthority;
+    DWORD                    dwUserGroupID;
+    DWORD                    dwUserID;
+} SHELL_USER_SID, *PSHELL_USER_SID;
+typedef struct SHELL_USER_PERMISSION {
+
+    SHELL_USER_SID susID;
+    DWORD          dwAccessType;
+    BOOL           fInherit;
+    DWORD          dwAccessMask;
+    DWORD          dwInheritMask;
+    DWORD          dwInheritAccessMask;
+} SHELL_USER_PERMISSION, *PSHELL_USER_PERMISSION;
+
+static SECURITY_DESCRIPTOR* (WINAPI *pGetShellSecurityDescriptor)(const SHELL_USER_PERMISSION**,int);
 
 static HMODULE hmlang;
 static HRESULT (WINAPI *pLcidToRfc1766A)(LCID, LPSTR, INT);
 
 static HMODULE hmlang;
 static HRESULT (WINAPI *pLcidToRfc1766A)(LCID, LPSTR, INT);
@@ -522,6 +540,11 @@ static void test_alloc_shared(int argc, char **argv)
         ret = pSHFreeShared(hmem2, procid);
         ok(ret, "SHFreeShared failed: %u\n", GetLastError());
     }
         ret = pSHFreeShared(hmem2, procid);
         ok(ret, "SHFreeShared failed: %u\n", GetLastError());
     }
+
+    SetLastError(0xdeadbeef);
+    ret = pSHFreeShared(NULL, procid);
+    ok(ret, "SHFreeShared failed: %u\n", GetLastError());
+    ok(GetLastError() == 0xdeadbeef, "last error should not have changed, got %u\n", GetLastError());
 }
 
 static void test_alloc_shared_remote(DWORD procid, HANDLE hmem)
 }
 
 static void test_alloc_shared_remote(DWORD procid, HANDLE hmem)
@@ -551,6 +574,11 @@ static void test_alloc_shared_remote(DWORD procid, HANDLE hmem)
     ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
 
     /* test SHMapHandle */
     ok(ret, "SHUnlockShared failed: %u\n", GetLastError());
 
     /* test SHMapHandle */
+    SetLastError(0xdeadbeef);
+    hmem2 = pSHMapHandle(NULL, procid, GetCurrentProcessId(), 0, 0);
+    ok(hmem2 == NULL, "expected NULL, got new handle\n");
+    ok(GetLastError() == 0xdeadbeef, "last error should not have changed, got %u\n", GetLastError());
+
     hmem2 = pSHMapHandle(hmem, procid, GetCurrentProcessId(), 0, 0);
 
     /* It seems like Windows Vista/2008 uses a different internal implementation
     hmem2 = pSHMapHandle(hmem, procid, GetCurrentProcessId(), 0, 0);
 
     /* It seems like Windows Vista/2008 uses a different internal implementation
@@ -676,40 +704,23 @@ static void test_fdsa(void)
     HeapFree(GetProcessHeap(), 0, mem);
 }
 
     HeapFree(GetProcessHeap(), 0, mem);
 }
 
-
-typedef struct SHELL_USER_SID {
-    SID_IDENTIFIER_AUTHORITY sidAuthority;
-    DWORD                    dwUserGroupID;
-    DWORD                    dwUserID;
-} SHELL_USER_SID, *PSHELL_USER_SID;
-typedef struct SHELL_USER_PERMISSION {
-    SHELL_USER_SID susID;
-    DWORD          dwAccessType;
-    BOOL           fInherit;
-    DWORD          dwAccessMask;
-    DWORD          dwInheritMask;
-    DWORD          dwInheritAccessMask;
-} SHELL_USER_PERMISSION, *PSHELL_USER_PERMISSION;
 static void test_GetShellSecurityDescriptor(void)
 {
 static void test_GetShellSecurityDescriptor(void)
 {
-    SHELL_USER_PERMISSION supCurrentUserFull = {
+    static const SHELL_USER_PERMISSION supCurrentUserFull = {
         { {SECURITY_NULL_SID_AUTHORITY}, 0, 0 },
         ACCESS_ALLOWED_ACE_TYPE, FALSE,
         GENERIC_ALL, 0, 0 };
 #define MY_INHERITANCE 0xBE /* invalid value to proof behavior */
         { {SECURITY_NULL_SID_AUTHORITY}, 0, 0 },
         ACCESS_ALLOWED_ACE_TYPE, FALSE,
         GENERIC_ALL, 0, 0 };
 #define MY_INHERITANCE 0xBE /* invalid value to proof behavior */
-    SHELL_USER_PERMISSION supEveryoneDenied = {
+    static const SHELL_USER_PERMISSION supEveryoneDenied = {
         { {SECURITY_WORLD_SID_AUTHORITY}, SECURITY_WORLD_RID, 0 },
         ACCESS_DENIED_ACE_TYPE, TRUE,
         GENERIC_WRITE, MY_INHERITANCE | 0xDEADBA00, GENERIC_READ };
         { {SECURITY_WORLD_SID_AUTHORITY}, SECURITY_WORLD_RID, 0 },
         ACCESS_DENIED_ACE_TYPE, TRUE,
         GENERIC_WRITE, MY_INHERITANCE | 0xDEADBA00, GENERIC_READ };
-    PSHELL_USER_PERMISSION rgsup[2] = {
+    const SHELL_USER_PERMISSION* rgsup[2] = {
         &supCurrentUserFull, &supEveryoneDenied,
     };
     SECURITY_DESCRIPTOR* psd;
         &supCurrentUserFull, &supEveryoneDenied,
     };
     SECURITY_DESCRIPTOR* psd;
-    SECURITY_DESCRIPTOR* (WINAPI*pGetShellSecurityDescriptor)(PSHELL_USER_PERMISSION*,int);
     void *pChrCmpIW = GetProcAddress(hShlwapi, "ChrCmpIW");
 
     void *pChrCmpIW = GetProcAddress(hShlwapi, "ChrCmpIW");
 
-    pGetShellSecurityDescriptor=(void*)GetProcAddress(hShlwapi,(char*)475);
-
     if(!pGetShellSecurityDescriptor)
     {
         win_skip("GetShellSecurityDescriptor not available\n");
     if(!pGetShellSecurityDescriptor)
     {
         win_skip("GetShellSecurityDescriptor not available\n");
@@ -3072,6 +3083,7 @@ static void init_pointers(void)
     MAKEFUNC(SHFormatDateTimeA, 353);
     MAKEFUNC(SHFormatDateTimeW, 354);
     MAKEFUNC(SHIShellFolder_EnumObjects, 404);
     MAKEFUNC(SHFormatDateTimeA, 353);
     MAKEFUNC(SHFormatDateTimeW, 354);
     MAKEFUNC(SHIShellFolder_EnumObjects, 404);
+    MAKEFUNC(GetShellSecurityDescriptor, 475);
     MAKEFUNC(SHGetObjectCompatFlags, 476);
     MAKEFUNC(IUnknown_QueryServiceExec, 484);
     MAKEFUNC(SHGetShellKey, 491);
     MAKEFUNC(SHGetObjectCompatFlags, 476);
     MAKEFUNC(IUnknown_QueryServiceExec, 484);
     MAKEFUNC(SHGetShellKey, 491);
@@ -3082,6 +3094,8 @@ static void init_pointers(void)
     MAKEFUNC(SKDeleteValueW, 518);
     MAKEFUNC(SKAllocValueW, 519);
 #undef MAKEFUNC
     MAKEFUNC(SKDeleteValueW, 518);
     MAKEFUNC(SKAllocValueW, 519);
 #undef MAKEFUNC
+
+    pDllGetVersion = (void*)GetProcAddress(hShlwapi, "DllGetVersion");
 }
 
 static void test_SHSetParentHwnd(void)
 }
 
 static void test_SHSetParentHwnd(void)
@@ -3255,6 +3269,14 @@ if (0) /* crashes on native systems */
         "got wrong clsid %s\n", wine_dbgstr_guid(&clsid));
 }
 
         "got wrong clsid %s\n", wine_dbgstr_guid(&clsid));
 }
 
+static void test_DllGetVersion(void)
+{
+    HRESULT hr;
+
+    hr = pDllGetVersion(NULL);
+    ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+}
+
 START_TEST(ordinal)
 {
     char **argv;
 START_TEST(ordinal)
 {
     char **argv;
@@ -3310,6 +3332,7 @@ START_TEST(ordinal)
     test_SHGetShellKey();
     test_SHSetParentHwnd();
     test_IUnknown_GetClassID();
     test_SHGetShellKey();
     test_SHSetParentHwnd();
     test_IUnknown_GetClassID();
+    test_DllGetVersion();
 
     FreeLibrary(hshell32);
     FreeLibrary(hmlang);
 
     FreeLibrary(hshell32);
     FreeLibrary(hmlang);
index 18fc820..354d9c8 100644 (file)
@@ -315,6 +315,45 @@ static const TEST_URL_ESCAPE TEST_ESCAPE[] = {
     {"ftp\x1f\1end/", 0, 0, S_OK, "ftp%1F%01end/"}
 };
 
     {"ftp\x1f\1end/", 0, 0, S_OK, "ftp%1F%01end/"}
 };
 
+typedef struct _TEST_URL_ESCAPEW {
+    const WCHAR url[INTERNET_MAX_URL_LENGTH];
+    DWORD flags;
+    HRESULT expectret;
+    const WCHAR expecturl[INTERNET_MAX_URL_LENGTH];
+    const WCHAR win7url[INTERNET_MAX_URL_LENGTH];  /* <= Win7 */
+    const WCHAR vistaurl[INTERNET_MAX_URL_LENGTH]; /* <= Vista/2k8 */
+} TEST_URL_ESCAPEW;
+
+static const TEST_URL_ESCAPEW TEST_ESCAPEW[] = {
+    {{' ','<','>','"',0},  URL_ESCAPE_AS_UTF8, S_OK, {'%','2','0','%','3','C','%','3','E','%','2','2',0}},
+    {{'{','}','|','\\',0}, URL_ESCAPE_AS_UTF8, S_OK, {'%','7','B','%','7','D','%','7','C','%','5','C',0}},
+    {{'^',']','[','`',0},  URL_ESCAPE_AS_UTF8, S_OK, {'%','5','E','%','5','D','%','5','B','%','6','0',0}},
+    {{'&','/','?','#',0},  URL_ESCAPE_AS_UTF8, S_OK, {'%','2','6','/','?','#',0}},
+    {{'M','a','s','s',0},  URL_ESCAPE_AS_UTF8, S_OK, {'M','a','s','s',0}},
+
+    /* broken < Win8/10 */
+
+    {{'M','a',0xdf,0},  URL_ESCAPE_AS_UTF8, S_OK, {'M','a','%','C','3','%','9','F',0},
+                                                  {'M','a','%','D','F',0}},
+    /* 0x2070E */
+    {{0xd841,0xdf0e,0}, URL_ESCAPE_AS_UTF8, S_OK, {'%','F','0','%','A','0','%','9','C','%','8','E',0},
+                                                  {'%','E','F','%','B','F','%','B','D','%','E','F','%','B','F','%','B','D',0},
+                                                  {0xd841,0xdf0e,0}},
+    /* 0x27A3E */
+    {{0xd85e,0xde3e,0}, URL_ESCAPE_AS_UTF8, S_OK, {'%','F','0','%','A','7','%','A','8','%','B','E',0},
+                                                  {'%','E','F','%','B','F','%','B','D','%','E','F','%','B','F','%','B','D',0},
+                                                  {0xd85e,0xde3e,0}},
+
+    {{0xd85e,0},        URL_ESCAPE_AS_UTF8, S_OK, {'%','E','F','%','B','F','%','B','D',0},
+                                                  {0xd85e,0}},
+    {{0xd85e,0x41},     URL_ESCAPE_AS_UTF8, S_OK, {'%','E','F','%','B','F','%','B','D','A',0},
+                                                  {0xd85e,'A',0}},
+    {{0xdc00,0},        URL_ESCAPE_AS_UTF8, S_OK, {'%','E','F','%','B','F','%','B','D',0},
+                                                  {0xdc00,0}},
+    {{0xffff,0},        URL_ESCAPE_AS_UTF8, S_OK, {'%','E','F','%','B','F','%','B','F',0},
+                                                  {0xffff,0}},
+};
+
 /* ################ */
 
 typedef struct _TEST_URL_COMBINE {
 /* ################ */
 
 typedef struct _TEST_URL_COMBINE {
@@ -885,6 +924,15 @@ static void test_UrlEscapeA(void)
     ok(size == 34, "got %d, expected %d\n", size, 34);
     ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
 
     ok(size == 34, "got %d, expected %d\n", size, 34);
     ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
 
+    size = 1;
+    empty_string[0] = 127;
+    ret = pUrlEscapeA("/woningplan/woonkamer basis.swf", empty_string, &size, URL_ESCAPE_AS_UTF8);
+    ok(ret == E_NOTIMPL || broken(ret == E_POINTER), /* < Win7/Win2k8 */
+        "got %x, expected %x\n", ret, E_NOTIMPL);
+    ok(size == 1 || broken(size == 34), /* < Win7/Win2k8 */
+        "got %d, expected %d\n", size, 1);
+    ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
+
     for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
         CHAR ret_url[INTERNET_MAX_URL_LENGTH];
 
     for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
         CHAR ret_url[INTERNET_MAX_URL_LENGTH];
 
@@ -948,6 +996,21 @@ static void test_UrlEscapeW(void)
         FreeWideString(urlW);
         FreeWideString(expected_urlW);
     }
         FreeWideString(urlW);
         FreeWideString(expected_urlW);
     }
+
+    for(i=0; i<sizeof(TEST_ESCAPEW)/sizeof(TEST_ESCAPEW[0]); i++) {
+        WCHAR ret_url[INTERNET_MAX_URL_LENGTH];
+
+        size = INTERNET_MAX_URL_LENGTH;
+        ret = pUrlEscapeW(TEST_ESCAPEW[i].url, ret_url, &size, TEST_ESCAPEW[i].flags);
+        ok(ret == TEST_ESCAPEW[i].expectret, "UrlEscapeW returned 0x%08x instead of 0x%08x for \"%s\"\n",
+           ret, TEST_ESCAPEW[i].expectret, wine_dbgstr_w(TEST_ESCAPEW[i].url));
+        ok(!lstrcmpW(ret_url, TEST_ESCAPEW[i].expecturl) ||
+           broken(!lstrcmpW(ret_url, TEST_ESCAPEW[i].vistaurl)) ||
+           broken(!lstrcmpW(ret_url, TEST_ESCAPEW[i].win7url)),
+            "Expected \"%s\" or \"%s\" or \"%s\", but got \"%s\" for \"%s\"\n",
+            wine_dbgstr_w(TEST_ESCAPEW[i].expecturl), wine_dbgstr_w(TEST_ESCAPEW[i].vistaurl),
+            wine_dbgstr_w(TEST_ESCAPEW[i].win7url), wine_dbgstr_w(ret_url), wine_dbgstr_w(TEST_ESCAPEW[i].url));
+    }
 }
 
 /* ########################### */
 }
 
 /* ########################### */