2010-08-24 13:54:10 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for AddFontResource
|
|
|
|
* PROGRAMMERS: Timo Kreuzer
|
|
|
|
*/
|
|
|
|
|
2017-12-02 20:00:06 +00:00
|
|
|
#include "precomp.h"
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
#define COUNT 26
|
|
|
|
|
|
|
|
void Test_AddFontResourceA()
|
|
|
|
{
|
2021-07-10 14:04:16 +00:00
|
|
|
CHAR szCurrentDir[MAX_PATH];
|
|
|
|
CHAR szFileNameFont1[MAX_PATH];
|
|
|
|
CHAR szFileNameFont2[MAX_PATH];
|
|
|
|
CHAR szFileName[MAX_PATH*2 + 3];
|
2010-08-24 13:54:10 +00:00
|
|
|
int result;
|
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
GetCurrentDirectoryA(MAX_PATH, szCurrentDir);
|
2010-08-24 13:54:10 +00:00
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.ttf", szCurrentDir);
|
|
|
|
snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.otf", szCurrentDir);
|
2010-08-24 13:54:10 +00:00
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
//RtlZeroMemory(szFileNameA, sizeof(szFileNameA));
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
/* Testing NULL pointer */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
result = AddFontResourceA(NULL);
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing -1 pointer */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
result = AddFontResourceA((CHAR*)-1);
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing address 1 pointer */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
result = AddFontResourceA((CHAR*)1);
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing address empty string */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
result = AddFontResourceA("");
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing one ttf font */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2021-07-10 14:04:16 +00:00
|
|
|
result = AddFontResourceA(szFileNameFont1);
|
|
|
|
ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1, result);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
2021-07-10 14:04:16 +00:00
|
|
|
RemoveFontResourceA(szFileNameFont1);
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
/* Testing one otf font */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2021-07-10 14:04:16 +00:00
|
|
|
result = AddFontResourceA(szFileNameFont2);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(result == 1, "AddFontResourceA failed, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
2021-07-10 14:04:16 +00:00
|
|
|
RemoveFontResourceA(szFileNameFont2);
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
/* Testing two fonts */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s|%s",szFileNameFont1, szFileNameFont2);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s |%s",szFileNameFont1, szFileNameFont2);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s | %s",szFileNameFont1, szFileNameFont2);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
|
2011-10-13 12:52:25 +00:00
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.pfm", szCurrentDir);
|
|
|
|
snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.pfb", szCurrentDir);
|
2011-10-13 12:52:25 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s|%s", szFileNameFont1, szFileNameFont2);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n",
|
2021-07-10 14:04:16 +00:00
|
|
|
szFileNameFont1, szFileNameFont2, result);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
2021-07-10 14:04:16 +00:00
|
|
|
RemoveFontResourceA(szFileName);
|
2011-10-13 12:52:25 +00:00
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s | %s", szFileNameFont1, szFileNameFont2);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n",
|
2021-07-10 14:04:16 +00:00
|
|
|
szFileNameFont1, szFileNameFont2, result);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
|
2021-07-10 14:04:16 +00:00
|
|
|
RemoveFontResourceA(szFileName);
|
2011-10-13 12:52:25 +00:00
|
|
|
|
2021-07-10 14:04:16 +00:00
|
|
|
sprintf(szFileName,"%s|%s", szFileNameFont2, szFileNameFont1);
|
|
|
|
result = AddFontResourceA(szFileName);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n",
|
2021-07-10 14:04:16 +00:00
|
|
|
szFileNameFont2, szFileNameFont1, result);
|
2011-10-13 12:52:25 +00:00
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
|
2010-08-24 13:54:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(AddFontResource)
|
|
|
|
{
|
|
|
|
Test_AddFontResourceA();
|
|
|
|
}
|
|
|
|
|