[SHELL32_APITEST] -Add some tests for SHParseDisplayName for CORE-12882.
[reactos.git] / rostests / apitests / apphelp / apphelp.c
index d17afdc..6bfd978 100644 (file)
@@ -33,6 +33,8 @@
 #include <winerror.h>
 #include <stdio.h>
 #include <initguid.h>
+#include <shlguid.h>
+#include <shobjidl.h>
 
 #include "wine/test.h"
 
@@ -101,6 +103,7 @@ typedef struct tagATTRINFO {
 } ATTRINFO, *PATTRINFO;
 
 static HMODULE hdll;
+static BOOL (WINAPI *pApphelpCheckShellObject)(REFCLSID, BOOL, ULONGLONG *);
 static LPCWSTR (WINAPI *pSdbTagToString)(TAG);
 static BOOL (WINAPI *pSdbGUIDToString)(CONST GUID *, PCWSTR, SIZE_T);
 static BOOL (WINAPI *pSdbIsNullGUID)(CONST GUID *);
@@ -114,7 +117,65 @@ DEFINE_GUID(GUID_DATABASE_SHIM,0x11111111,0x1111,0x1111,0x11,0x11,0x11,0x11,0x11
 DEFINE_GUID(GUID_DATABASE_DRIVERS,0xf9ab2228,0x3312,0x4a73,0xb6,0xf9,0x93,0x6d,0x70,0xe1,0x12,0xef);
 
 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
+
+DEFINE_GUID(test_Microsoft_Browser_Architecture, 0xa5e46e3a, 0x8849, 0x11d1, 0x9d, 0x8c, 0x00, 0xc0, 0x4f, 0xc9, 0x9d, 0x61);
 DEFINE_GUID(test_UserAssist, 0xdd313e04, 0xfeff, 0x11d1, 0x8e, 0xcd, 0x00, 0x00, 0xf8, 0x7a, 0x47, 0x0c);
+DEFINE_GUID(CLSID_InternetSecurityManager, 0x7b8a2d94, 0x0ac9, 0x11d1, 0x89, 0x6c, 0x00, 0xc0, 0x4f, 0xB6, 0xbf, 0xc4);
+
+static const CLSID * objects[] = {
+    &GUID_NULL,
+    /* used by IE */
+    &test_Microsoft_Browser_Architecture,
+    &CLSID_MenuBand,
+    &CLSID_ShellLink,
+    &CLSID_ShellWindows,
+    &CLSID_InternetSecurityManager,
+    &test_UserAssist,
+    (const CLSID *)NULL
+};
+
+static void test_ApphelpCheckShellObject(void)
+{
+    ULONGLONG flags;
+    BOOL res;
+    int i;
+
+    if (!pApphelpCheckShellObject)
+    {
+        win_skip("ApphelpCheckShellObject not available\n");
+        return;
+    }
+
+    for (i = 0; objects[i]; i++)
+    {
+        flags = 0xdeadbeef;
+        SetLastError(0xdeadbeef);
+        res = pApphelpCheckShellObject(objects[i], FALSE, &flags);
+        ok(res && (flags == 0), "%s 0: got %d and 0x%x%08x with 0x%x (expected TRUE and 0)\n",
+            wine_dbgstr_guid(objects[i]), res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
+
+        flags = 0xdeadbeef;
+        SetLastError(0xdeadbeef);
+        res = pApphelpCheckShellObject(objects[i], TRUE, &flags);
+        ok(res && (flags == 0), "%s 1: got %d and 0x%x%08x with 0x%x (expected TRUE and 0)\n",
+            wine_dbgstr_guid(objects[i]), res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
+
+    }
+
+    /* NULL as pointer to flags is checked */
+    SetLastError(0xdeadbeef);
+    res = pApphelpCheckShellObject(&GUID_NULL, FALSE, NULL);
+    ok(res, "%s 0: got %d with 0x%x (expected != FALSE)\n", wine_dbgstr_guid(&GUID_NULL), res, GetLastError());
+
+    /* NULL as CLSID* crash on Windows */
+    if (0)
+    {
+        flags = 0xdeadbeef;
+        SetLastError(0xdeadbeef);
+        res = pApphelpCheckShellObject(NULL, FALSE, &flags);
+        trace("NULL as CLSID*: got %d and 0x%x%08x with 0x%x\n", res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
+    }
+}
 
 static void test_SdbTagToString(void)
 {
@@ -834,6 +895,8 @@ START_TEST(apphelp)
     //SetEnvironmentVariable("SHIM_DEBUG_LEVEL", "4");
     //SetEnvironmentVariable("DEBUGCHANNEL", "+apphelp");
     hdll = LoadLibraryA("apphelp.dll");
+
+    pApphelpCheckShellObject = (void *) GetProcAddress(hdll, "ApphelpCheckShellObject");
     pSdbTagToString = (void *) GetProcAddress(hdll, "SdbTagToString");
     pSdbGUIDToString = (void *) GetProcAddress(hdll, "SdbGUIDToString");
     pSdbIsNullGUID = (void *) GetProcAddress(hdll, "SdbIsNullGUID");
@@ -841,6 +904,7 @@ START_TEST(apphelp)
     pSdbGetFileAttributes = (void *) GetProcAddress(hdll, "SdbGetFileAttributes");
     pSdbFreeFileAttributes = (void *) GetProcAddress(hdll, "SdbFreeFileAttributes");
 
+    test_ApphelpCheckShellObject();
     test_GuidFunctions();
     test_ApplicationAttributes();
     test_SdbTagToString();