atl100/tests: Fix leaked memory during test_AtlAxAttachControl.
[wine.git] / dlls / atl100 / tests / atl.c
blobeecf07934fe5c6d5518a276108a7819da5248460
1 /*
2 * Copyright 2012 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
23 #define CONST_VTABLE
25 #include <windef.h>
26 #include <winbase.h>
27 #include <winuser.h>
28 #include <exdisp.h>
30 #include <atlbase.h>
31 #include <mshtml.h>
33 #include <wine/test.h>
35 static const GUID CLSID_Test =
36 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
37 #define CLSID_TEST_STR "178fc163-0000-0000-0000-000000000046"
39 static const GUID CATID_CatTest1 =
40 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x46}};
41 #define CATID_CATTEST1_STR "178fc163-0000-0000-0000-000000000146"
43 static const GUID CATID_CatTest2 =
44 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x46}};
45 #define CATID_CATTEST2_STR "178fc163-0000-0000-0000-000000000246"
47 static const WCHAR emptyW[] = {'\0'};
48 static const WCHAR randomW[] = {'r','a','n','d','o','m','\0'};
49 static const WCHAR progid1W[] = {'S','h','e','l','l','.','E','x','p','l','o','r','e','r','.','2','\0'};
50 static const WCHAR clsid1W[] = {'{','8','8','5','6','f','9','6','1','-','3','4','0','a','-',
51 '1','1','d','0','-','a','9','6','b','-',
52 '0','0','c','0','4','f','d','7','0','5','a','2','}','\0'};
53 static const WCHAR url1W[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q',
54 '.','o','r','g','/','t','e','s','t','s','/','w','i','n','e','h','q','_',
55 's','n','a','p','s','h','o','t','/','\0'};
56 static const WCHAR mshtml1W[] = {'m','s','h','t','m','l',':','<','h','t','m','l','>','<','b','o','d','y','>',
57 't','e','s','t','<','/','b','o','d','y','>','<','/','h','t','m','l','>','\0'};
58 static const WCHAR mshtml2W[] = {'M','S','H','T','M','L',':','<','h','t','m','l','>','<','b','o','d','y','>',
59 't','e','s','t','<','/','b','o','d','y','>','<','/','h','t','m','l','>','\0'};
60 static const WCHAR mshtml3W[] = {'<','h','t','m','l','>','<','b','o','d','y','>', 't','e','s','t',
61 '<','/','b','o','d','y','>','<','/','h','t','m','l','>','\0'};
62 static const WCHAR fileW[] = {'f','i','l','e',':','/','/','/','\0'};
63 static const WCHAR html_fileW[] = {'t','e','s','t','.','h','t','m','l','\0'};
64 static const char html_str[] = "<html><body>test</body><html>";
66 static BOOL is_token_admin(HANDLE token)
68 PSID administrators = NULL;
69 SID_IDENTIFIER_AUTHORITY nt_authority = { SECURITY_NT_AUTHORITY };
70 DWORD groups_size;
71 PTOKEN_GROUPS groups;
72 DWORD group_index;
74 /* Create a well-known SID for the Administrators group. */
75 if (! AllocateAndInitializeSid(&nt_authority, 2, SECURITY_BUILTIN_DOMAIN_RID,
76 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
77 &administrators))
78 return FALSE;
80 /* Get the group info from the token */
81 groups_size = 0;
82 GetTokenInformation(token, TokenGroups, NULL, 0, &groups_size);
83 groups = HeapAlloc(GetProcessHeap(), 0, groups_size);
84 if (groups == NULL)
86 FreeSid(administrators);
87 return FALSE;
89 if (! GetTokenInformation(token, TokenGroups, groups, groups_size, &groups_size))
91 HeapFree(GetProcessHeap(), 0, groups);
92 FreeSid(administrators);
93 return FALSE;
96 /* Now check if the token groups include the Administrators group */
97 for (group_index = 0; group_index < groups->GroupCount; group_index++)
99 if (EqualSid(groups->Groups[group_index].Sid, administrators))
101 HeapFree(GetProcessHeap(), 0, groups);
102 FreeSid(administrators);
103 return TRUE;
107 /* If we end up here we didn't find the Administrators group */
108 HeapFree(GetProcessHeap(), 0, groups);
109 FreeSid(administrators);
110 return FALSE;
113 static BOOL is_process_limited(void)
115 static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, PHANDLE) = NULL;
116 HANDLE token;
117 BOOL result=FALSE;
119 if (!pOpenProcessToken)
121 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
122 pOpenProcessToken = (void*)GetProcAddress(hadvapi32, "OpenProcessToken");
123 if (!pOpenProcessToken)
124 return FALSE;
127 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
129 BOOL ret;
130 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
131 DWORD size;
133 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
134 if (ret)
136 if (type == TokenElevationTypeDefault)
137 /* UAC is disabled, check for administrators group */
138 result = !is_token_admin(token);
139 else if (type == TokenElevationTypeFull)
140 result = FALSE;
141 else if (type == TokenElevationTypeLimited)
142 result = TRUE;
144 CloseHandle(token);
146 return result;
149 static void test_winmodule(void)
151 _AtlCreateWndData create_data[3];
152 _ATL_WIN_MODULE winmod;
153 void *p;
154 HRESULT hres;
156 winmod.cbSize = 0xdeadbeef;
157 hres = AtlWinModuleInit(&winmod);
158 ok(hres == E_INVALIDARG, "AtlWinModuleInit failed: %08x\n", hres);
160 winmod.cbSize = sizeof(winmod);
161 winmod.m_pCreateWndList = (void*)0xdeadbeef;
162 winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
163 winmod.m_rgWindowClassAtoms.m_aT = (void*)0xdeadbeef;
164 winmod.m_rgWindowClassAtoms.m_nSize = 0xdeadbeef;
165 winmod.m_rgWindowClassAtoms.m_nAllocSize = 0xdeadbeef;
166 hres = AtlWinModuleInit(&winmod);
167 ok(hres == S_OK, "AtlWinModuleInit failed: %08x\n", hres);
168 ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
169 ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %d\n",
170 winmod.m_csWindowCreate.LockCount);
171 ok(winmod.m_rgWindowClassAtoms.m_aT == (void*)0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_aT = %p\n",
172 winmod.m_rgWindowClassAtoms.m_aT);
173 ok(winmod.m_rgWindowClassAtoms.m_nSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nSize = %d\n",
174 winmod.m_rgWindowClassAtoms.m_nSize);
175 ok(winmod.m_rgWindowClassAtoms.m_nAllocSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nAllocSize = %d\n",
176 winmod.m_rgWindowClassAtoms.m_nAllocSize);
178 InitializeCriticalSection(&winmod.m_csWindowCreate);
180 AtlWinModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
181 ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
182 ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
183 ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %x\n",
184 create_data[0].m_dwThreadID);
185 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
187 AtlWinModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
188 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
189 ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
190 ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %x\n",
191 create_data[1].m_dwThreadID);
192 ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
194 AtlWinModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
195 ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
196 ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
197 ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %x\n",
198 create_data[2].m_dwThreadID);
199 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
201 p = AtlWinModuleExtractCreateWndData(&winmod);
202 ok(p == (void*)0xdead0003, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
203 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
204 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
206 create_data[1].m_dwThreadID = 0xdeadbeef;
208 p = AtlWinModuleExtractCreateWndData(&winmod);
209 ok(p == (void*)0xdead0001, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
210 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
211 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
212 ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
214 p = AtlWinModuleExtractCreateWndData(&winmod);
215 ok(!p, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
216 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
219 #define test_key_exists(a,b) _test_key_exists(__LINE__,a,b)
220 static void _test_key_exists(unsigned line, HKEY root, const char *key_name)
222 HKEY key;
223 DWORD res;
225 res = RegOpenKeyA(root, key_name, &key);
226 ok_(__FILE__,line)(res == ERROR_SUCCESS, "Could not open key %s\n", key_name);
227 if(res == ERROR_SUCCESS)
228 RegCloseKey(key);
231 #define test_key_not_exists(a,b) _test_key_not_exists(__LINE__,a,b)
232 static void _test_key_not_exists(unsigned line, HKEY root, const char *key_name)
234 HKEY key;
235 DWORD res;
237 res = RegOpenKeyA(root, key_name, &key);
238 ok_(__FILE__,line)(res == ERROR_FILE_NOT_FOUND, "Attempting to open %s returned %u\n", key_name, res);
239 if(res == ERROR_SUCCESS)
240 RegCloseKey(key);
243 static void test_regcat(void)
245 unsigned char b;
246 HRESULT hres;
248 const struct _ATL_CATMAP_ENTRY catmap[] = {
249 {_ATL_CATMAP_ENTRY_IMPLEMENTED, &CATID_CatTest1},
250 {_ATL_CATMAP_ENTRY_REQUIRED, &CATID_CatTest2},
251 {_ATL_CATMAP_ENTRY_END}
254 if (is_process_limited())
256 skip("process is limited\n");
257 return;
260 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, TRUE);
261 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
263 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
264 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories\\{" CATID_CATTEST1_STR "}");
265 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories\\{" CATID_CATTEST2_STR "}");
267 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, FALSE);
268 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
270 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories");
271 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories");
272 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
274 ok(RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}") == ERROR_SUCCESS, "Could not delete key\n");
276 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, NULL, TRUE);
277 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
279 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
281 b = 10;
282 hres = AtlGetPerUserRegistration(&b);
283 ok(hres == S_OK, "AtlGetPerUserRegistration failed: %08x\n", hres);
284 ok(!b, "AtlGetPerUserRegistration returned %x\n", b);
287 static void test_typelib(void)
289 ITypeLib *typelib;
290 HINSTANCE inst;
291 size_t len;
292 BSTR path;
293 HRESULT hres;
295 static const WCHAR scrrun_dll_suffixW[] = {'\\','s','c','r','r','u','n','.','d','l','l',0};
296 static const WCHAR mshtml_tlb_suffixW[] = {'\\','m','s','h','t','m','l','.','t','l','b',0};
298 inst = LoadLibraryA("scrrun.dll");
299 ok(inst != NULL, "Could not load scrrun.dll\n");
301 typelib = NULL;
302 hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
303 ok(hres == S_OK, "AtlLoadTypeLib failed: %08x\n", hres);
304 FreeLibrary(inst);
306 len = SysStringLen(path);
307 ok(len > sizeof(scrrun_dll_suffixW)/sizeof(WCHAR)
308 && lstrcmpiW(path+len-sizeof(scrrun_dll_suffixW)/sizeof(WCHAR), scrrun_dll_suffixW),
309 "unexpected path %s\n", wine_dbgstr_w(path));
310 SysFreeString(path);
311 ok(typelib != NULL, "typelib == NULL\n");
312 ITypeLib_Release(typelib);
314 inst = LoadLibraryA("mshtml.dll");
315 ok(inst != NULL, "Could not load mshtml.dll\n");
317 typelib = NULL;
318 hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
319 ok(hres == S_OK, "AtlLoadTypeLib failed: %08x\n", hres);
320 FreeLibrary(inst);
322 len = SysStringLen(path);
323 ok(len > sizeof(mshtml_tlb_suffixW)/sizeof(WCHAR)
324 && lstrcmpiW(path+len-sizeof(mshtml_tlb_suffixW)/sizeof(WCHAR), mshtml_tlb_suffixW),
325 "unexpected path %s\n", wine_dbgstr_w(path));
326 SysFreeString(path);
327 ok(typelib != NULL, "typelib == NULL\n");
328 ITypeLib_Release(typelib);
331 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
333 if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
334 *ppv = iface;
335 return S_OK;
338 ok(0, "unexpected call\n");
339 return E_NOINTERFACE;
342 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
344 return 2;
347 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
349 return 1;
352 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
354 ok(0, "unexpected call\n");
355 return E_NOTIMPL;
358 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
359 IConnectionPointContainer **ppCPC)
361 ok(0, "unexpected call\n");
362 return E_NOTIMPL;
365 static int advise_cnt;
367 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
368 DWORD *pdwCookie)
370 ok(pUnkSink == (IUnknown*)0xdead0000, "pUnkSink = %p\n", pUnkSink);
371 *pdwCookie = 0xdeadbeef;
372 advise_cnt++;
373 return S_OK;
376 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
378 ok(dwCookie == 0xdeadbeef, "dwCookie = %x\n", dwCookie);
379 advise_cnt--;
380 return S_OK;
383 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
384 IEnumConnections **ppEnum)
386 ok(0, "unexpected call\n");
387 return E_NOTIMPL;
390 static const IConnectionPointVtbl ConnectionPointVtbl =
392 ConnectionPoint_QueryInterface,
393 ConnectionPoint_AddRef,
394 ConnectionPoint_Release,
395 ConnectionPoint_GetConnectionInterface,
396 ConnectionPoint_GetConnectionPointContainer,
397 ConnectionPoint_Advise,
398 ConnectionPoint_Unadvise,
399 ConnectionPoint_EnumConnections
402 static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
404 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
405 REFIID riid, void **ppv)
407 if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
408 *ppv = iface;
409 return S_OK;
412 ok(0, "unexpected call\n");
413 return E_NOTIMPL;
416 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
418 return 2;
421 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
423 return 1;
426 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
427 IEnumConnectionPoints **ppEnum)
429 ok(0, "unexpected call\n");
430 return E_NOTIMPL;
433 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
434 REFIID riid, IConnectionPoint **ppCP)
436 ok(IsEqualGUID(riid, &CLSID_Test), "unexpected riid\n");
437 *ppCP = &ConnectionPoint;
438 return S_OK;
441 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
442 ConnectionPointContainer_QueryInterface,
443 ConnectionPointContainer_AddRef,
444 ConnectionPointContainer_Release,
445 ConnectionPointContainer_EnumConnectionPoints,
446 ConnectionPointContainer_FindConnectionPoint
449 static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
451 static void test_cp(void)
453 DWORD cookie = 0;
454 HRESULT hres;
456 hres = AtlAdvise(NULL, (IUnknown*)0xdeed0000, &CLSID_Test, &cookie);
457 ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres);
459 hres = AtlUnadvise(NULL, &CLSID_Test, 0xdeadbeef);
460 ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres);
462 hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie);
463 ok(hres == S_OK, "AtlAdvise failed: %08x\n", hres);
464 ok(cookie == 0xdeadbeef, "cookie = %x\n", cookie);
465 ok(advise_cnt == 1, "advise_cnt = %d\n", advise_cnt);
467 hres = AtlUnadvise((IUnknown*)&ConnectionPointContainer, &CLSID_Test, 0xdeadbeef);
468 ok(hres == S_OK, "AtlUnadvise failed: %08x\n", hres);
469 ok(!advise_cnt, "advise_cnt = %d\n", advise_cnt);
472 static CLSID persist_clsid;
474 static HRESULT WINAPI Persist_QueryInterface(IPersist *iface, REFIID riid, void **ppv)
476 ok(0, "unexpected call\n");
477 return E_NOINTERFACE;
480 static ULONG WINAPI Persist_AddRef(IPersist *iface)
482 return 2;
485 static ULONG WINAPI Persist_Release(IPersist *iface)
487 return 1;
490 static HRESULT WINAPI Persist_GetClassID(IPersist *iface, CLSID *pClassID)
492 *pClassID = persist_clsid;
493 return S_OK;
496 static const IPersistVtbl PersistVtbl = {
497 Persist_QueryInterface,
498 Persist_AddRef,
499 Persist_Release,
500 Persist_GetClassID
503 static IPersist Persist = { &PersistVtbl };
505 static HRESULT WINAPI ProvideClassInfo2_QueryInterface(IProvideClassInfo2 *iface, REFIID riid, void **ppv)
507 ok(0, "unexpected call\n");
508 return E_NOINTERFACE;
511 static ULONG WINAPI ProvideClassInfo2_AddRef(IProvideClassInfo2 *iface)
513 return 2;
516 static ULONG WINAPI ProvideClassInfo2_Release(IProvideClassInfo2 *iface)
518 return 1;
521 static HRESULT WINAPI ProvideClassInfo2_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ppTI)
523 ok(0, "unexpected call\n");
524 return E_NOTIMPL;
527 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideClassInfo2 *iface, DWORD dwGuidKind, GUID *pGUID)
529 ok(dwGuidKind == GUIDKIND_DEFAULT_SOURCE_DISP_IID, "unexpected dwGuidKind %x\n", dwGuidKind);
530 *pGUID = DIID_DispHTMLBody;
531 return S_OK;
534 static const IProvideClassInfo2Vtbl ProvideClassInfo2Vtbl = {
535 ProvideClassInfo2_QueryInterface,
536 ProvideClassInfo2_AddRef,
537 ProvideClassInfo2_Release,
538 ProvideClassInfo2_GetClassInfo,
539 ProvideClassInfo2_GetGUID
542 static IProvideClassInfo2 ProvideClassInfo2 = { &ProvideClassInfo2Vtbl };
543 static BOOL support_classinfo2;
545 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
547 *ppv = NULL;
549 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
550 *ppv = iface;
551 return S_OK;
554 if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
555 if(!support_classinfo2)
556 return E_NOINTERFACE;
557 *ppv = &ProvideClassInfo2;
558 return S_OK;
561 if(IsEqualGUID(&IID_IPersist, riid)) {
562 *ppv = &Persist;
563 return S_OK;
566 ok(0, "unexpected riid: %s\n", wine_dbgstr_guid(riid));
567 return E_NOINTERFACE;
570 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
572 return 2;
575 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
577 return 1;
580 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
582 ok(0, "unexpected call\n");
583 return E_NOTIMPL;
586 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
587 ITypeInfo **ppTInfo)
589 ITypeLib *typelib;
590 HRESULT hres;
592 static const WCHAR mshtml_tlbW[] = {'m','s','h','t','m','l','.','t','l','b',0};
594 ok(!iTInfo, "iTInfo = %d\n", iTInfo);
595 ok(!lcid, "lcid = %x\n", lcid);
597 hres = LoadTypeLib(mshtml_tlbW, &typelib);
598 ok(hres == S_OK, "LoadTypeLib failed: %08x\n", hres);
600 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHTMLElement, ppTInfo);
601 ok(hres == S_OK, "GetTypeInfoOfGuid failed: %08x\n", hres);
603 ITypeLib_Release(typelib);
604 return S_OK;
607 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
608 UINT cNames, LCID lcid, DISPID *rgDispId)
610 ok(0, "unexpected call\n");
611 return E_NOTIMPL;
614 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
615 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
616 EXCEPINFO *pExcepInfo, UINT *puArgErr)
618 ok(0, "unexpected call\n");
619 return E_NOTIMPL;
622 static const IDispatchVtbl DispatchVtbl = {
623 Dispatch_QueryInterface,
624 Dispatch_AddRef,
625 Dispatch_Release,
626 Dispatch_GetTypeInfoCount,
627 Dispatch_GetTypeInfo,
628 Dispatch_GetIDsOfNames,
629 Dispatch_Invoke
632 static IDispatch Dispatch = { &DispatchVtbl };
634 static void test_source_iface(void)
636 unsigned short maj_ver, min_ver;
637 IID libid, iid;
638 HRESULT hres;
640 support_classinfo2 = TRUE;
642 maj_ver = min_ver = 0xdead;
643 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
644 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
645 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
646 ok(IsEqualGUID(&iid, &DIID_DispHTMLBody), "iid = %s\n", wine_dbgstr_guid(&iid));
647 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
649 support_classinfo2 = FALSE;
650 persist_clsid = CLSID_HTMLDocument;
652 maj_ver = min_ver = 0xdead;
653 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
654 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
655 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
656 ok(IsEqualGUID(&iid, &DIID_HTMLDocumentEvents), "iid = %s\n", wine_dbgstr_guid(&iid));
657 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
659 persist_clsid = CLSID_HTMLStyle;
661 maj_ver = min_ver = 0xdead;
662 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
663 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
664 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
665 ok(IsEqualGUID(&iid, &IID_NULL), "iid = %s\n", wine_dbgstr_guid(&iid));
666 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
669 static void test_ax_win(void)
671 DWORD ret, ret_size, i;
672 HRESULT res;
673 HWND hwnd;
674 HANDLE hfile;
675 IUnknown *control;
676 WNDPROC wndproc[2] = {NULL, NULL};
677 WCHAR file_uri1W[MAX_PATH], pathW[MAX_PATH];
678 WNDCLASSEXW wcex;
679 static HMODULE hinstance = 0;
680 static const WCHAR cls_names[][16] =
682 {'A','t','l','A','x','W','i','n','1','0','0',0},
683 {'A','t','l','A','x','W','i','n','L','i','c','1','0','0',0}
686 ret = AtlAxWinInit();
687 ok(ret, "AtlAxWinInit failed\n");
689 hinstance = GetModuleHandleA(NULL);
691 for (i = 0; i < 2; i++)
693 memset(&wcex, 0, sizeof(wcex));
694 wcex.cbSize = sizeof(wcex);
695 ret = GetClassInfoExW(hinstance, cls_names[i], &wcex);
696 ok(ret, "%s has not registered\n", wine_dbgstr_w(cls_names[i]));
697 ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
698 wndproc[i] = wcex.lpfnWndProc;
700 hwnd = CreateWindowW(cls_names[i], NULL, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
701 ok(hwnd != NULL, "CreateWindow failed!\n");
702 control = (IUnknown *)0xdeadbeef;
703 res = AtlAxGetControl(hwnd, &control);
704 ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
705 ok(!control, "returned %p\n", control);
706 if (control) IUnknown_Release(control);
707 DestroyWindow(hwnd);
709 hwnd = CreateWindowW(cls_names[i], emptyW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
710 ok(hwnd != NULL, "CreateWindow failed!\n");
711 control = (IUnknown *)0xdeadbeef;
712 res = AtlAxGetControl(hwnd, &control);
713 ok(res == E_FAIL, "Expected E_FAIL, returned %08x\n", res);
714 ok(!control, "returned %p\n", control);
715 if (control) IUnknown_Release(control);
716 DestroyWindow(hwnd);
718 hwnd = CreateWindowW(cls_names[i], randomW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
719 todo_wine ok(!hwnd, "returned %p\n", hwnd);
720 if(hwnd) DestroyWindow(hwnd);
722 hwnd = CreateWindowW(cls_names[i], progid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
723 ok(hwnd != NULL, "CreateWindow failed!\n");
724 control = NULL;
725 res = AtlAxGetControl(hwnd, &control);
726 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
727 ok(control != NULL, "AtlAxGetControl failed!\n");
728 IUnknown_Release(control);
729 DestroyWindow(hwnd);
731 hwnd = CreateWindowW(cls_names[i], clsid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
732 ok(hwnd != NULL, "CreateWindow failed!\n");
733 control = NULL;
734 res = AtlAxGetControl(hwnd, &control);
735 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
736 ok(control != NULL, "AtlAxGetControl failed!\n");
737 IUnknown_Release(control);
738 DestroyWindow(hwnd);
740 hwnd = CreateWindowW(cls_names[i], url1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
741 ok(hwnd != NULL, "CreateWindow failed!\n");
742 control = NULL;
743 res = AtlAxGetControl(hwnd, &control);
744 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
745 ok(control != NULL, "AtlAxGetControl failed!\n");
746 IUnknown_Release(control);
747 DestroyWindow(hwnd);
749 /* test html stream with "MSHTML:" prefix */
750 hwnd = CreateWindowW(cls_names[i], mshtml1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
751 ok(hwnd != NULL, "CreateWindow failed!\n");
752 control = NULL;
753 res = AtlAxGetControl(hwnd, &control);
754 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
755 ok(control != NULL, "AtlAxGetControl failed!\n");
756 IUnknown_Release(control);
757 DestroyWindow(hwnd);
759 hwnd = CreateWindowW(cls_names[i], mshtml2W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
760 ok(hwnd != NULL, "CreateWindow failed!\n");
761 control = NULL;
762 res = AtlAxGetControl(hwnd, &control);
763 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
764 ok(control != NULL, "AtlAxGetControl failed!\n");
765 IUnknown_Release(control);
766 DestroyWindow(hwnd);
768 /* test html stream without "MSHTML:" prefix */
769 hwnd = CreateWindowW(cls_names[i], mshtml3W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
770 todo_wine ok(!hwnd, "returned %p\n", hwnd);
771 if(hwnd) DestroyWindow(hwnd);
773 ret = GetTempPathW(MAX_PATH, pathW);
774 ok(ret, "GetTempPath failed!\n");
775 lstrcatW(pathW, html_fileW);
776 hfile = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
777 ok(hfile != INVALID_HANDLE_VALUE, "failed to create file\n");
778 ret = WriteFile(hfile, html_str, sizeof(html_str), &ret_size, NULL);
779 ok(ret, "WriteFile failed\n");
780 CloseHandle(hfile);
782 /* test C:// scheme */
783 hwnd = CreateWindowW(cls_names[i], pathW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
784 ok(hwnd != NULL, "CreateWindow failed!\n");
785 control = NULL;
786 res = AtlAxGetControl(hwnd, &control);
787 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
788 ok(control != NULL, "AtlAxGetControl failed!\n");
789 IUnknown_Release(control);
790 DestroyWindow(hwnd);
792 /* test file:// scheme */
793 lstrcpyW(file_uri1W, fileW);
794 lstrcatW(file_uri1W, pathW);
795 hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
796 ok(hwnd != NULL, "CreateWindow failed!\n");
797 control = NULL;
798 res = AtlAxGetControl(hwnd, &control);
799 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
800 ok(control != NULL, "AtlAxGetControl failed!\n");
801 IUnknown_Release(control);
802 DestroyWindow(hwnd);
804 /* test file:// scheme on non-existent file */
805 ret = DeleteFileW(pathW);
806 ok(ret, "DeleteFile failed!\n");
807 hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
808 ok(hwnd != NULL, "CreateWindow failed!\n");
809 control = NULL;
810 res = AtlAxGetControl(hwnd, &control);
811 ok(res == S_OK, "AtlAxGetControl failed with res %08x\n", res);
812 ok(control != NULL, "AtlAxGetControl failed!\n");
813 IUnknown_Release(control);
814 DestroyWindow(hwnd);
816 todo_wine ok(wndproc[0] != wndproc[1], "expected different proc!\n");
819 static ATOM register_class(void)
821 WNDCLASSA wndclassA;
823 wndclassA.style = 0;
824 wndclassA.lpfnWndProc = DefWindowProcA;
825 wndclassA.cbClsExtra = 0;
826 wndclassA.cbWndExtra = 0;
827 wndclassA.hInstance = GetModuleHandleA(NULL);
828 wndclassA.hIcon = NULL;
829 wndclassA.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
830 wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
831 wndclassA.lpszMenuName = NULL;
832 wndclassA.lpszClassName = "WineAtlTestClass";
834 return RegisterClassA(&wndclassA);
837 static HWND create_container_window(void)
839 return CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
840 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
841 CW_USEDEFAULT, NULL, NULL, NULL, NULL);
844 static void test_AtlAxAttachControl(void)
846 HWND hwnd;
847 HRESULT hr;
848 IUnknown *control, *container;
849 LONG val;
851 hr = AtlAxAttachControl(NULL, NULL, NULL);
852 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
854 container = (IUnknown *)0xdeadbeef;
855 hr = AtlAxAttachControl(NULL, NULL, &container);
856 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
857 ok(container == (IUnknown *)0xdeadbeef,
858 "Expected the output container pointer to be untouched, got %p\n", container);
860 hwnd = create_container_window();
861 hr = AtlAxAttachControl(NULL, hwnd, NULL);
862 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
863 DestroyWindow(hwnd);
865 hwnd = create_container_window();
866 container = (IUnknown *)0xdeadbeef;
867 hr = AtlAxAttachControl(NULL, hwnd, &container);
868 ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
869 ok(container == (IUnknown *)0xdeadbeef, "returned %p\n", container);
870 DestroyWindow(hwnd);
872 hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
873 &IID_IOleObject, (void **)&control);
874 ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08x\n", hr);
876 if (FAILED(hr))
878 skip("Couldn't obtain a test IOleObject instance\n");
879 return;
882 hr = AtlAxAttachControl(control, NULL, NULL);
883 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
885 container = NULL;
886 hr = AtlAxAttachControl(control, NULL, &container);
887 ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
888 ok(container != NULL, "got %p\n", container);
889 IUnknown_Release(container);
891 hwnd = create_container_window();
892 SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);
893 hr = AtlAxAttachControl(control, hwnd, NULL);
894 ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
895 val = GetWindowLongW(hwnd, GWLP_USERDATA);
896 ok(val == 0xdeadbeef, "returned %08x\n", val);
897 DestroyWindow(hwnd);
899 hwnd = create_container_window();
900 SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);
901 container = NULL;
902 hr = AtlAxAttachControl(control, hwnd, &container);
903 ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
904 ok(container != NULL, "Expected not NULL!\n");
905 IUnknown_Release(container);
906 val = GetWindowLongW(hwnd, GWLP_USERDATA);
907 ok(val == 0xdeadbeef, "Expected unchanged, returned %08x\n", val);
908 DestroyWindow(hwnd);
910 IUnknown_Release(control);
913 static void test_AtlAxCreateControl(void)
915 HWND hwnd;
916 IUnknown *control, *container;
917 HRESULT hr;
918 DWORD ret, ret_size;
919 HANDLE hfile;
920 WCHAR file_uri1W[MAX_PATH], pathW[MAX_PATH];
922 container = NULL;
923 control = (IUnknown *)0xdeadbeef;
924 hr = AtlAxCreateControlEx(NULL, NULL, NULL, &container, &control, NULL, NULL);
925 todo_wine ok(hr == S_FALSE, "got 0x%08x\n", hr);
926 todo_wine ok(container != NULL, "returned %p\n", container);
927 ok(!control, "returned %p\n", control);
929 container = NULL;
930 control = (IUnknown *)0xdeadbeef;
931 hwnd = create_container_window();
932 ok(hwnd != NULL, "create window failed!\n");
933 hr = AtlAxCreateControlEx(NULL, hwnd, NULL, &container, &control, &IID_NULL, NULL);
934 ok(hr == S_OK, "got 0x%08x\n", hr);
935 todo_wine ok(container != NULL, "returned %p!\n", container);
936 ok(!control, "returned %p\n", control);
937 DestroyWindow(hwnd);
939 container = NULL;
940 control = (IUnknown *)0xdeadbeef;
941 hwnd = create_container_window();
942 ok(hwnd != NULL, "create window failed!\n");
943 hr = AtlAxCreateControlEx(emptyW, hwnd, NULL, &container, &control, &IID_NULL, NULL);
944 ok(hr == S_OK, "got 0x%08x\n", hr);
945 todo_wine ok(container != NULL, "returned %p!\n", container);
946 ok(!control, "returned %p\n", control);
947 DestroyWindow(hwnd);
949 container = (IUnknown *)0xdeadbeef;
950 control = (IUnknown *)0xdeadbeef;
951 hwnd = create_container_window();
952 ok(hwnd != NULL, "create window failed!\n");
953 hr = AtlAxCreateControlEx(randomW, hwnd, NULL, &container, &control, &IID_NULL, NULL);
954 ok(hr == CO_E_CLASSSTRING, "got 0x%08x\n", hr);
955 ok(!container, "returned %p!\n", container);
956 ok(!control, "returned %p\n", control);
957 DestroyWindow(hwnd);
959 container = NULL;
960 control = NULL;
961 hwnd = create_container_window();
962 ok(hwnd != NULL, "create window failed!\n");
963 hr = AtlAxCreateControlEx(progid1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
964 ok(hr == S_OK, "got 0x%08x\n", hr);
965 ok(container != NULL, "returned %p!\n", container);
966 ok(control != NULL, "returned %p\n", control);
967 DestroyWindow(hwnd);
969 container = NULL;
970 control = NULL;
971 hwnd = create_container_window();
972 ok(hwnd != NULL, "create window failed!\n");
973 hr = AtlAxCreateControlEx(clsid1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
974 ok(hr == S_OK, "got 0x%08x\n", hr);
975 ok(container != NULL, "returned %p!\n", container);
976 ok(control != NULL, "returned %p\n", control);
977 IUnknown_Release(container);
978 IUnknown_Release(control);
979 DestroyWindow(hwnd);
981 container = NULL;
982 control = NULL;
983 hwnd = create_container_window();
984 ok(hwnd != NULL, "create window failed!\n");
985 hr = AtlAxCreateControlEx(url1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
986 ok(hr == S_OK, "got 0x%08x\n", hr);
987 ok(container != NULL, "returned %p!\n", container);
988 ok(control != NULL, "returned %p\n", control);
989 IUnknown_Release(container);
990 IUnknown_Release(control);
991 DestroyWindow(hwnd);
993 container = NULL;
994 control = NULL;
995 hwnd = create_container_window();
996 ok(hwnd != NULL, "create window failed!\n");
997 hr = AtlAxCreateControlEx(mshtml1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
998 ok(hr == S_OK, "got 0x%08x\n", hr);
999 ok(container != NULL, "returned %p!\n", container);
1000 ok(control != NULL, "returned %p\n", control);
1001 IUnknown_Release(container);
1002 IUnknown_Release(control);
1003 DestroyWindow(hwnd);
1005 container = NULL;
1006 control = NULL;
1007 hwnd = create_container_window();
1008 ok(hwnd != NULL, "create window failed!\n");
1009 hr = AtlAxCreateControlEx(mshtml2W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1010 ok(hr == S_OK, "got 0x%08x\n", hr);
1011 ok(container != NULL, "returned %p!\n", container);
1012 ok(control != NULL, "returned %p\n", control);
1013 IUnknown_Release(container);
1014 IUnknown_Release(control);
1015 DestroyWindow(hwnd);
1017 container = (IUnknown *)0xdeadbeef;
1018 control = (IUnknown *)0xdeadbeef;
1019 hwnd = create_container_window();
1020 ok(hwnd != NULL, "create window failed!\n");
1021 hr = AtlAxCreateControlEx(mshtml3W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1022 ok(hr == CO_E_CLASSSTRING, "got 0x%08x\n", hr);
1023 ok(!container, "returned %p!\n", container);
1024 ok(!control, "returned %p\n", control);
1025 DestroyWindow(hwnd);
1027 ret = GetTempPathW(MAX_PATH, pathW);
1028 ok(ret, "GetTempPath failed!\n");
1029 lstrcatW(pathW, html_fileW);
1030 hfile = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
1031 ok(hfile != INVALID_HANDLE_VALUE, "failed to create file\n");
1032 ret = WriteFile(hfile, html_str, sizeof(html_str), &ret_size, NULL);
1033 ok(ret, "WriteFile failed\n");
1034 CloseHandle(hfile);
1036 /* test C:// scheme */
1037 container = NULL;
1038 control = NULL;
1039 hwnd = create_container_window();
1040 ok(hwnd != NULL, "create window failed!\n");
1041 hr = AtlAxCreateControlEx(pathW, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1042 ok(hr == S_OK, "got 0x%08x\n", hr);
1043 ok(container != NULL, "returned %p!\n", container);
1044 ok(control != NULL, "returned %p\n", control);
1045 IUnknown_Release(container);
1046 IUnknown_Release(control);
1047 DestroyWindow(hwnd);
1049 /* test file:// scheme */
1050 lstrcpyW(file_uri1W, fileW);
1051 lstrcatW(file_uri1W, pathW);
1052 container = NULL;
1053 control = NULL;
1054 hwnd = create_container_window();
1055 ok(hwnd != NULL, "create window failed!\n");
1056 hr = AtlAxCreateControlEx(file_uri1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1057 ok(hr == S_OK, "got 0x%08x\n", hr);
1058 ok(container != NULL, "returned %p!\n", container);
1059 ok(control != NULL, "returned %p\n", control);
1060 IUnknown_Release(container);
1061 IUnknown_Release(control);
1062 DestroyWindow(hwnd);
1064 /* test file:// scheme on non-existent file. */
1065 ret = DeleteFileW(pathW);
1066 ok(ret, "DeleteFile failed!\n");
1067 container = NULL;
1068 control = NULL;
1069 hwnd = create_container_window();
1070 ok(hwnd != NULL, "create window failed!\n");
1071 hr = AtlAxCreateControlEx(file_uri1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1072 ok(hr == S_OK, "got 0x%08x\n", hr);
1073 ok(container != NULL, "returned %p!\n", container);
1074 ok(control != NULL, "returned %p\n", control);
1075 IUnknown_Release(container);
1076 IUnknown_Release(control);
1077 DestroyWindow(hwnd);
1080 START_TEST(atl)
1082 if (!register_class())
1083 return;
1085 CoInitialize(NULL);
1087 test_winmodule();
1088 test_regcat();
1089 test_typelib();
1090 test_cp();
1091 test_source_iface();
1092 test_ax_win();
1093 test_AtlAxAttachControl();
1094 test_AtlAxCreateControl();
1096 CoUninitialize();