[ATL_WINETEST]

* Sync with Wine 1.7.17.
CORE-8080

svn path=/trunk/; revision=63008
This commit is contained in:
Amine Khaldi 2014-04-26 18:50:38 +00:00
parent c152cc4698
commit de38ba40d3
4 changed files with 158 additions and 80 deletions

View file

@ -1,3 +1,4 @@
add_definitions(-D_ATL_VER=_ATL_VER_30)
list(APPEND SOURCE
atl_ax.c
@ -8,5 +9,5 @@ list(APPEND SOURCE
add_executable(atl_winetest ${SOURCE})
target_link_libraries(atl_winetest wine uuid)
set_module_type(atl_winetest win32cui)
add_importlibs(atl_winetest ole32 user32 atl msvcrt kernel32 ntdll advapi32)
add_importlibs(atl_winetest ole32 user32 atl advapi32 msvcrt kernel32)
add_cd_file(TARGET atl_winetest DESTINATION reactos/bin FOR all)

View file

@ -40,6 +40,7 @@
//#include <olectl.h>
//#include <ocidl.h>
#include <exdisp.h>
#include <wine/atlbase.h>
static HRESULT (WINAPI *pAtlAxAttachControl)(IUnknown *, HWND, IUnknown **);
@ -55,12 +56,12 @@ static ATOM register_class(void)
WNDCLASSA wndclassA;
wndclassA.style = 0;
wndclassA.lpfnWndProc = DefWindowProc;
wndclassA.lpfnWndProc = DefWindowProcA;
wndclassA.cbClsExtra = 0;
wndclassA.cbWndExtra = 0;
wndclassA.hInstance = GetModuleHandleA(NULL);
wndclassA.hIcon = NULL;
wndclassA.hCursor = LoadCursorA(NULL, IDC_ARROW);
wndclassA.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wndclassA.lpszMenuName = NULL;
wndclassA.lpszClassName = "WineAtlTestClass";
@ -101,15 +102,11 @@ static void test_AtlAxAttachControl(void)
hr = pAtlAxAttachControl(pObj, NULL, NULL);
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
pContainer = (IUnknown *)0xdeadbeef;
pContainer = NULL;
hr = pAtlAxAttachControl(pObj, NULL, &pContainer);
ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
ok(pContainer != (IUnknown *)0xdeadbeef &&
pContainer != NULL,
"Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
IUnknown_Release(pContainer);
ok(pContainer != NULL, "got %p\n", pContainer);
IUnknown_Release(pContainer);
hr = pAtlAxAttachControl(pObj, hwnd, NULL);
ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
@ -119,6 +116,24 @@ static void test_AtlAxAttachControl(void)
DestroyWindow(hwnd);
}
static void test_ax_win(void)
{
BOOL ret;
WNDCLASSEXW wcex;
static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n',0};
static HMODULE hinstance = 0;
ret = AtlAxWinInit();
ok(ret, "AtlAxWinInit failed\n");
hinstance = GetModuleHandleA(NULL);
memset(&wcex, 0, sizeof(wcex));
wcex.cbSize = sizeof(wcex);
ret = GetClassInfoExW(hinstance, AtlAxWin, &wcex);
ok(ret, "AtlAxWin has not registered\n");
ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style);
}
START_TEST(atl_ax)
{
init_function_pointers();
@ -133,5 +148,7 @@ START_TEST(atl_ax)
else
win_skip("AtlAxAttachControl is not available\n");
test_ax_win();
CoUninitialize();
}

View file

@ -29,84 +29,138 @@
#define COBJMACROS
#include <wine/test.h>
//#include <windef.h>
//#include <winbase.h>
//#include <winuser.h>
//#include <wingdi.h>
//#include <winnls.h>
//#include <winerror.h>
//#include <winnt.h>
//#include <wtypes.h>
#include <objbase.h>
//#include <olectl.h>
//#include <ocidl.h>
struct _ATL_OBJMAP_ENTRYW;
struct _AtlCreateWndData;
struct _ATL_TERMFUNC_ELEM;
struct _ATL_MODULEW
{
UINT cbSize;
HINSTANCE m_hInst;
HINSTANCE m_hInstResource;
HINSTANCE m_hInstTypeLib;
struct _ATL_OBJMAP_ENTRYW* m_pObjMap;
LONG m_nLockCnt;
HANDLE m_hHeap;
union
{
CRITICAL_SECTION m_csTypeInfoHolder;
CRITICAL_SECTION m_csStaticDataInit;
} u;
CRITICAL_SECTION m_csWindowCreate;
CRITICAL_SECTION m_csObjMap;
DWORD dwAtlBuildVer;
struct _AtlCreateWndData* m_pCreateWndList;
BOOL m_bDestroyHeap;
GUID* pguidVer;
DWORD m_dwHeaps;
HANDLE* m_phHeaps;
int m_nHeap;
struct _ATL_TERMFUNC_ELEM* m_pTermFuncs;
};
HRESULT WINAPI AtlModuleInit(struct _ATL_MODULEW* pM, struct _ATL_OBJMAP_ENTRYW* p, HINSTANCE h);
#include <wine/atlbase.h>
#define MAXSIZE 512
static void test_StructSize(void)
{
struct _ATL_MODULEW *tst;
HRESULT hres;
int i;
_ATL_MODULEW *tst;
HRESULT hres;
int i;
tst = HeapAlloc (GetProcessHeap(),HEAP_ZERO_MEMORY,MAXSIZE);
tst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MAXSIZE);
for (i=0;i<MAXSIZE;i++) {
tst->cbSize = i;
hres = AtlModuleInit(tst, NULL, NULL);
for (i=0;i<MAXSIZE;i++) {
tst->cbSize = i;
hres = AtlModuleInit(tst, NULL, NULL);
switch (i) {
case FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer ):
case sizeof(struct _ATL_MODULEW):
switch (i) {
case FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer):
case sizeof(_ATL_MODULEW):
#ifdef _WIN64
case sizeof(struct _ATL_MODULEW) + sizeof(void *):
case sizeof(_ATL_MODULEW) + sizeof(void *):
#endif
ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
break;
default:
ok (FAILED(hres) ||
broken((i > FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer )) && (hres == S_OK)), /* Win95 */
"AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
break;
}
}
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;
}
}
HeapFree (GetProcessHeap(), 0, tst);
HeapFree (GetProcessHeap(), 0, tst);
}
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");
}
static DWORD cb_val;
static void WINAPI term_callback(DWORD dw)
{
cb_val = dw;
}
static void test_term(void)
{
_ATL_MODULEW test;
HRESULT hres;
test.cbSize = sizeof(_ATL_MODULEW);
hres = AtlModuleInit(&test, NULL, NULL);
ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", (int)hres);
hres = AtlModuleAddTermFunc(&test, term_callback, 0x22);
ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", (int)hres);
cb_val = 0xdeadbeef;
hres = AtlModuleTerm(&test);
ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", (int)hres);
ok (cb_val == 0x22, "wrong callback value (0x%x).\n", (int)cb_val);
test.cbSize = FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer);
hres = AtlModuleInit(&test, NULL, NULL);
ok (hres == S_OK, "AtlModuleInit failed (0x%x).\n", (int)hres);
hres = AtlModuleAddTermFunc(&test, term_callback, 0x23);
ok (hres == S_OK, "AtlModuleAddTermFunc failed (0x%x).\n", (int)hres);
cb_val = 0xdeadbeef;
hres = AtlModuleTerm(&test);
ok (hres == S_OK, "AtlModuleTerm failed (0x%x).\n", (int)hres);
ok (cb_val == 0xdeadbeef, "wrong callback value (0x%x).\n", (int)cb_val);
}
START_TEST(module)
{
test_StructSize();
test_StructSize();
test_winmodule();
test_term();
}

