winegstreamer: return the IMemAllocator so the BaseOutputPin can store it and use...
[wine] / dlls / apphelp / tests / apphelp.c
1 /*
2  * Copyright 2012 Detlef Riekenberg
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #define COBJMACROS
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <initguid.h>
24 #include <exdisp.h>
25 #include <shlobj.h>
26 #include <urlmon.h>
27
28 #include "wine/test.h"
29
30 static HMODULE hdll;
31 static BOOL (WINAPI *pApphelpCheckShellObject)(REFCLSID, BOOL, ULONGLONG *);
32
33 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
34
35 DEFINE_GUID(test_Microsoft_Browser_Architecture, 0xa5e46e3a, 0x8849, 0x11d1, 0x9d, 0x8c, 0x00, 0xc0, 0x4f, 0xc9, 0x9d, 0x61);
36 DEFINE_GUID(CLSID_MenuBand, 0x5b4dae26, 0xb807, 0x11d0, 0x98, 0x15, 0x00, 0xc0, 0x4f, 0xd9, 0x19, 0x72);
37 DEFINE_GUID(test_UserAssist, 0xdd313e04, 0xfeff, 0x11d1, 0x8e, 0xcd, 0x00, 0x00, 0xf8, 0x7a, 0x47, 0x0c);
38
39 static const CLSID * objects[] = {
40     &GUID_NULL,
41     /* used by IE */
42     &test_Microsoft_Browser_Architecture,
43     &CLSID_MenuBand,
44     &CLSID_ShellLink,
45     &CLSID_ShellWindows,
46     &CLSID_InternetSecurityManager,
47     &test_UserAssist,
48     NULL,};
49
50 static const char *debugstr_guid(REFIID riid)
51 {
52     static char buf[50];
53
54     sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
55             riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
56             riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
57             riid->Data4[5], riid->Data4[6], riid->Data4[7]);
58
59     return buf;
60 }
61
62 static void test_ApphelpCheckShellObject(void)
63 {
64     ULONGLONG flags;
65     BOOL res;
66     int i;
67
68     if (!pApphelpCheckShellObject)
69     {
70         win_skip("ApphelpCheckShellObject not available\n");
71         return;
72     }
73
74     for (i = 0; objects[i]; i++)
75     {
76         flags = 0xdeadbeef;
77         SetLastError(0xdeadbeef);
78         res = pApphelpCheckShellObject(objects[i], FALSE, &flags);
79         ok(res && (flags == 0), "%s 0: got %d and 0x%x%08x with 0x%x (expected TRUE and 0)\n",
80             debugstr_guid(objects[i]), res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
81
82         flags = 0xdeadbeef;
83         SetLastError(0xdeadbeef);
84         res = pApphelpCheckShellObject(objects[i], TRUE, &flags);
85         ok(res && (flags == 0), "%s 1: got %d and 0x%x%08x with 0x%x (expected TRUE and 0)\n",
86             debugstr_guid(objects[i]), res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
87
88     }
89
90     /* NULL as pointer to flags is checked */
91     SetLastError(0xdeadbeef);
92     res = pApphelpCheckShellObject(&GUID_NULL, FALSE, NULL);
93     ok(res, "%s 0: got %d with 0x%x (expected != FALSE)\n", debugstr_guid(&GUID_NULL), res, GetLastError());
94
95     /* NULL as CLSID* crash on Windows */
96     if (0)
97     {
98         flags = 0xdeadbeef;
99         SetLastError(0xdeadbeef);
100         res = pApphelpCheckShellObject(NULL, FALSE, &flags);
101         trace("NULL as CLSID*: got %d and 0x%x%08x with 0x%x\n", res, (ULONG)(flags >> 32), (ULONG)flags, GetLastError());
102     }
103 }
104
105 START_TEST(apphelp)
106 {
107
108     hdll = LoadLibrary("apphelp.dll");
109     if (!hdll) {
110         win_skip("apphelp.dll not available\n");
111         return;
112     }
113     pApphelpCheckShellObject = (void *) GetProcAddress(hdll, "ApphelpCheckShellObject");
114
115     test_ApphelpCheckShellObject();
116 }