8078e4f4f7775012aa565696a4ba778f368595b6
[reactos.git] / rostests / winetests / atl / module.c
1 /*
2 * ATL test program
3 *
4 * Copyright 2010 Marcus Meissner
5 *
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #define WIN32_NO_STATUS
23 #define _INC_WINDOWS
24 #define COM_NO_WINDOWS_H
25
26 //#include <stdarg.h>
27 //#include <stdio.h>
28
29 #define COBJMACROS
30
31 #include <wine/test.h>
32 //#include <windef.h>
33 //#include <winbase.h>
34 //#include <winuser.h>
35 //#include <wingdi.h>
36 //#include <winnls.h>
37 //#include <winerror.h>
38 //#include <winnt.h>
39 //#include <wtypes.h>
40 #include <objbase.h>
41 //#include <olectl.h>
42 //#include <ocidl.h>
43
44 struct _ATL_OBJMAP_ENTRYW;
45 struct _AtlCreateWndData;
46 struct _ATL_TERMFUNC_ELEM;
47
48 struct _ATL_MODULEW
49 {
50 UINT cbSize;
51 HINSTANCE m_hInst;
52 HINSTANCE m_hInstResource;
53 HINSTANCE m_hInstTypeLib;
54 struct _ATL_OBJMAP_ENTRYW* m_pObjMap;
55 LONG m_nLockCnt;
56 HANDLE m_hHeap;
57 union
58 {
59 CRITICAL_SECTION m_csTypeInfoHolder;
60 CRITICAL_SECTION m_csStaticDataInit;
61 } u;
62 CRITICAL_SECTION m_csWindowCreate;
63 CRITICAL_SECTION m_csObjMap;
64
65 DWORD dwAtlBuildVer;
66 struct _AtlCreateWndData* m_pCreateWndList;
67 BOOL m_bDestroyHeap;
68 GUID* pguidVer;
69 DWORD m_dwHeaps;
70 HANDLE* m_phHeaps;
71 int m_nHeap;
72 struct _ATL_TERMFUNC_ELEM* m_pTermFuncs;
73 };
74
75 HRESULT WINAPI AtlModuleInit(struct _ATL_MODULEW* pM, struct _ATL_OBJMAP_ENTRYW* p, HINSTANCE h);
76
77 #define MAXSIZE 512
78 static void test_StructSize(void)
79 {
80 struct _ATL_MODULEW *tst;
81 HRESULT hres;
82 int i;
83
84 tst = HeapAlloc (GetProcessHeap(),HEAP_ZERO_MEMORY,MAXSIZE);
85
86 for (i=0;i<MAXSIZE;i++) {
87 tst->cbSize = i;
88 hres = AtlModuleInit(tst, NULL, NULL);
89
90 switch (i) {
91 case FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer ):
92 case sizeof(struct _ATL_MODULEW):
93 #ifdef _WIN64
94 case sizeof(struct _ATL_MODULEW) + sizeof(void *):
95 #endif
96 ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
97 break;
98 default:
99 ok (FAILED(hres) ||
100 broken((i > FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer )) && (hres == S_OK)), /* Win95 */
101 "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
102 break;
103 }
104 }
105
106 HeapFree (GetProcessHeap(), 0, tst);
107 }
108
109 START_TEST(module)
110 {
111 test_StructSize();
112 }