View file

@ -44,7 +44,7 @@
#include <atliface.h>
static const char textA[] =
"HKCR \n"
"HKCU \n"
"{ \n"
" ForceRemove eebf73c4-50fd-478f-bbcf-db212221227a \n"
" { \n"
@ -74,7 +74,7 @@ static void test_registrar(void)
hr = CoCreateInstance(&CLSID_Registrar, NULL, CLSCTX_INPROC_SERVER, &IID_IRegistrar, (void**)&registrar);
if (FAILED(hr))
{
skip("creating IRegistrar failed, hr = 0x%08X\n", hr);
win_skip("creating IRegistrar failed, hr = 0x%08X\n", hr);
return;
}
@ -90,9 +90,14 @@ static void test_registrar(void)
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count);
hr = IRegistrar_StringRegister(registrar, textW);
ok(SUCCEEDED(hr), "IRegistrar_StringRegister failed, hr = 0x%08X\n", hr);
ok(hr == S_OK, "StringRegister failed: %08x\n", hr);
if (FAILED(hr))
{
IRegistrar_Release(registrar);
return;
}
lret = RegOpenKeyA(HKEY_CLASSES_ROOT, "eebf73c4-50fd-478f-bbcf-db212221227a", &key);
lret = RegOpenKeyA(HKEY_CURRENT_USER, "eebf73c4-50fd-478f-bbcf-db212221227a", &key);
ok(lret == ERROR_SUCCESS, "error %d opening registry key\n", lret);
size = sizeof(dword);
@ -148,8 +153,9 @@ static void test_aggregation(void)
hres = CoCreateInstance(&CLSID_Registrar, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IUnknown, (void**)&unk);
ok(hres == CLASS_E_NOAGGREGATION, "CoCreateInstance failed: %08x, expected CLASS_E_NOAGGREGATION\n", hres);
ok(!unk, "unk = %p\n", unk);
ok(hres == CLASS_E_NOAGGREGATION || broken(hres == E_INVALIDARG),
"CoCreateInstance failed: %08x, expected CLASS_E_NOAGGREGATION\n", hres);
ok(!unk || unk == (IUnknown*)0xdeadbeef, "unk = %p\n", unk);
}
START_TEST(registrar)