Release 1.6-rc2.
[wine/testsucceed.git] / dlls / atl / tests / module.c
blob45cff06006224e3fbc10b4debb4f625c423c5d23
1 /*
2 * ATL test program
4 * Copyright 2010 Marcus Meissner
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.
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.
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
22 #include <stdarg.h>
23 #include <stdio.h>
25 #define COBJMACROS
27 #include <atlbase.h>
29 #include <wine/test.h>
31 #define MAXSIZE 512
32 static void test_StructSize(void)
34 _ATL_MODULEW *tst;
35 HRESULT hres;
36 int i;
38 tst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAXSIZE);
40 for (i=0;i<MAXSIZE;i++) {
41 tst->cbSize = i;
42 hres = AtlModuleInit(tst, NULL, NULL);
44 switch (i) {
45 case FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer):
46 case sizeof(_ATL_MODULEW):
47 #ifdef _WIN64
48 case sizeof(_ATL_MODULEW) + sizeof(void *):
49 #endif
50 ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
51 break;
52 default:
53 ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
54 break;
58 HeapFree (GetProcessHeap(), 0, tst);
61 static void test_winmodule(void)
63 _AtlCreateWndData create_data[3];
64 _ATL_MODULEW winmod;
65 void *p;
66 HRESULT hres;
68 winmod.cbSize = sizeof(winmod);
69 winmod.m_pCreateWndList = (void*)0xdeadbeef;
70 winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
71 hres = AtlModuleInit(&winmod, NULL, NULL);
72 ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
73 ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
74 ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %d\n",
75 winmod.m_csWindowCreate.LockCount);
77 AtlModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
78 ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
79 ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
80 ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %x\n",
81 create_data[0].m_dwThreadID);
82 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
84 AtlModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
85 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
86 ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
87 ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %x\n",
88 create_data[1].m_dwThreadID);
89 ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
91 AtlModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
92 ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
93 ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
94 ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %x\n",
95 create_data[2].m_dwThreadID);
96 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
98 p = AtlModuleExtractCreateWndData(&winmod);
99 ok(p == (void*)0xdead0003, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
100 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
101 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
103 create_data[1].m_dwThreadID = 0xdeadbeef;
105 p = AtlModuleExtractCreateWndData(&winmod);
106 ok(p == (void*)0xdead0001, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
107 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
108 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
109 ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
111 p = AtlModuleExtractCreateWndData(&winmod);
112 ok(!p, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
113 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
116 START_TEST(module)
118 test_StructSize();
119 test_winmodule();