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
29 #include <wine/test.h>
32 static void test_StructSize(void)
38 tst
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, MAXSIZE
);
40 for (i
=0;i
<MAXSIZE
;i
++) {
42 hres
= AtlModuleInit(tst
, NULL
, NULL
);
45 case FIELD_OFFSET(_ATL_MODULEW
, dwAtlBuildVer
):
46 case sizeof(_ATL_MODULEW
):
48 case sizeof(_ATL_MODULEW
) + sizeof(void *):
50 ok (hres
== S_OK
, "AtlModuleInit with %d failed (0x%x).\n", i
, (int)hres
);
53 ok (FAILED(hres
), "AtlModuleInit with %d succeeded? (0x%x).\n", i
, (int)hres
);
58 HeapFree (GetProcessHeap(), 0, tst
);
61 static void test_winmodule(void)
63 _AtlCreateWndData create_data
[3];
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");
118 static void WINAPI
term_callback(DWORD dw
)
123 static void test_term(void)
128 test
.cbSize
= sizeof(_ATL_MODULEW
);
130 hres
= AtlModuleInit(&test
, NULL
, NULL
);
131 ok (hres
== S_OK
, "AtlModuleInit failed (0x%x).\n", (int)hres
);
133 hres
= AtlModuleAddTermFunc(&test
, term_callback
, 0x22);
134 ok (hres
== S_OK
, "AtlModuleAddTermFunc failed (0x%x).\n", (int)hres
);
137 hres
= AtlModuleTerm(&test
);
138 ok (hres
== S_OK
, "AtlModuleTerm failed (0x%x).\n", (int)hres
);
139 ok (cb_val
== 0x22, "wrong callback value (0x%x).\n", (int)cb_val
);
141 test
.cbSize
= FIELD_OFFSET(_ATL_MODULEW
, dwAtlBuildVer
);
143 hres
= AtlModuleInit(&test
, NULL
, NULL
);
144 ok (hres
== S_OK
, "AtlModuleInit failed (0x%x).\n", (int)hres
);
146 hres
= AtlModuleAddTermFunc(&test
, term_callback
, 0x23);
147 ok (hres
== S_OK
, "AtlModuleAddTermFunc failed (0x%x).\n", (int)hres
);
150 hres
= AtlModuleTerm(&test
);
151 ok (hres
== S_OK
, "AtlModuleTerm failed (0x%x).\n", (int)hres
);
152 ok (cb_val
== 0xdeadbeef, "wrong callback value (0x%x).\n", (int)cb_val
);