[THEMES]
[reactos.git] / rostests / winetests / atl100 / atl.c
1 /*
2 * Copyright 2012 Jacek Caban for CodeWeavers
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 #include <stdarg.h>
20 #include <stdio.h>
21
22 #define WIN32_NO_STATUS
23 #define _INC_WINDOWS
24 #define COM_NO_WINDOWS_H
25
26 #define COBJMACROS
27 #define CONST_VTABLE
28
29 #include <windef.h>
30 #include <winbase.h>
31 #include <winuser.h>
32 #include <winreg.h>
33 #include <wingdi.h>
34 #include <objbase.h>
35 #include <oleauto.h>
36
37 #include <wine/atlbase.h>
38 #include <mshtml.h>
39
40 #include <wine/test.h>
41
42 static const GUID CLSID_Test =
43 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
44 #define CLSID_TEST_STR "178fc163-0000-0000-0000-000000000046"
45
46 static const GUID CATID_CatTest1 =
47 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x46}};
48 #define CATID_CATTEST1_STR "178fc163-0000-0000-0000-000000000146"
49
50 static const GUID CATID_CatTest2 =
51 {0x178fc163,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x46}};
52 #define CATID_CATTEST2_STR "178fc163-0000-0000-0000-000000000246"
53
54 static const char *debugstr_guid(REFIID riid)
55 {
56 static char buf[50];
57
58 if(!riid)
59 return "(null)";
60
61 sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
62 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
63 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
64 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
65
66 return buf;
67 }
68
69 static void test_winmodule(void)
70 {
71 _AtlCreateWndData create_data[3];
72 _ATL_WIN_MODULE winmod;
73 void *p;
74 HRESULT hres;
75
76 winmod.cbSize = 0xdeadbeef;
77 hres = AtlWinModuleInit(&winmod);
78 ok(hres == E_INVALIDARG, "AtlWinModuleInit failed: %08x\n", hres);
79
80 winmod.cbSize = sizeof(winmod);
81 winmod.m_pCreateWndList = (void*)0xdeadbeef;
82 winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
83 winmod.m_rgWindowClassAtoms.m_aT = (void*)0xdeadbeef;
84 winmod.m_rgWindowClassAtoms.m_nSize = 0xdeadbeef;
85 winmod.m_rgWindowClassAtoms.m_nAllocSize = 0xdeadbeef;
86 hres = AtlWinModuleInit(&winmod);
87 ok(hres == S_OK, "AtlWinModuleInit failed: %08x\n", hres);
88 ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
89 ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %d\n",
90 winmod.m_csWindowCreate.LockCount);
91 ok(winmod.m_rgWindowClassAtoms.m_aT == (void*)0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_aT = %p\n",
92 winmod.m_rgWindowClassAtoms.m_aT);
93 ok(winmod.m_rgWindowClassAtoms.m_nSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nSize = %d\n",
94 winmod.m_rgWindowClassAtoms.m_nSize);
95 ok(winmod.m_rgWindowClassAtoms.m_nAllocSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nAllocSize = %d\n",
96 winmod.m_rgWindowClassAtoms.m_nAllocSize);
97
98 InitializeCriticalSection(&winmod.m_csWindowCreate);
99
100 AtlWinModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
101 ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
102 ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
103 ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %x\n",
104 create_data[0].m_dwThreadID);
105 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
106
107 AtlWinModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
108 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
109 ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
110 ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %x\n",
111 create_data[1].m_dwThreadID);
112 ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
113
114 AtlWinModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
115 ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
116 ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
117 ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %x\n",
118 create_data[2].m_dwThreadID);
119 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
120
121 p = AtlWinModuleExtractCreateWndData(&winmod);
122 ok(p == (void*)0xdead0003, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
123 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
124 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
125
126 create_data[1].m_dwThreadID = 0xdeadbeef;
127
128 p = AtlWinModuleExtractCreateWndData(&winmod);
129 ok(p == (void*)0xdead0001, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
130 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
131 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
132 ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
133
134 p = AtlWinModuleExtractCreateWndData(&winmod);
135 ok(!p, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
136 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
137 }
138
139 #define test_key_exists(a,b) _test_key_exists(__LINE__,a,b)
140 static void _test_key_exists(unsigned line, HKEY root, const char *key_name)
141 {
142 HKEY key;
143 DWORD res;
144
145 res = RegOpenKeyA(root, key_name, &key);
146 ok_(__FILE__,line)(res == ERROR_SUCCESS, "Could not open key %s\n", key_name);
147 if(res == ERROR_SUCCESS)
148 RegCloseKey(key);
149 }
150
151 #define test_key_not_exists(a,b) _test_key_not_exists(__LINE__,a,b)
152 static void _test_key_not_exists(unsigned line, HKEY root, const char *key_name)
153 {
154 HKEY key;
155 DWORD res;
156
157 res = RegOpenKeyA(root, key_name, &key);
158 ok_(__FILE__,line)(res == ERROR_FILE_NOT_FOUND, "Attempting to open %s returned %u\n", key_name, res);
159 if(res == ERROR_SUCCESS)
160 RegCloseKey(key);
161 }
162
163 static void test_regcat(void)
164 {
165 unsigned char b;
166 HRESULT hres;
167
168 const struct _ATL_CATMAP_ENTRY catmap[] = {
169 {_ATL_CATMAP_ENTRY_IMPLEMENTED, &CATID_CatTest1},
170 {_ATL_CATMAP_ENTRY_REQUIRED, &CATID_CatTest2},
171 {_ATL_CATMAP_ENTRY_END}
172 };
173
174 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, TRUE);
175 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
176
177 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
178 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories\\{" CATID_CATTEST1_STR "}");
179 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories\\{" CATID_CATTEST2_STR "}");
180
181 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, FALSE);
182 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
183
184 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories");
185 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories");
186 test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
187
188 ok(RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}") == ERROR_SUCCESS, "Could not delete key\n");
189
190 hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, NULL, TRUE);
191 ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08x\n", hres);
192
193 test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
194
195 b = 10;
196 hres = AtlGetPerUserRegistration(&b);
197 ok(hres == S_OK, "AtlGetPerUserRegistration failed: %08x\n", hres);
198 ok(!b, "AtlGetPerUserRegistration returned %x\n", b);
199 }
200
201 static void test_typelib(void)
202 {
203 ITypeLib *typelib;
204 HINSTANCE inst;
205 size_t len;
206 BSTR path;
207 HRESULT hres;
208
209 static const WCHAR scrrun_dll_suffixW[] = {'\\','s','c','r','r','u','n','.','d','l','l',0};
210 static const WCHAR mshtml_tlb_suffixW[] = {'\\','m','s','h','t','m','l','.','t','l','b',0};
211
212 inst = LoadLibraryA("scrrun.dll");
213 ok(inst != NULL, "Could not load scrrun.dll\n");
214
215 typelib = NULL;
216 hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
217 ok(hres == S_OK, "AtlLoadTypeLib failed: %08x\n", hres);
218 FreeLibrary(inst);
219
220 len = SysStringLen(path);
221 ok(len > sizeof(scrrun_dll_suffixW)/sizeof(WCHAR)
222 && lstrcmpiW(path+len-sizeof(scrrun_dll_suffixW)/sizeof(WCHAR), scrrun_dll_suffixW),
223 "unexpected path %s\n", wine_dbgstr_w(path));
224 SysFreeString(path);
225 ok(typelib != NULL, "typelib == NULL\n");
226 ITypeLib_Release(typelib);
227
228 inst = LoadLibraryA("mshtml.dll");
229 ok(inst != NULL, "Could not load mshtml.dll\n");
230
231 typelib = NULL;
232 hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
233 ok(hres == S_OK, "AtlLoadTypeLib failed: %08x\n", hres);
234 FreeLibrary(inst);
235
236 len = SysStringLen(path);
237 ok(len > sizeof(mshtml_tlb_suffixW)/sizeof(WCHAR)
238 && lstrcmpiW(path+len-sizeof(mshtml_tlb_suffixW)/sizeof(WCHAR), mshtml_tlb_suffixW),
239 "unexpected path %s\n", wine_dbgstr_w(path));
240 SysFreeString(path);
241 ok(typelib != NULL, "typelib == NULL\n");
242 ITypeLib_Release(typelib);
243 }
244
245 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
246 {
247 if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
248 *ppv = iface;
249 return S_OK;
250 }
251
252 ok(0, "unexpected call\n");
253 return E_NOINTERFACE;
254 }
255
256 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
257 {
258 return 2;
259 }
260
261 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
262 {
263 return 1;
264 }
265
266 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
267 {
268 ok(0, "unexpected call\n");
269 return E_NOTIMPL;
270 }
271
272 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
273 IConnectionPointContainer **ppCPC)
274 {
275 ok(0, "unexpected call\n");
276 return E_NOTIMPL;
277 }
278
279 static int advise_cnt;
280
281 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
282 DWORD *pdwCookie)
283 {
284 ok(pUnkSink == (IUnknown*)0xdead0000, "pUnkSink = %p\n", pUnkSink);
285 *pdwCookie = 0xdeadbeef;
286 advise_cnt++;
287 return S_OK;
288 }
289
290 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
291 {
292 ok(dwCookie == 0xdeadbeef, "dwCookie = %x\n", dwCookie);
293 advise_cnt--;
294 return S_OK;
295 }
296
297 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
298 IEnumConnections **ppEnum)
299 {
300 ok(0, "unexpected call\n");
301 return E_NOTIMPL;
302 }
303
304 static const IConnectionPointVtbl ConnectionPointVtbl =
305 {
306 ConnectionPoint_QueryInterface,
307 ConnectionPoint_AddRef,
308 ConnectionPoint_Release,
309 ConnectionPoint_GetConnectionInterface,
310 ConnectionPoint_GetConnectionPointContainer,
311 ConnectionPoint_Advise,
312 ConnectionPoint_Unadvise,
313 ConnectionPoint_EnumConnections
314 };
315
316 static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
317
318 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
319 REFIID riid, void **ppv)
320 {
321 if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
322 *ppv = iface;
323 return S_OK;
324 }
325
326 ok(0, "unexpected call\n");
327 return E_NOTIMPL;
328 }
329
330 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
331 {
332 return 2;
333 }
334
335 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
336 {
337 return 1;
338 }
339
340 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
341 IEnumConnectionPoints **ppEnum)
342 {
343 ok(0, "unexpected call\n");
344 return E_NOTIMPL;
345 }
346
347 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
348 REFIID riid, IConnectionPoint **ppCP)
349 {
350 ok(IsEqualGUID(riid, &CLSID_Test), "unexpected riid\n");
351 *ppCP = &ConnectionPoint;
352 return S_OK;
353 }
354
355 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
356 ConnectionPointContainer_QueryInterface,
357 ConnectionPointContainer_AddRef,
358 ConnectionPointContainer_Release,
359 ConnectionPointContainer_EnumConnectionPoints,
360 ConnectionPointContainer_FindConnectionPoint
361 };
362
363 static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
364
365 static void test_cp(void)
366 {
367 DWORD cookie = 0;
368 HRESULT hres;
369
370 hres = AtlAdvise(NULL, (IUnknown*)0xdeed0000, &CLSID_Test, &cookie);
371 ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres);
372
373 hres = AtlUnadvise(NULL, &CLSID_Test, 0xdeadbeef);
374 ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres);
375
376 hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie);
377 ok(hres == S_OK, "AtlAdvise failed: %08x\n", hres);
378 ok(cookie == 0xdeadbeef, "cookie = %x\n", cookie);
379 ok(advise_cnt == 1, "advise_cnt = %d\n", advise_cnt);
380
381 hres = AtlUnadvise((IUnknown*)&ConnectionPointContainer, &CLSID_Test, 0xdeadbeef);
382 ok(hres == S_OK, "AtlUnadvise failed: %08x\n", hres);
383 ok(!advise_cnt, "advise_cnt = %d\n", advise_cnt);
384 }
385
386 static CLSID persist_clsid;
387
388 static HRESULT WINAPI Persist_QueryInterface(IPersist *iface, REFIID riid, void **ppv)
389 {
390 ok(0, "unexpected call\n");
391 return E_NOINTERFACE;
392 }
393
394 static ULONG WINAPI Persist_AddRef(IPersist *iface)
395 {
396 return 2;
397 }
398
399 static ULONG WINAPI Persist_Release(IPersist *iface)
400 {
401 return 1;
402 }
403
404 static HRESULT WINAPI Persist_GetClassID(IPersist *iface, CLSID *pClassID)
405 {
406 *pClassID = persist_clsid;
407 return S_OK;
408 }
409
410 static const IPersistVtbl PersistVtbl = {
411 Persist_QueryInterface,
412 Persist_AddRef,
413 Persist_Release,
414 Persist_GetClassID
415 };
416
417 static IPersist Persist = { &PersistVtbl };
418
419 static HRESULT WINAPI ProvideClassInfo2_QueryInterface(IProvideClassInfo2 *iface, REFIID riid, void **ppv)
420 {
421 ok(0, "unexpected call\n");
422 return E_NOINTERFACE;
423 }
424
425 static ULONG WINAPI ProvideClassInfo2_AddRef(IProvideClassInfo2 *iface)
426 {
427 return 2;
428 }
429
430 static ULONG WINAPI ProvideClassInfo2_Release(IProvideClassInfo2 *iface)
431 {
432 return 1;
433 }
434
435 static HRESULT WINAPI ProvideClassInfo2_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ppTI)
436 {
437 ok(0, "unexpected call\n");
438 return E_NOTIMPL;
439 }
440
441 static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideClassInfo2 *iface, DWORD dwGuidKind, GUID *pGUID)
442 {
443 ok(dwGuidKind == GUIDKIND_DEFAULT_SOURCE_DISP_IID, "unexpected dwGuidKind %x\n", dwGuidKind);
444 *pGUID = DIID_DispHTMLBody;
445 return S_OK;
446 }
447
448 static const IProvideClassInfo2Vtbl ProvideClassInfo2Vtbl = {
449 ProvideClassInfo2_QueryInterface,
450 ProvideClassInfo2_AddRef,
451 ProvideClassInfo2_Release,
452 ProvideClassInfo2_GetClassInfo,
453 ProvideClassInfo2_GetGUID
454 };
455
456 static IProvideClassInfo2 ProvideClassInfo2 = { &ProvideClassInfo2Vtbl };
457 static BOOL support_classinfo2;
458
459 static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
460 {
461 *ppv = NULL;
462
463 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
464 *ppv = iface;
465 return S_OK;
466 }
467
468 if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
469 if(!support_classinfo2)
470 return E_NOINTERFACE;
471 *ppv = &ProvideClassInfo2;
472 return S_OK;
473 }
474
475 if(IsEqualGUID(&IID_IPersist, riid)) {
476 *ppv = &Persist;
477 return S_OK;
478 }
479
480 ok(0, "unexpected riid: %s\n", debugstr_guid(riid));
481 return E_NOINTERFACE;
482 }
483
484 static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
485 {
486 return 2;
487 }
488
489 static ULONG WINAPI Dispatch_Release(IDispatch *iface)
490 {
491 return 1;
492 }
493
494 static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
495 {
496 ok(0, "unexpected call\n");
497 return E_NOTIMPL;
498 }
499
500 static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
501 ITypeInfo **ppTInfo)
502 {
503 ITypeLib *typelib;
504 HRESULT hres;
505
506 static const WCHAR mshtml_tlbW[] = {'m','s','h','t','m','l','.','t','l','b',0};
507
508 ok(!iTInfo, "iTInfo = %d\n", iTInfo);
509 ok(!lcid, "lcid = %x\n", lcid);
510
511 hres = LoadTypeLib(mshtml_tlbW, &typelib);
512 ok(hres == S_OK, "LoadTypeLib failed: %08x\n", hres);
513
514 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHTMLElement, ppTInfo);
515 ok(hres == S_OK, "GetTypeInfoOfGuid failed: %08x\n", hres);
516
517 ITypeLib_Release(typelib);
518 return S_OK;
519 }
520
521 static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
522 UINT cNames, LCID lcid, DISPID *rgDispId)
523 {
524 ok(0, "unexpected call\n");
525 return E_NOTIMPL;
526 }
527
528 static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
529 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
530 EXCEPINFO *pExcepInfo, UINT *puArgErr)
531 {
532 ok(0, "unexpected call\n");
533 return E_NOTIMPL;
534 }
535
536 static const IDispatchVtbl DispatchVtbl = {
537 Dispatch_QueryInterface,
538 Dispatch_AddRef,
539 Dispatch_Release,
540 Dispatch_GetTypeInfoCount,
541 Dispatch_GetTypeInfo,
542 Dispatch_GetIDsOfNames,
543 Dispatch_Invoke
544 };
545
546 static IDispatch Dispatch = { &DispatchVtbl };
547
548 static void test_source_iface(void)
549 {
550 unsigned short maj_ver, min_ver;
551 IID libid, iid;
552 HRESULT hres;
553
554 support_classinfo2 = TRUE;
555
556 maj_ver = min_ver = 0xdead;
557 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
558 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
559 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", debugstr_guid(&libid));
560 ok(IsEqualGUID(&iid, &DIID_DispHTMLBody), "iid = %s\n", debugstr_guid(&iid));
561 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
562
563 support_classinfo2 = FALSE;
564 persist_clsid = CLSID_HTMLDocument;
565
566 maj_ver = min_ver = 0xdead;
567 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
568 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
569 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", debugstr_guid(&libid));
570 ok(IsEqualGUID(&iid, &DIID_HTMLDocumentEvents), "iid = %s\n", debugstr_guid(&iid));
571 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
572
573 persist_clsid = CLSID_HTMLStyle;
574
575 maj_ver = min_ver = 0xdead;
576 hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
577 ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08x\n", hres);
578 ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", debugstr_guid(&libid));
579 ok(IsEqualGUID(&iid, &IID_NULL), "iid = %s\n", debugstr_guid(&iid));
580 ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
581 }
582
583 static void test_ax_win(void)
584 {
585 BOOL ret;
586 WNDCLASSEXW wcex;
587 static const WCHAR AtlAxWin100[] = {'A','t','l','A','x','W','i','n','1','0','0',0};
588 static const WCHAR AtlAxWinLic100[] = {'A','t','l','A','x','W','i','n','L','i','c','1','0','0',0};
589 static HMODULE hinstance = 0;
590
591 ret = AtlAxWinInit();
592 ok(ret, "AtlAxWinInit failed\n");
593
594 hinstance = GetModuleHandleA(NULL);
595
596 memset(&wcex, 0, sizeof(wcex));
597 wcex.cbSize = sizeof(wcex);
598 ret = GetClassInfoExW(hinstance, AtlAxWin100, &wcex);
599 ok(ret, "AtlAxWin100 has not registered\n");
600 ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
601
602 memset(&wcex, 0, sizeof(wcex));
603 wcex.cbSize = sizeof(wcex);
604 ret = GetClassInfoExW(hinstance, AtlAxWinLic100, &wcex);
605 ok(ret, "AtlAxWinLic100 has not registered\n");
606 ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
607 }
608
609 START_TEST(atl)
610 {
611 CoInitialize(NULL);
612
613 test_winmodule();
614 test_regcat();
615 test_typelib();
616 test_cp();
617 test_source_iface();
618 test_ax_win();
619
620 CoUninitialize();
621 }