2007-11-29 12:54:54 +00:00
|
|
|
/*
|
|
|
|
* Unit test suite for MAPI IMalloc functions
|
|
|
|
*
|
|
|
|
* Copyright 2004 Jon Griffiths
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
#include "mapiutil.h"
|
2009-10-20 21:40:20 +00:00
|
|
|
#include "mapi32_test.h"
|
2007-11-29 12:54:54 +00:00
|
|
|
|
|
|
|
static HMODULE hMapi32 = 0;
|
|
|
|
|
|
|
|
static SCODE (WINAPI *pScInitMapiUtil)(ULONG);
|
|
|
|
static LPMALLOC (WINAPI *pMAPIGetDefaultMalloc)(void);
|
|
|
|
|
|
|
|
static void test_IMalloc(void)
|
|
|
|
{
|
|
|
|
LPVOID lpMem;
|
|
|
|
ULONG ulRef;
|
|
|
|
int iRet;
|
|
|
|
HRESULT hRet;
|
|
|
|
LPMALLOC lpMalloc;
|
|
|
|
LPVOID lpVoid;
|
|
|
|
|
|
|
|
pMAPIGetDefaultMalloc = (void*)GetProcAddress(hMapi32,
|
|
|
|
"MAPIGetDefaultMalloc@0");
|
|
|
|
if (!pMAPIGetDefaultMalloc)
|
2010-03-05 18:41:30 +00:00
|
|
|
{
|
|
|
|
win_skip("MAPIGetDefaultMalloc is not available\n");
|
2007-11-29 12:54:54 +00:00
|
|
|
return;
|
2010-03-05 18:41:30 +00:00
|
|
|
}
|
2007-11-29 12:54:54 +00:00
|
|
|
|
|
|
|
lpMalloc = pMAPIGetDefaultMalloc();
|
2010-03-05 18:41:30 +00:00
|
|
|
ok(lpMalloc != NULL, "Expected MAPIGetDefaultMalloc to return non-NULL\n");
|
2007-11-29 12:54:54 +00:00
|
|
|
if (!lpMalloc)
|
2010-03-05 18:41:30 +00:00
|
|
|
{
|
|
|
|
skip("MAPIGetDefaultMalloc failed\n");
|
2007-11-29 12:54:54 +00:00
|
|
|
return;
|
2010-03-05 18:41:30 +00:00
|
|
|
}
|
2007-11-29 12:54:54 +00:00
|
|
|
|
|
|
|
lpVoid = NULL;
|
|
|
|
hRet = IMalloc_QueryInterface(lpMalloc, &IID_IUnknown, &lpVoid);
|
|
|
|
ok (hRet == S_OK && lpVoid != NULL,
|
|
|
|
"IID_IUnknown: expected S_OK, non-null, got 0x%08x, %p\n",
|
|
|
|
hRet, lpVoid);
|
|
|
|
|
|
|
|
lpVoid = NULL;
|
|
|
|
hRet = IMalloc_QueryInterface(lpMalloc, &IID_IMalloc, &lpVoid);
|
|
|
|
ok (hRet == S_OK && lpVoid != NULL,
|
|
|
|
"IID_IIMalloc: expected S_OK, non-null, got 0x%08x, %p\n",
|
|
|
|
hRet, lpVoid);
|
|
|
|
|
|
|
|
/* Prove that native mapi uses LocalAlloc/LocalFree */
|
|
|
|
lpMem = IMalloc_Alloc(lpMalloc, 61);
|
2009-01-18 08:56:17 +00:00
|
|
|
ok (lpMem && IMalloc_GetSize(lpMalloc, lpMem) == LocalSize(lpMem),
|
2007-11-29 12:54:54 +00:00
|
|
|
"Expected non-null, same size, got %p, %s size\n", lpMem,
|
|
|
|
lpMem ? "different" : "same");
|
|
|
|
|
|
|
|
iRet = IMalloc_DidAlloc(lpMalloc, lpMem);
|
|
|
|
ok (iRet == -1, "DidAlloc, expected -1. got %d\n", iRet);
|
|
|
|
|
|
|
|
IMalloc_HeapMinimize(lpMalloc);
|
|
|
|
|
|
|
|
LocalFree(lpMem);
|
|
|
|
|
|
|
|
ulRef = IMalloc_AddRef(lpMalloc);
|
|
|
|
ok (ulRef == 1u, "AddRef expected 1, returned %d\n", ulRef);
|
|
|
|
|
|
|
|
ulRef = IMalloc_Release(lpMalloc);
|
|
|
|
ok (ulRef == 1u, "AddRef expected 1, returned %d\n", ulRef);
|
|
|
|
|
|
|
|
IMalloc_Release(lpMalloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(imalloc)
|
|
|
|
{
|
|
|
|
SCODE ret;
|
|
|
|
|
2009-10-20 21:40:20 +00:00
|
|
|
if (!HaveDefaultMailClient())
|
|
|
|
{
|
|
|
|
win_skip("No default mail client installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-29 12:54:54 +00:00
|
|
|
hMapi32 = LoadLibraryA("mapi32.dll");
|
|
|
|
|
|
|
|
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
|
|
|
|
if (!pScInitMapiUtil)
|
|
|
|
{
|
- Sync winetests with Wine head (comcat, crypt32, gdiplus, lz32, mapi32, mlang, msacm32, mshtml, msvcrt, netapi32, riched20, riched32, rsaenh, schannel, setupapi, shdocvw, urlmon, user32, usp10, uxtheme, version, winhttp, wininet, wintrust, ws2_32)
svn path=/trunk/; revision=39773
2009-02-26 13:26:26 +00:00
|
|
|
win_skip("ScInitMapiUtil is not available\n");
|
2007-11-29 12:54:54 +00:00
|
|
|
FreeLibrary(hMapi32);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pScInitMapiUtil(0);
|
|
|
|
if ((ret != S_OK) && (GetLastError() == ERROR_PROC_NOT_FOUND))
|
|
|
|
{
|
- Sync winetests with Wine head (comcat, crypt32, gdiplus, lz32, mapi32, mlang, msacm32, mshtml, msvcrt, netapi32, riched20, riched32, rsaenh, schannel, setupapi, shdocvw, urlmon, user32, usp10, uxtheme, version, winhttp, wininet, wintrust, ws2_32)
svn path=/trunk/; revision=39773
2009-02-26 13:26:26 +00:00
|
|
|
win_skip("ScInitMapiUtil is not implemented\n");
|
2007-11-29 12:54:54 +00:00
|
|
|
FreeLibrary(hMapi32);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-20 21:40:20 +00:00
|
|
|
else if ((ret == E_FAIL) && (GetLastError() == ERROR_INVALID_HANDLE))
|
|
|
|
{
|
|
|
|
win_skip("ScInitMapiUtil doesn't work on some Win98 and WinME systems\n");
|
|
|
|
FreeLibrary(hMapi32);
|
|
|
|
return;
|
|
|
|
}
|
2007-11-29 12:54:54 +00:00
|
|
|
|
|
|
|
test_IMalloc();
|
|
|
|
|
|
|
|
FreeLibrary(hMapi32);
|
|
|
|
}
|