ReactOS 0.4.15-dev-7961-gdcf9eb0
module.c
Go to the documentation of this file.
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#include <stdarg.h>
23#include <stdio.h>
24
25#define COBJMACROS
26
27#include <wine/atlbase.h>
28#include <wine/atlwin.h>
29
30#include <wine/test.h>
31
32#define MAXSIZE 512
33static void test_StructSize(void)
34{
35 _ATL_MODULEW *tst;
37 int i;
38
40
41 for (i=0;i<MAXSIZE;i++) {
42 tst->cbSize = i;
43 hres = AtlModuleInit(tst, NULL, NULL);
44
45 switch (i) {
46 case FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer):
47 case sizeof(_ATL_MODULEW):
48#ifdef _WIN64
49 case sizeof(_ATL_MODULEW) + sizeof(void *):
50#endif
51 ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
52 break;
53 default:
54 ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
55 break;
56 }
57 }
58
59 HeapFree (GetProcessHeap(), 0, tst);
60}
61
62static void test_winmodule(void)
63{
64 _AtlCreateWndData create_data[3];
65 _ATL_MODULEW winmod;
66 void *p;
68
69 winmod.cbSize = sizeof(winmod);
70 winmod.m_pCreateWndList = (void*)0xdeadbeef;
71 winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
72 hres = AtlModuleInit(&winmod, NULL, NULL);
73 ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
74 ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
75 ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %d\n",
77
78 AtlModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
79 ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
80 ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
81 ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %x\n",
82 create_data[0].m_dwThreadID);
83 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
84
85 AtlModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
86 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
87 ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
88 ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %x\n",
89 create_data[1].m_dwThreadID);
90 ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
91
92 AtlModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
93 ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
94 ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
95 ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %x\n",
96 create_data[2].m_dwThreadID);
97 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
98
100 ok(p == (void*)0xdead0003, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
101 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
102 ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
103
104 create_data[1].m_dwThreadID = 0xdeadbeef;
105
107 ok(p == (void*)0xdead0001, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
108 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
109 ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
110 ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
111
113 ok(!p, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
114 ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
115}
116
117static void test_winclassinfo(void)
118{
119 _ATL_MODULEW winmod;
121 int len, expectedLen;
122 ATOM atom;
125 {
126 /* .m_wc = */
127 {
128 sizeof(WNDCLASSEXW),
131 0,
132 0,
133 NULL,
134 NULL,
136 (HBRUSH)(COLOR_BTNFACE + 1),
137 NULL,
138 NULL, /* LPCSTR lpszClassName; <-- We force ATL class name generation */
139 NULL
140 },
141 /* .m_lpszOrigName = */ NULL,
142 /* .pWndProc = */ NULL,
143 /* .m_lpszCursorID = */ (LPCWSTR)IDC_ARROW,
144 /* .m_bSystemCursor = */ TRUE,
145 /* .m_atom = */ 0,
146 /* .m_szAutoName = */ L""
147 };
148
149 winmod.cbSize = sizeof(winmod);
150 winmod.m_pCreateWndList = (void*)0xdeadbeef;
151 hres = AtlModuleInit(&winmod, NULL, NULL);
152 ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
153 ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
154
155 atom = AtlModuleRegisterWndClassInfoW(&winmod, &wci, &wndProc);
156 ok(atom, "AtlModuleRegisterWndClassInfoA failed: %08x\n", atom);
157 ok(atom == wci.m_atom, "(atom = %08x) is != than (wci.m_atom = %08x)\n", atom, wci.m_atom);
158
159 ok(wcsncmp(wci.m_szAutoName, L"ATL:", 4) == 0, "wci.m_szAutoName = '%ls', expected starting with 'ATL:'\n", wci.m_szAutoName);
160
161 len = wcslen(wci.m_szAutoName);
162 expectedLen = sizeof("ATL:") + sizeof(void *) * 2 - 1;
163 ok(len == expectedLen, "wci.m_szAutoName has length %d, expected length %d\n", len, expectedLen);
164}
165
167
169{
170 cb_val = dw;
171}
172
173static void test_term(void)
174{
178
179 ex = (ULONG_PTR)-37;
180
181 test.cbSize = sizeof(_ATL_MODULEW);
182
184 ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", hres);
185
187 ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", hres);
188
189 cb_val = 0xdeadbeef;
191 ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", hres);
192 ok (cb_val == ex, "wrong callback value (0x%lx).\n", cb_val);
193
194 test.cbSize = FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer);
195
197 ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", hres);
198
200 ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", hres);
201
202 cb_val = 0xdeadbeef;
204 ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", hres);
205 ok (cb_val == 0xdeadbeef, "wrong callback value (0x%lx).\n", cb_val);
206}
207
209{
213 test_term();
214}
HRESULT WINAPI AtlModuleTerm(_ATL_MODULE *pM)
Definition: atl30.c:112
ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW *wci, WNDPROC *pProc)
Definition: atl30.c:357
void *WINAPI AtlModuleExtractCreateWndData(_ATL_MODULEW *pM)
Definition: atl30.c:425
HRESULT WINAPI AtlModuleInit(_ATL_MODULEW *pM, _ATL_OBJMAP_ENTRYW *p, HINSTANCE h)
Definition: atl30.c:39
void WINAPI AtlModuleAddCreateWndData(_ATL_MODULEW *pM, _AtlCreateWndData *pData, void *pvObject)
Definition: atl30.c:405
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULE *pM, _ATL_TERMFUNC *pFunc, DWORD_PTR dw)
Definition: atl.c:297
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define ULONG_PTR
Definition: config.h:101
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static LRESULT WINAPI wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: imm32.c:185
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
struct _ATL_MODULEW_TAG _ATL_MODULEW
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
static DWORD_PTR cb_val
Definition: module.c:166
#define MAXSIZE
Definition: module.c:32
static void test_StructSize(void)
Definition: module.c:33
static void WINAPI term_callback(DWORD_PTR dw)
Definition: module.c:168
static void test_winmodule(void)
Definition: module.c:62
static void test_winclassinfo(void)
Definition: module.c:117
static void test_term(void)
Definition: module.c:173
HRESULT hres
Definition: protocol.c:465
#define L(x)
Definition: ntvdm.h:50
#define test
Definition: rosglue.h:37
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
CRITICAL_SECTION m_csWindowCreate
Definition: atlbase.h:170
_AtlCreateWndData * m_pCreateWndList
Definition: atlbase.h:174
WCHAR m_szAutoName[sizeof("ATL:")+sizeof(void *) *2]
Definition: atlwin.h:43
Definition: comerr.c:44
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define WINAPI
Definition: msvc.h:6
#define CS_VREDRAW
Definition: winuser.h:658
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
struct _WNDCLASSEXW WNDCLASSEXW
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define COLOR_BTNFACE
Definition: winuser.h:928
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185