2010-06-15 11:04:33 +02:00
|
|
|
/*
|
|
|
|
* ATL test program
|
|
|
|
*
|
|
|
|
* Copyright 2010 Marcus Meissner
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
#include <atlbase.h>
|
2020-01-15 02:09:33 +01:00
|
|
|
#include <atlwin.h>
|
2010-06-15 11:04:33 +02:00
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
#include <wine/test.h>
|
2010-06-15 11:04:33 +02:00
|
|
|
|
|
|
|
#define MAXSIZE 512
|
|
|
|
static void test_StructSize(void)
|
|
|
|
{
|
2012-12-26 13:49:50 +01:00
|
|
|
_ATL_MODULEW *tst;
|
|
|
|
HRESULT hres;
|
|
|
|
int i;
|
2010-06-15 11:04:33 +02:00
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
tst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAXSIZE);
|
2010-06-15 11:04:33 +02:00
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
for (i=0;i<MAXSIZE;i++) {
|
|
|
|
tst->cbSize = i;
|
|
|
|
hres = AtlModuleInit(tst, NULL, NULL);
|
2010-06-15 11:04:33 +02:00
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
switch (i) {
|
|
|
|
case FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer):
|
|
|
|
case sizeof(_ATL_MODULEW):
|
2010-06-15 11:04:33 +02:00
|
|
|
#ifdef _WIN64
|
2012-12-26 13:49:50 +01:00
|
|
|
case sizeof(_ATL_MODULEW) + sizeof(void *):
|
2010-06-15 11:04:33 +02:00
|
|
|
#endif
|
2012-12-26 13:49:50 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-09-19 17:18:25 +02:00
|
|
|
|
2012-12-26 13:49:50 +01:00
|
|
|
HeapFree (GetProcessHeap(), 0, tst);
|
2010-06-15 11:04:33 +02:00
|
|
|
}
|
|
|
|
|
2012-12-26 13:50:11 +01:00
|
|
|
static void test_winmodule(void)
|
|
|
|
{
|
|
|
|
_AtlCreateWndData create_data[3];
|
|
|
|
_ATL_MODULEW winmod;
|
|
|
|
void *p;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
winmod.cbSize = sizeof(winmod);
|
|
|
|
winmod.m_pCreateWndList = (void*)0xdeadbeef;
|
|
|
|
winmod.m_csWindowCreate.LockCount = 0xdeadbeef;
|
|
|
|
hres = AtlModuleInit(&winmod, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
|
|
|
|
ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
|
|
|
|
ok(winmod.m_csWindowCreate.LockCount == -1, "winmod.m_csWindowCreate.LockCount = %d\n",
|
|
|
|
winmod.m_csWindowCreate.LockCount);
|
|
|
|
|
|
|
|
AtlModuleAddCreateWndData(&winmod, create_data, (void*)0xdead0001);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
ok(create_data[0].m_pThis == (void*)0xdead0001, "unexpected create_data[0].m_pThis %p\n", create_data[0].m_pThis);
|
|
|
|
ok(create_data[0].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[0].m_dwThreadID %x\n",
|
|
|
|
create_data[0].m_dwThreadID);
|
|
|
|
ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
|
|
|
|
|
|
|
|
AtlModuleAddCreateWndData(&winmod, create_data+1, (void*)0xdead0002);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
ok(create_data[1].m_pThis == (void*)0xdead0002, "unexpected create_data[1].m_pThis %p\n", create_data[1].m_pThis);
|
|
|
|
ok(create_data[1].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[1].m_dwThreadID %x\n",
|
|
|
|
create_data[1].m_dwThreadID);
|
|
|
|
ok(create_data[1].m_pNext == create_data, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
|
|
|
|
|
|
|
|
AtlModuleAddCreateWndData(&winmod, create_data+2, (void*)0xdead0003);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data+2, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
ok(create_data[2].m_pThis == (void*)0xdead0003, "unexpected create_data[2].m_pThis %p\n", create_data[2].m_pThis);
|
|
|
|
ok(create_data[2].m_dwThreadID == GetCurrentThreadId(), "unexpected create_data[2].m_dwThreadID %x\n",
|
|
|
|
create_data[2].m_dwThreadID);
|
|
|
|
ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
|
|
|
|
|
|
|
|
p = AtlModuleExtractCreateWndData(&winmod);
|
|
|
|
ok(p == (void*)0xdead0003, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
ok(create_data[2].m_pNext == create_data+1, "unexpected create_data[2].m_pNext %p\n", create_data[2].m_pNext);
|
|
|
|
|
|
|
|
create_data[1].m_dwThreadID = 0xdeadbeef;
|
|
|
|
|
|
|
|
p = AtlModuleExtractCreateWndData(&winmod);
|
|
|
|
ok(p == (void*)0xdead0001, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
ok(!create_data[0].m_pNext, "unexpected create_data[0].m_pNext %p\n", create_data[0].m_pNext);
|
|
|
|
ok(!create_data[1].m_pNext, "unexpected create_data[1].m_pNext %p\n", create_data[1].m_pNext);
|
|
|
|
|
|
|
|
p = AtlModuleExtractCreateWndData(&winmod);
|
|
|
|
ok(!p, "unexpected AtlModuleExtractCreateWndData result %p\n", p);
|
|
|
|
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
|
|
|
|
}
|
|
|
|
|
2020-01-15 02:09:33 +01:00
|
|
|
static void test_winclassinfo(void)
|
|
|
|
{
|
|
|
|
_ATL_MODULEW winmod;
|
|
|
|
HRESULT hres;
|
|
|
|
int len, expectedLen;
|
|
|
|
ATOM atom;
|
|
|
|
WNDPROC wndProc;
|
|
|
|
_ATL_WNDCLASSINFOW wci =
|
|
|
|
{
|
|
|
|
/* .m_wc = */
|
|
|
|
{
|
|
|
|
sizeof(WNDCLASSEXW),
|
|
|
|
CS_VREDRAW | CS_HREDRAW,
|
|
|
|
DefWindowProcW,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
LoadCursorW(NULL, (LPCWSTR)IDC_ARROW),
|
|
|
|
(HBRUSH)(COLOR_BTNFACE + 1),
|
|
|
|
NULL,
|
|
|
|
NULL, /* LPCSTR lpszClassName; <-- We force ATL class name generation */
|
|
|
|
NULL
|
|
|
|
},
|
|
|
|
/* .m_lpszOrigName = */ NULL,
|
|
|
|
/* .pWndProc = */ NULL,
|
|
|
|
/* .m_lpszCursorID = */ (LPCWSTR)IDC_ARROW,
|
|
|
|
/* .m_bSystemCursor = */ TRUE,
|
|
|
|
/* .m_atom = */ 0,
|
|
|
|
/* .m_szAutoName = */ L""
|
|
|
|
};
|
|
|
|
|
|
|
|
winmod.cbSize = sizeof(winmod);
|
|
|
|
winmod.m_pCreateWndList = (void*)0xdeadbeef;
|
|
|
|
hres = AtlModuleInit(&winmod, NULL, NULL);
|
|
|
|
ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
|
|
|
|
ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
|
|
|
|
|
|
|
|
atom = AtlModuleRegisterWndClassInfoW(&winmod, &wci, &wndProc);
|
|
|
|
ok(atom, "AtlModuleRegisterWndClassInfoA failed: %08x\n", atom);
|
|
|
|
ok(atom == wci.m_atom, "(atom = %08x) is != than (wci.m_atom = %08x)\n", atom, wci.m_atom);
|
|
|
|
|
|
|
|
ok(wcsncmp(wci.m_szAutoName, L"ATL:", 4) == 0, "wci.m_szAutoName = '%ls', expected starting with 'ATL:'\n", wci.m_szAutoName);
|
|
|
|
|
|
|
|
len = wcslen(wci.m_szAutoName);
|
|
|
|
expectedLen = sizeof("ATL:") + sizeof(void *) * 2 - 1;
|
|
|
|
ok(len == expectedLen, "wci.m_szAutoName has length %d, expected length %d\n", len, expectedLen);
|
|
|
|
}
|
|
|
|
|
2020-02-03 22:06:49 +01:00
|
|
|
static DWORD_PTR cb_val;
|
2013-07-25 22:13:24 +02:00
|
|
|
|
2020-02-03 22:06:49 +01:00
|
|
|
static void WINAPI term_callback(DWORD_PTR dw)
|
2013-07-25 22:13:24 +02:00
|
|
|
{
|
|
|
|
cb_val = dw;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_term(void)
|
|
|
|
{
|
|
|
|
_ATL_MODULEW test;
|
2020-02-03 22:06:49 +01:00
|
|
|
ULONG_PTR ex;
|
2013-07-25 22:13:24 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2020-02-03 22:06:49 +01:00
|
|
|
ex = (ULONG_PTR)-37;
|
|
|
|
|
2013-07-25 22:13:24 +02:00
|
|
|
test.cbSize = sizeof(_ATL_MODULEW);
|
|
|
|
|
|
|
|
hres = AtlModuleInit(&test, NULL, NULL);
|
2020-02-03 22:06:49 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", hres);
|
2013-07-25 22:13:24 +02:00
|
|
|
|
2020-02-03 22:06:49 +01:00
|
|
|
hres = AtlModuleAddTermFunc(&test, term_callback, ex);
|
|
|
|
ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", hres);
|
2013-07-25 22:13:24 +02:00
|
|
|
|
|
|
|
cb_val = 0xdeadbeef;
|
|
|
|
hres = AtlModuleTerm(&test);
|
2020-02-03 22:06:49 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", hres);
|
|
|
|
ok (cb_val == ex, "wrong callback value (0x%lx).\n", cb_val);
|
2013-07-25 22:13:24 +02:00
|
|
|
|
|
|
|
test.cbSize = FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer);
|
|
|
|
|
|
|
|
hres = AtlModuleInit(&test, NULL, NULL);
|
2020-02-03 22:06:49 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", hres);
|
2013-07-25 22:13:24 +02:00
|
|
|
|
|
|
|
hres = AtlModuleAddTermFunc(&test, term_callback, 0x23);
|
2020-02-03 22:06:49 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", hres);
|
2013-07-25 22:13:24 +02:00
|
|
|
|
|
|
|
cb_val = 0xdeadbeef;
|
|
|
|
hres = AtlModuleTerm(&test);
|
2020-02-03 22:06:49 +01:00
|
|
|
ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", hres);
|
|
|
|
ok (cb_val == 0xdeadbeef, "wrong callback value (0x%lx).\n", cb_val);
|
2013-07-25 22:13:24 +02:00
|
|
|
}
|
|
|
|
|
2010-06-15 11:04:33 +02:00
|
|
|
START_TEST(module)
|
|
|
|
{
|
2012-12-26 13:49:50 +01:00
|
|
|
test_StructSize();
|
2012-12-26 13:50:11 +01:00
|
|
|
test_winmodule();
|
2020-01-15 02:09:33 +01:00
|
|
|
test_winclassinfo();
|
2013-07-25 22:13:24 +02:00
|
|
|
test_term();
|
2010-06-15 11:04:33 +02:00
|
|
|
}
|