diff --git a/dlls/atl/tests/module.c b/dlls/atl/tests/module.c index ffa62ad0afa..45cff060062 100644 --- a/dlls/atl/tests/module.c +++ b/dlls/atl/tests/module.c @@ -58,7 +58,63 @@ static void test_StructSize(void) 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"); +} + START_TEST(module) { test_StructSize(); + test_winmodule(); }