Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/atl100/tests/atl.c
4391 views
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 COBJMACROS
23
#define CONST_VTABLE
24
25
#include <windef.h>
26
#include <winbase.h>
27
#include <winuser.h>
28
#include <exdisp.h>
29
30
#include <atlbase.h>
31
#include <mshtml.h>
32
33
#include <wine/test.h>
34
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"
38
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"
42
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"
46
static const WCHAR progid1W[] = L"Shell.Explorer.2";
47
static const WCHAR clsid1W[] = L"{8856f961-340a-11d0-a96b-00c04fd705a2}";
48
static const WCHAR url1W[] = L"http://test.winehq.org/tests/winehq_snapshot/";
49
static const WCHAR mshtml1W[] = L"mshtml:<html><body>test</body></html>";
50
static const WCHAR mshtml2W[] = L"MSHTML:<html><body>test</body></html>";
51
static const WCHAR mshtml3W[] = L"<html><body>test</body></html>";
52
static const char html_str[] = "<html><body>test</body><html>";
53
54
static BOOL is_token_admin(HANDLE token)
55
{
56
PSID administrators = NULL;
57
SID_IDENTIFIER_AUTHORITY nt_authority = { SECURITY_NT_AUTHORITY };
58
DWORD groups_size;
59
PTOKEN_GROUPS groups;
60
DWORD group_index;
61
62
/* Create a well-known SID for the Administrators group. */
63
if (! AllocateAndInitializeSid(&nt_authority, 2, SECURITY_BUILTIN_DOMAIN_RID,
64
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0,
65
&administrators))
66
return FALSE;
67
68
/* Get the group info from the token */
69
groups_size = 0;
70
GetTokenInformation(token, TokenGroups, NULL, 0, &groups_size);
71
groups = HeapAlloc(GetProcessHeap(), 0, groups_size);
72
if (groups == NULL)
73
{
74
FreeSid(administrators);
75
return FALSE;
76
}
77
if (! GetTokenInformation(token, TokenGroups, groups, groups_size, &groups_size))
78
{
79
HeapFree(GetProcessHeap(), 0, groups);
80
FreeSid(administrators);
81
return FALSE;
82
}
83
84
/* Now check if the token groups include the Administrators group */
85
for (group_index = 0; group_index < groups->GroupCount; group_index++)
86
{
87
if (EqualSid(groups->Groups[group_index].Sid, administrators))
88
{
89
HeapFree(GetProcessHeap(), 0, groups);
90
FreeSid(administrators);
91
return TRUE;
92
}
93
}
94
95
/* If we end up here we didn't find the Administrators group */
96
HeapFree(GetProcessHeap(), 0, groups);
97
FreeSid(administrators);
98
return FALSE;
99
}
100
101
static BOOL is_process_limited(void)
102
{
103
static BOOL (WINAPI *pOpenProcessToken)(HANDLE, DWORD, PHANDLE) = NULL;
104
HANDLE token;
105
BOOL result=FALSE;
106
107
if (!pOpenProcessToken)
108
{
109
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
110
pOpenProcessToken = (void*)GetProcAddress(hadvapi32, "OpenProcessToken");
111
if (!pOpenProcessToken)
112
return FALSE;
113
}
114
115
if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
116
{
117
BOOL ret;
118
TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
119
DWORD size;
120
121
ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
122
if (ret)
123
{
124
if (type == TokenElevationTypeDefault)
125
/* UAC is disabled, check for administrators group */
126
result = !is_token_admin(token);
127
else if (type == TokenElevationTypeFull)
128
result = FALSE;
129
else if (type == TokenElevationTypeLimited)
130
result = TRUE;
131
}
132
CloseHandle(token);
133
}
134
return result;
135
}
136
137
static void test_winmodule(void)
138
{
139
_AtlCreateWndData create_data[3];
140
_ATL_WIN_MODULE winmod;
141
void *p;
142
HRESULT hres;
143
144
winmod.cbSize = 0xdeadbeef;
145
hres = AtlWinModuleInit(&winmod);
146
ok(hres == E_INVALIDARG, "AtlWinModuleInit failed: %08lx\n", hres);
147
148
winmod.cbSize = sizeof(winmod);
149
winmod.m_pCreateWndList = (void*)0xdeadbeef;
150
winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
151
winmod.m_rgWindowClassAtoms.m_aT = (void*)0xdeadbeef;
152
winmod.m_rgWindowClassAtoms.m_nSize = 0xdeadbeef;
153
winmod.m_rgWindowClassAtoms.m_nAllocSize = 0xdeadbeef;
154
hres = AtlWinModuleInit(&winmod);
155
ok(hres == S_OK, "AtlWinModuleInit failed: %08lx\n", hres);
156
ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
157
ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %ld\n",
158
winmod.m_csWindowCreate.LockCount);
159
ok(winmod.m_rgWindowClassAtoms.m_aT == (void*)0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_aT = %p\n",
160
winmod.m_rgWindowClassAtoms.m_aT);
161
ok(winmod.m_rgWindowClassAtoms.m_nSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nSize = %d\n",
162
winmod.m_rgWindowClassAtoms.m_nSize);
163
ok(winmod.m_rgWindowClassAtoms.m_nAllocSize == 0xdeadbeef, "winmod.m_rgWindowClassAtoms.m_nAllocSize = %d\n",
164
winmod.m_rgWindowClassAtoms.m_nAllocSize);
165
166
InitializeCriticalSection(&winmod.m_csWindowCreate);
167
168
AtlWinModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
169
ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
170
ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
171
ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %lx\n",
172
create_data[0].m_dwThreadID);
173
ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
174
175
AtlWinModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
176
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
177
ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
178
ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %lx\n",
179
create_data[1].m_dwThreadID);
180
ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
181
182
AtlWinModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
183
ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
184
ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
185
ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %lx\n",
186
create_data[2].m_dwThreadID);
187
ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
188
189
p = AtlWinModuleExtractCreateWndData(&winmod);
190
ok(p == (void*)0xdead0003, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
191
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
192
ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
193
194
create_data[1].m_dwThreadID = 0xdeadbeef;
195
196
p = AtlWinModuleExtractCreateWndData(&winmod);
197
ok(p == (void*)0xdead0001, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
198
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
199
ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
200
ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
201
202
p = AtlWinModuleExtractCreateWndData(&winmod);
203
ok(!p, "unexpected AtlWinModuleExtractCreateWndData result %p\n", p);
204
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
205
}
206
207
#define test_key_exists(a,b) _test_key_exists(__LINE__,a,b)
208
static void _test_key_exists(unsigned line, HKEY root, const char *key_name)
209
{
210
HKEY key;
211
DWORD res;
212
213
res = RegOpenKeyA(root, key_name, &key);
214
ok_(__FILE__,line)(res == ERROR_SUCCESS, "Could not open key %s\n", key_name);
215
if(res == ERROR_SUCCESS)
216
RegCloseKey(key);
217
}
218
219
#define test_key_not_exists(a,b) _test_key_not_exists(__LINE__,a,b)
220
static void _test_key_not_exists(unsigned line, HKEY root, const char *key_name)
221
{
222
HKEY key;
223
DWORD res;
224
225
res = RegOpenKeyA(root, key_name, &key);
226
ok_(__FILE__,line)(res == ERROR_FILE_NOT_FOUND, "Attempting to open %s returned %lu\n", key_name, res);
227
if(res == ERROR_SUCCESS)
228
RegCloseKey(key);
229
}
230
231
static void test_regcat(void)
232
{
233
unsigned char b;
234
HRESULT hres;
235
236
const struct _ATL_CATMAP_ENTRY catmap[] = {
237
{_ATL_CATMAP_ENTRY_IMPLEMENTED, &CATID_CatTest1},
238
{_ATL_CATMAP_ENTRY_REQUIRED, &CATID_CatTest2},
239
{_ATL_CATMAP_ENTRY_END}
240
};
241
242
if (is_process_limited())
243
{
244
skip("process is limited\n");
245
return;
246
}
247
248
hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, TRUE);
249
ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08lx\n", hres);
250
251
test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
252
test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories\\{" CATID_CATTEST1_STR "}");
253
test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories\\{" CATID_CATTEST2_STR "}");
254
255
hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, catmap, FALSE);
256
ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08lx\n", hres);
257
258
test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Implemented Categories");
259
test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}\\Required Categories");
260
test_key_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
261
262
ok(RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}") == ERROR_SUCCESS, "Could not delete key\n");
263
264
hres = AtlRegisterClassCategoriesHelper(&CLSID_Test, NULL, TRUE);
265
ok(hres == S_OK, "AtlRegisterClassCategoriesHelper failed: %08lx\n", hres);
266
267
test_key_not_exists(HKEY_CLASSES_ROOT, "CLSID\\{" CLSID_TEST_STR "}");
268
269
b = 10;
270
hres = AtlGetPerUserRegistration(&b);
271
ok(hres == S_OK, "AtlGetPerUserRegistration failed: %08lx\n", hres);
272
ok(!b, "AtlGetPerUserRegistration returned %x\n", b);
273
}
274
275
static void test_typelib(void)
276
{
277
ITypeLib *typelib;
278
HINSTANCE inst;
279
size_t len;
280
BSTR path;
281
HRESULT hres;
282
283
inst = LoadLibraryA("scrrun.dll");
284
ok(inst != NULL, "Could not load scrrun.dll\n");
285
286
typelib = NULL;
287
hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
288
ok(hres == S_OK, "AtlLoadTypeLib failed: %08lx\n", hres);
289
FreeLibrary(inst);
290
291
len = SysStringLen(path);
292
ok(len > ARRAY_SIZE(L"\\scrrun.dll")
293
&& lstrcmpiW(path+len-ARRAY_SIZE(L"\\scrrun.dll"), L"\\scrrun.dll"),
294
"unexpected path %s\n", wine_dbgstr_w(path));
295
SysFreeString(path);
296
ok(typelib != NULL, "typelib == NULL\n");
297
ITypeLib_Release(typelib);
298
299
inst = LoadLibraryA("mshtml.dll");
300
ok(inst != NULL, "Could not load mshtml.dll\n");
301
302
typelib = NULL;
303
hres = AtlLoadTypeLib(inst, NULL, &path, &typelib);
304
ok(hres == S_OK, "AtlLoadTypeLib failed: %08lx\n", hres);
305
FreeLibrary(inst);
306
307
len = SysStringLen(path);
308
ok(len > ARRAY_SIZE(L"\\mshtml.tlb")
309
&& lstrcmpiW(path+len-ARRAY_SIZE(L"\\mshtml.tlb"), L"\\mshtml.tlb"),
310
"unexpected path %s\n", wine_dbgstr_w(path));
311
SysFreeString(path);
312
ok(typelib != NULL, "typelib == NULL\n");
313
ITypeLib_Release(typelib);
314
}
315
316
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface, REFIID riid, void **ppv)
317
{
318
if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
319
*ppv = iface;
320
return S_OK;
321
}
322
323
ok(0, "unexpected call\n");
324
return E_NOINTERFACE;
325
}
326
327
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
328
{
329
return 2;
330
}
331
332
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
333
{
334
return 1;
335
}
336
337
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *pIID)
338
{
339
ok(0, "unexpected call\n");
340
return E_NOTIMPL;
341
}
342
343
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
344
IConnectionPointContainer **ppCPC)
345
{
346
ok(0, "unexpected call\n");
347
return E_NOTIMPL;
348
}
349
350
static int advise_cnt;
351
352
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *pUnkSink,
353
DWORD *pdwCookie)
354
{
355
ok(pUnkSink == (IUnknown*)0xdead0000, "pUnkSink = %p\n", pUnkSink);
356
*pdwCookie = 0xdeadbeef;
357
advise_cnt++;
358
return S_OK;
359
}
360
361
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
362
{
363
ok(dwCookie == 0xdeadbeef, "dwCookie = %lx\n", dwCookie);
364
advise_cnt--;
365
return S_OK;
366
}
367
368
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
369
IEnumConnections **ppEnum)
370
{
371
ok(0, "unexpected call\n");
372
return E_NOTIMPL;
373
}
374
375
static const IConnectionPointVtbl ConnectionPointVtbl =
376
{
377
ConnectionPoint_QueryInterface,
378
ConnectionPoint_AddRef,
379
ConnectionPoint_Release,
380
ConnectionPoint_GetConnectionInterface,
381
ConnectionPoint_GetConnectionPointContainer,
382
ConnectionPoint_Advise,
383
ConnectionPoint_Unadvise,
384
ConnectionPoint_EnumConnections
385
};
386
387
static IConnectionPoint ConnectionPoint = { &ConnectionPointVtbl };
388
389
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
390
REFIID riid, void **ppv)
391
{
392
if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
393
*ppv = iface;
394
return S_OK;
395
}
396
397
ok(0, "unexpected call\n");
398
return E_NOTIMPL;
399
}
400
401
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
402
{
403
return 2;
404
}
405
406
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
407
{
408
return 1;
409
}
410
411
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
412
IEnumConnectionPoints **ppEnum)
413
{
414
ok(0, "unexpected call\n");
415
return E_NOTIMPL;
416
}
417
418
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
419
REFIID riid, IConnectionPoint **ppCP)
420
{
421
ok(IsEqualGUID(riid, &CLSID_Test), "unexpected riid\n");
422
*ppCP = &ConnectionPoint;
423
return S_OK;
424
}
425
426
static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
427
ConnectionPointContainer_QueryInterface,
428
ConnectionPointContainer_AddRef,
429
ConnectionPointContainer_Release,
430
ConnectionPointContainer_EnumConnectionPoints,
431
ConnectionPointContainer_FindConnectionPoint
432
};
433
434
static IConnectionPointContainer ConnectionPointContainer = { &ConnectionPointContainerVtbl };
435
436
static void test_cp(void)
437
{
438
DWORD cookie = 0;
439
HRESULT hres;
440
441
hres = AtlAdvise(NULL, (IUnknown*)0xdeed0000, &CLSID_Test, &cookie);
442
ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08lx\n", hres);
443
444
hres = AtlUnadvise(NULL, &CLSID_Test, 0xdeadbeef);
445
ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08lx\n", hres);
446
447
hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie);
448
ok(hres == S_OK, "AtlAdvise failed: %08lx\n", hres);
449
ok(cookie == 0xdeadbeef, "cookie = %lx\n", cookie);
450
ok(advise_cnt == 1, "advise_cnt = %d\n", advise_cnt);
451
452
hres = AtlUnadvise((IUnknown*)&ConnectionPointContainer, &CLSID_Test, 0xdeadbeef);
453
ok(hres == S_OK, "AtlUnadvise failed: %08lx\n", hres);
454
ok(!advise_cnt, "advise_cnt = %d\n", advise_cnt);
455
}
456
457
static CLSID persist_clsid;
458
459
static HRESULT WINAPI Persist_QueryInterface(IPersist *iface, REFIID riid, void **ppv)
460
{
461
ok(0, "unexpected call\n");
462
return E_NOINTERFACE;
463
}
464
465
static ULONG WINAPI Persist_AddRef(IPersist *iface)
466
{
467
return 2;
468
}
469
470
static ULONG WINAPI Persist_Release(IPersist *iface)
471
{
472
return 1;
473
}
474
475
static HRESULT WINAPI Persist_GetClassID(IPersist *iface, CLSID *pClassID)
476
{
477
*pClassID = persist_clsid;
478
return S_OK;
479
}
480
481
static const IPersistVtbl PersistVtbl = {
482
Persist_QueryInterface,
483
Persist_AddRef,
484
Persist_Release,
485
Persist_GetClassID
486
};
487
488
static IPersist Persist = { &PersistVtbl };
489
490
static HRESULT WINAPI ProvideClassInfo2_QueryInterface(IProvideClassInfo2 *iface, REFIID riid, void **ppv)
491
{
492
ok(0, "unexpected call\n");
493
return E_NOINTERFACE;
494
}
495
496
static ULONG WINAPI ProvideClassInfo2_AddRef(IProvideClassInfo2 *iface)
497
{
498
return 2;
499
}
500
501
static ULONG WINAPI ProvideClassInfo2_Release(IProvideClassInfo2 *iface)
502
{
503
return 1;
504
}
505
506
static HRESULT WINAPI ProvideClassInfo2_GetClassInfo(IProvideClassInfo2 *iface, ITypeInfo **ppTI)
507
{
508
ok(0, "unexpected call\n");
509
return E_NOTIMPL;
510
}
511
512
static HRESULT WINAPI ProvideClassInfo2_GetGUID(IProvideClassInfo2 *iface, DWORD dwGuidKind, GUID *pGUID)
513
{
514
ok(dwGuidKind == GUIDKIND_DEFAULT_SOURCE_DISP_IID, "unexpected dwGuidKind %lx\n", dwGuidKind);
515
*pGUID = DIID_DispHTMLBody;
516
return S_OK;
517
}
518
519
static const IProvideClassInfo2Vtbl ProvideClassInfo2Vtbl = {
520
ProvideClassInfo2_QueryInterface,
521
ProvideClassInfo2_AddRef,
522
ProvideClassInfo2_Release,
523
ProvideClassInfo2_GetClassInfo,
524
ProvideClassInfo2_GetGUID
525
};
526
527
static IProvideClassInfo2 ProvideClassInfo2 = { &ProvideClassInfo2Vtbl };
528
static BOOL support_classinfo2;
529
530
static HRESULT WINAPI Dispatch_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
531
{
532
*ppv = NULL;
533
534
if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IDispatch, riid)) {
535
*ppv = iface;
536
return S_OK;
537
}
538
539
if(IsEqualGUID(&IID_IProvideClassInfo2, riid)) {
540
if(!support_classinfo2)
541
return E_NOINTERFACE;
542
*ppv = &ProvideClassInfo2;
543
return S_OK;
544
}
545
546
if(IsEqualGUID(&IID_IPersist, riid)) {
547
*ppv = &Persist;
548
return S_OK;
549
}
550
551
ok(0, "unexpected riid: %s\n", wine_dbgstr_guid(riid));
552
return E_NOINTERFACE;
553
}
554
555
static ULONG WINAPI Dispatch_AddRef(IDispatch *iface)
556
{
557
return 2;
558
}
559
560
static ULONG WINAPI Dispatch_Release(IDispatch *iface)
561
{
562
return 1;
563
}
564
565
static HRESULT WINAPI Dispatch_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
566
{
567
ok(0, "unexpected call\n");
568
return E_NOTIMPL;
569
}
570
571
static HRESULT WINAPI Dispatch_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid,
572
ITypeInfo **ppTInfo)
573
{
574
ITypeLib *typelib;
575
HRESULT hres;
576
577
ok(!iTInfo, "iTInfo = %d\n", iTInfo);
578
ok(!lcid, "lcid = %lx\n", lcid);
579
580
hres = LoadTypeLib(L"mshtml.tlb", &typelib);
581
ok(hres == S_OK, "LoadTypeLib failed: %08lx\n", hres);
582
583
hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IHTMLElement, ppTInfo);
584
ok(hres == S_OK, "GetTypeInfoOfGuid failed: %08lx\n", hres);
585
586
ITypeLib_Release(typelib);
587
return S_OK;
588
}
589
590
static HRESULT WINAPI Dispatch_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames,
591
UINT cNames, LCID lcid, DISPID *rgDispId)
592
{
593
ok(0, "unexpected call\n");
594
return E_NOTIMPL;
595
}
596
597
static HRESULT WINAPI Dispatch_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid,
598
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
599
EXCEPINFO *pExcepInfo, UINT *puArgErr)
600
{
601
ok(0, "unexpected call\n");
602
return E_NOTIMPL;
603
}
604
605
static const IDispatchVtbl DispatchVtbl = {
606
Dispatch_QueryInterface,
607
Dispatch_AddRef,
608
Dispatch_Release,
609
Dispatch_GetTypeInfoCount,
610
Dispatch_GetTypeInfo,
611
Dispatch_GetIDsOfNames,
612
Dispatch_Invoke
613
};
614
615
static IDispatch Dispatch = { &DispatchVtbl };
616
617
static void test_source_iface(void)
618
{
619
unsigned short maj_ver, min_ver;
620
IID libid, iid;
621
HRESULT hres;
622
623
support_classinfo2 = TRUE;
624
625
maj_ver = min_ver = 0xdead;
626
hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
627
ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08lx\n", hres);
628
ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
629
ok(IsEqualGUID(&iid, &DIID_DispHTMLBody), "iid = %s\n", wine_dbgstr_guid(&iid));
630
ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
631
632
support_classinfo2 = FALSE;
633
persist_clsid = CLSID_HTMLDocument;
634
635
maj_ver = min_ver = 0xdead;
636
hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
637
ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08lx\n", hres);
638
ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
639
ok(IsEqualGUID(&iid, &DIID_HTMLDocumentEvents), "iid = %s\n", wine_dbgstr_guid(&iid));
640
ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
641
642
persist_clsid = CLSID_HTMLStyle;
643
644
maj_ver = min_ver = 0xdead;
645
hres = AtlGetObjectSourceInterface((IUnknown*)&Dispatch, &libid, &iid, &maj_ver, &min_ver);
646
ok(hres == S_OK, "AtlGetObjectSourceInterface failed: %08lx\n", hres);
647
ok(IsEqualGUID(&libid, &LIBID_MSHTML), "libid = %s\n", wine_dbgstr_guid(&libid));
648
ok(IsEqualGUID(&iid, &IID_NULL), "iid = %s\n", wine_dbgstr_guid(&iid));
649
ok(maj_ver == 4 && min_ver == 0, "ver = %d.%d\n", maj_ver, min_ver);
650
}
651
652
static void test_ax_win(void)
653
{
654
DWORD ret, ret_size, i;
655
HRESULT res;
656
HWND hwnd;
657
HANDLE hfile;
658
IUnknown *control;
659
WNDPROC wndproc[2] = {NULL, NULL};
660
WCHAR file_uri1W[MAX_PATH], pathW[MAX_PATH];
661
WNDCLASSEXW wcex;
662
static HMODULE hinstance = 0;
663
static const WCHAR cls_names[][16] =
664
{
665
L"AtlAxWin100",
666
L"AtlAxWinLic100"
667
};
668
669
ret = AtlAxWinInit();
670
ok(ret, "AtlAxWinInit failed\n");
671
672
hinstance = GetModuleHandleA(NULL);
673
674
for (i = 0; i < 2; i++)
675
{
676
memset(&wcex, 0, sizeof(wcex));
677
wcex.cbSize = sizeof(wcex);
678
ret = GetClassInfoExW(hinstance, cls_names[i], &wcex);
679
ok(ret, "%s has not registered\n", wine_dbgstr_w(cls_names[i]));
680
ok(wcex.style == (CS_GLOBALCLASS | CS_DBLCLKS), "wcex.style %08x\n", wcex.style);
681
wndproc[i] = wcex.lpfnWndProc;
682
683
hwnd = CreateWindowW(cls_names[i], NULL, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
684
ok(hwnd != NULL, "CreateWindow failed!\n");
685
control = (IUnknown *)0xdeadbeef;
686
res = AtlAxGetControl(hwnd, &control);
687
ok(res == E_FAIL, "Expected E_FAIL, returned %08lx\n", res);
688
ok(!control, "returned %p\n", control);
689
if (control) IUnknown_Release(control);
690
DestroyWindow(hwnd);
691
692
hwnd = CreateWindowW(cls_names[i], L"", 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
693
ok(hwnd != NULL, "CreateWindow failed!\n");
694
control = (IUnknown *)0xdeadbeef;
695
res = AtlAxGetControl(hwnd, &control);
696
ok(res == E_FAIL, "Expected E_FAIL, returned %08lx\n", res);
697
ok(!control, "returned %p\n", control);
698
if (control) IUnknown_Release(control);
699
DestroyWindow(hwnd);
700
701
hwnd = CreateWindowW(cls_names[i], L"random", 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
702
todo_wine ok(!hwnd, "returned %p\n", hwnd);
703
if(hwnd) DestroyWindow(hwnd);
704
705
hwnd = CreateWindowW(cls_names[i], progid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
706
ok(hwnd != NULL, "CreateWindow failed!\n");
707
control = NULL;
708
res = AtlAxGetControl(hwnd, &control);
709
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
710
ok(control != NULL, "AtlAxGetControl failed!\n");
711
IUnknown_Release(control);
712
DestroyWindow(hwnd);
713
714
hwnd = CreateWindowW(cls_names[i], clsid1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
715
ok(hwnd != NULL, "CreateWindow failed!\n");
716
control = NULL;
717
res = AtlAxGetControl(hwnd, &control);
718
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
719
ok(control != NULL, "AtlAxGetControl failed!\n");
720
IUnknown_Release(control);
721
DestroyWindow(hwnd);
722
723
hwnd = CreateWindowW(cls_names[i], url1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
724
ok(hwnd != NULL, "CreateWindow failed!\n");
725
control = NULL;
726
res = AtlAxGetControl(hwnd, &control);
727
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
728
ok(control != NULL, "AtlAxGetControl failed!\n");
729
IUnknown_Release(control);
730
DestroyWindow(hwnd);
731
732
/* test html stream with "MSHTML:" prefix */
733
hwnd = CreateWindowW(cls_names[i], mshtml1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
734
ok(hwnd != NULL, "CreateWindow failed!\n");
735
control = NULL;
736
res = AtlAxGetControl(hwnd, &control);
737
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
738
ok(control != NULL, "AtlAxGetControl failed!\n");
739
IUnknown_Release(control);
740
DestroyWindow(hwnd);
741
742
hwnd = CreateWindowW(cls_names[i], mshtml2W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
743
ok(hwnd != NULL, "CreateWindow failed!\n");
744
control = NULL;
745
res = AtlAxGetControl(hwnd, &control);
746
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
747
ok(control != NULL, "AtlAxGetControl failed!\n");
748
IUnknown_Release(control);
749
DestroyWindow(hwnd);
750
751
/* test html stream without "MSHTML:" prefix */
752
hwnd = CreateWindowW(cls_names[i], mshtml3W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
753
todo_wine ok(!hwnd, "returned %p\n", hwnd);
754
if(hwnd) DestroyWindow(hwnd);
755
756
ret = GetTempPathW(MAX_PATH, pathW);
757
ok(ret, "GetTempPath failed!\n");
758
lstrcatW(pathW, L"test.html");
759
hfile = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
760
ok(hfile != INVALID_HANDLE_VALUE, "failed to create file\n");
761
ret = WriteFile(hfile, html_str, sizeof(html_str), &ret_size, NULL);
762
ok(ret, "WriteFile failed\n");
763
CloseHandle(hfile);
764
765
/* test C:// scheme */
766
hwnd = CreateWindowW(cls_names[i], pathW, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
767
ok(hwnd != NULL, "CreateWindow failed!\n");
768
control = NULL;
769
res = AtlAxGetControl(hwnd, &control);
770
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
771
ok(control != NULL, "AtlAxGetControl failed!\n");
772
IUnknown_Release(control);
773
DestroyWindow(hwnd);
774
775
/* test file:// scheme */
776
lstrcpyW(file_uri1W, L"file:///");
777
lstrcatW(file_uri1W, pathW);
778
hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
779
ok(hwnd != NULL, "CreateWindow failed!\n");
780
control = NULL;
781
res = AtlAxGetControl(hwnd, &control);
782
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
783
ok(control != NULL, "AtlAxGetControl failed!\n");
784
IUnknown_Release(control);
785
DestroyWindow(hwnd);
786
787
/* test file:// scheme on non-existent file */
788
ret = DeleteFileW(pathW);
789
ok(ret, "DeleteFile failed (gle=%lu)\n", GetLastError());
790
hwnd = CreateWindowW(cls_names[i], file_uri1W, 0, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
791
ok(hwnd != NULL, "CreateWindow failed!\n");
792
control = NULL;
793
res = AtlAxGetControl(hwnd, &control);
794
ok(res == S_OK, "AtlAxGetControl failed with res %08lx\n", res);
795
ok(control != NULL, "AtlAxGetControl failed!\n");
796
IUnknown_Release(control);
797
DestroyWindow(hwnd);
798
}
799
todo_wine ok(wndproc[0] != wndproc[1], "expected different proc!\n");
800
}
801
802
static ATOM register_class(void)
803
{
804
WNDCLASSA wndclassA;
805
806
wndclassA.style = 0;
807
wndclassA.lpfnWndProc = DefWindowProcA;
808
wndclassA.cbClsExtra = 0;
809
wndclassA.cbWndExtra = 0;
810
wndclassA.hInstance = GetModuleHandleA(NULL);
811
wndclassA.hIcon = NULL;
812
wndclassA.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
813
wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
814
wndclassA.lpszMenuName = NULL;
815
wndclassA.lpszClassName = "WineAtlTestClass";
816
817
return RegisterClassA(&wndclassA);
818
}
819
820
static HWND create_container_window(void)
821
{
822
return CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
823
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
824
CW_USEDEFAULT, NULL, NULL, NULL, NULL);
825
}
826
827
static void test_AtlAxAttachControl(void)
828
{
829
HWND hwnd;
830
HRESULT hr;
831
IUnknown *control, *container;
832
LONG val;
833
834
hr = AtlAxAttachControl(NULL, NULL, NULL);
835
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
836
837
container = (IUnknown *)0xdeadbeef;
838
hr = AtlAxAttachControl(NULL, NULL, &container);
839
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
840
ok(container == (IUnknown *)0xdeadbeef,
841
"Expected the output container pointer to be untouched, got %p\n", container);
842
843
hwnd = create_container_window();
844
hr = AtlAxAttachControl(NULL, hwnd, NULL);
845
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
846
DestroyWindow(hwnd);
847
848
hwnd = create_container_window();
849
container = (IUnknown *)0xdeadbeef;
850
hr = AtlAxAttachControl(NULL, hwnd, &container);
851
ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08lx\n", hr);
852
ok(container == (IUnknown *)0xdeadbeef, "returned %p\n", container);
853
DestroyWindow(hwnd);
854
855
hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
856
&IID_IOleObject, (void **)&control);
857
ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08lx\n", hr);
858
859
if (FAILED(hr))
860
{
861
skip("Couldn't obtain a test IOleObject instance\n");
862
return;
863
}
864
865
hr = AtlAxAttachControl(control, NULL, NULL);
866
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08lx\n", hr);
867
868
container = NULL;
869
hr = AtlAxAttachControl(control, NULL, &container);
870
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08lx\n", hr);
871
ok(container != NULL, "got %p\n", container);
872
IUnknown_Release(container);
873
874
hwnd = create_container_window();
875
SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);
876
hr = AtlAxAttachControl(control, hwnd, NULL);
877
ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08lx\n", hr);
878
val = GetWindowLongW(hwnd, GWLP_USERDATA);
879
ok(val == 0xdeadbeef, "returned %08lx\n", val);
880
DestroyWindow(hwnd);
881
882
hwnd = create_container_window();
883
SetWindowLongW(hwnd, GWLP_USERDATA, 0xdeadbeef);
884
container = NULL;
885
hr = AtlAxAttachControl(control, hwnd, &container);
886
ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08lx\n", hr);
887
ok(container != NULL, "Expected not NULL!\n");
888
IUnknown_Release(container);
889
val = GetWindowLongW(hwnd, GWLP_USERDATA);
890
ok(val == 0xdeadbeef, "Expected unchanged, returned %08lx\n", val);
891
DestroyWindow(hwnd);
892
893
IUnknown_Release(control);
894
}
895
896
static void test_AtlAxCreateControl(void)
897
{
898
HWND hwnd;
899
IUnknown *control, *container;
900
HRESULT hr;
901
DWORD ret, ret_size;
902
HANDLE hfile;
903
WCHAR file_uri1W[MAX_PATH], pathW[MAX_PATH];
904
905
container = NULL;
906
control = (IUnknown *)0xdeadbeef;
907
hr = AtlAxCreateControlEx(NULL, NULL, NULL, &container, &control, NULL, NULL);
908
todo_wine ok(hr == S_FALSE, "got 0x%08lx\n", hr);
909
todo_wine ok(container != NULL, "returned %p\n", container);
910
ok(!control, "returned %p\n", control);
911
912
container = NULL;
913
control = (IUnknown *)0xdeadbeef;
914
hwnd = create_container_window();
915
ok(hwnd != NULL, "create window failed!\n");
916
hr = AtlAxCreateControlEx(NULL, hwnd, NULL, &container, &control, &IID_NULL, NULL);
917
ok(hr == S_OK, "got 0x%08lx\n", hr);
918
todo_wine ok(container != NULL, "returned %p!\n", container);
919
ok(!control, "returned %p\n", control);
920
DestroyWindow(hwnd);
921
922
container = NULL;
923
control = (IUnknown *)0xdeadbeef;
924
hwnd = create_container_window();
925
ok(hwnd != NULL, "create window failed!\n");
926
hr = AtlAxCreateControlEx(L"", hwnd, NULL, &container, &control, &IID_NULL, NULL);
927
ok(hr == S_OK, "got 0x%08lx\n", hr);
928
todo_wine ok(container != NULL, "returned %p!\n", container);
929
ok(!control, "returned %p\n", control);
930
DestroyWindow(hwnd);
931
932
container = (IUnknown *)0xdeadbeef;
933
control = (IUnknown *)0xdeadbeef;
934
hwnd = create_container_window();
935
ok(hwnd != NULL, "create window failed!\n");
936
hr = AtlAxCreateControlEx(L"random", hwnd, NULL, &container, &control, &IID_NULL, NULL);
937
ok(hr == CO_E_CLASSSTRING, "got 0x%08lx\n", hr);
938
ok(!container, "returned %p!\n", container);
939
ok(!control, "returned %p\n", control);
940
DestroyWindow(hwnd);
941
942
container = NULL;
943
control = NULL;
944
hwnd = create_container_window();
945
ok(hwnd != NULL, "create window failed!\n");
946
hr = AtlAxCreateControlEx(progid1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
947
ok(hr == S_OK, "got 0x%08lx\n", hr);
948
ok(container != NULL, "returned %p!\n", container);
949
ok(control != NULL, "returned %p\n", control);
950
IUnknown_Release(container);
951
IUnknown_Release(control);
952
DestroyWindow(hwnd);
953
954
container = NULL;
955
control = NULL;
956
hwnd = create_container_window();
957
ok(hwnd != NULL, "create window failed!\n");
958
hr = AtlAxCreateControlEx(clsid1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
959
ok(hr == S_OK, "got 0x%08lx\n", hr);
960
ok(container != NULL, "returned %p!\n", container);
961
ok(control != NULL, "returned %p\n", control);
962
IUnknown_Release(container);
963
IUnknown_Release(control);
964
DestroyWindow(hwnd);
965
966
container = NULL;
967
control = NULL;
968
hwnd = create_container_window();
969
ok(hwnd != NULL, "create window failed!\n");
970
hr = AtlAxCreateControlEx(url1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
971
ok(hr == S_OK, "got 0x%08lx\n", hr);
972
ok(container != NULL, "returned %p!\n", container);
973
ok(control != NULL, "returned %p\n", control);
974
IUnknown_Release(container);
975
IUnknown_Release(control);
976
DestroyWindow(hwnd);
977
978
container = NULL;
979
control = NULL;
980
hwnd = create_container_window();
981
ok(hwnd != NULL, "create window failed!\n");
982
hr = AtlAxCreateControlEx(mshtml1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
983
ok(hr == S_OK, "got 0x%08lx\n", hr);
984
ok(container != NULL, "returned %p!\n", container);
985
ok(control != NULL, "returned %p\n", control);
986
IUnknown_Release(container);
987
IUnknown_Release(control);
988
DestroyWindow(hwnd);
989
990
container = NULL;
991
control = NULL;
992
hwnd = create_container_window();
993
ok(hwnd != NULL, "create window failed!\n");
994
hr = AtlAxCreateControlEx(mshtml2W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
995
ok(hr == S_OK, "got 0x%08lx\n", hr);
996
ok(container != NULL, "returned %p!\n", container);
997
ok(control != NULL, "returned %p\n", control);
998
IUnknown_Release(container);
999
IUnknown_Release(control);
1000
DestroyWindow(hwnd);
1001
1002
container = (IUnknown *)0xdeadbeef;
1003
control = (IUnknown *)0xdeadbeef;
1004
hwnd = create_container_window();
1005
ok(hwnd != NULL, "create window failed!\n");
1006
hr = AtlAxCreateControlEx(mshtml3W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1007
ok(hr == CO_E_CLASSSTRING, "got 0x%08lx\n", hr);
1008
ok(!container, "returned %p!\n", container);
1009
ok(!control, "returned %p\n", control);
1010
DestroyWindow(hwnd);
1011
1012
ret = GetTempPathW(MAX_PATH, pathW);
1013
ok(ret, "GetTempPath failed!\n");
1014
lstrcatW(pathW, L"test.html");
1015
hfile = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
1016
ok(hfile != INVALID_HANDLE_VALUE, "failed to create file\n");
1017
ret = WriteFile(hfile, html_str, sizeof(html_str), &ret_size, NULL);
1018
ok(ret, "WriteFile failed\n");
1019
CloseHandle(hfile);
1020
1021
/* test C:// scheme */
1022
container = NULL;
1023
control = NULL;
1024
hwnd = create_container_window();
1025
ok(hwnd != NULL, "create window failed!\n");
1026
hr = AtlAxCreateControlEx(pathW, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1027
ok(hr == S_OK, "got 0x%08lx\n", hr);
1028
ok(container != NULL, "returned %p!\n", container);
1029
ok(control != NULL, "returned %p\n", control);
1030
IUnknown_Release(container);
1031
IUnknown_Release(control);
1032
DestroyWindow(hwnd);
1033
1034
/* test file:// scheme */
1035
lstrcpyW(file_uri1W, L"file:///");
1036
lstrcatW(file_uri1W, pathW);
1037
container = NULL;
1038
control = NULL;
1039
hwnd = create_container_window();
1040
ok(hwnd != NULL, "create window failed!\n");
1041
hr = AtlAxCreateControlEx(file_uri1W, hwnd, NULL, &container, &control, &IID_NULL, NULL);
1042
ok(hr == S_OK, "got 0x%08lx\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);
1048
1049
/* test file:// scheme on non-existent file. */
1050
ret = DeleteFileW(pathW);
1051
ok(ret, "DeleteFile failed (gle=%lu)\n", GetLastError());
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%08lx\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);
1063
}
1064
1065
static void test_AtlComModuleGetClassObject(void)
1066
{
1067
_ATL_OBJMAP_ENTRY *null_entry = NULL;
1068
_ATL_COM_MODULE module;
1069
HRESULT hr;
1070
void *ret;
1071
1072
/* Test NULL module */
1073
hr = AtlComModuleGetClassObject(NULL, &GUID_NULL, &IID_NULL, &ret);
1074
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1075
1076
/* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
1077
module.cbSize = sizeof(module);
1078
module.m_ppAutoObjMapFirst = NULL;
1079
module.m_ppAutoObjMapLast = NULL;
1080
hr = AtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
1081
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
1082
1083
/* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
1084
module.cbSize = sizeof(module);
1085
module.m_ppAutoObjMapFirst = &null_entry;
1086
module.m_ppAutoObjMapLast = &null_entry;
1087
hr = AtlComModuleGetClassObject(&module, &GUID_NULL, &IID_NULL, &ret);
1088
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
1089
}
1090
1091
static void test_AtlComModuleRegisterClassObjects(void)
1092
{
1093
_ATL_OBJMAP_ENTRY *null_entry = NULL;
1094
_ATL_COM_MODULE module;
1095
HRESULT hr;
1096
1097
/* Test NULL module */
1098
hr = AtlComModuleRegisterClassObjects(NULL, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
1099
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1100
1101
/* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
1102
module.cbSize = sizeof(module);
1103
module.m_ppAutoObjMapFirst = NULL;
1104
module.m_ppAutoObjMapLast = NULL;
1105
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
1106
todo_wine_if(hr == S_OK)
1107
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
1108
1109
/* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
1110
module.cbSize = sizeof(module);
1111
module.m_ppAutoObjMapFirst = &null_entry;
1112
module.m_ppAutoObjMapLast = &null_entry;
1113
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
1114
todo_wine_if(hr == S_OK)
1115
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
1116
}
1117
1118
static void test_AtlComModuleRevokeClassObjects(void)
1119
{
1120
_ATL_OBJMAP_ENTRY *null_entry = NULL;
1121
_ATL_COM_MODULE module;
1122
HRESULT hr;
1123
1124
/* Test NULL module */
1125
hr = AtlComModuleRevokeClassObjects(NULL);
1126
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
1127
1128
/* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
1129
module.cbSize = sizeof(module);
1130
module.m_ppAutoObjMapFirst = NULL;
1131
module.m_ppAutoObjMapLast = NULL;
1132
hr = AtlComModuleRevokeClassObjects(&module);
1133
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1134
1135
/* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
1136
module.cbSize = sizeof(module);
1137
module.m_ppAutoObjMapFirst = &null_entry;
1138
module.m_ppAutoObjMapLast = &null_entry;
1139
hr = AtlComModuleRevokeClassObjects(&module);
1140
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
1141
}
1142
1143
START_TEST(atl)
1144
{
1145
if (!register_class())
1146
return;
1147
1148
CoInitialize(NULL);
1149
1150
test_winmodule();
1151
test_regcat();
1152
test_typelib();
1153
test_cp();
1154
test_source_iface();
1155
test_ax_win();
1156
test_AtlAxAttachControl();
1157
test_AtlAxCreateControl();
1158
test_AtlComModuleGetClassObject();
1159
test_AtlComModuleRegisterClassObjects();
1160
test_AtlComModuleRevokeClassObjects();
1161
1162
CoUninitialize();
1163
}
1164
1165