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
|
|
|
|
*/
|
|
|
|
|
2013-09-23 21:54:01 +00:00
|
|
|
#include <stdio.h>
|
2013-09-22 17:52:42 +00:00
|
|
|
#include <apitest.h>
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
#define COUNT 26
|
|
|
|
|
|
|
|
void Test_AddFontResourceA()
|
|
|
|
{
|
|
|
|
CHAR szFileNameA[MAX_PATH];
|
|
|
|
CHAR szFileNameFont1A[MAX_PATH];
|
|
|
|
CHAR szFileNameFont2A[MAX_PATH];
|
|
|
|
int result;
|
|
|
|
|
2015-08-08 08:31:49 +00:00
|
|
|
GetWindowsDirectoryA(szFileNameA,MAX_PATH);
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
memcpy(szFileNameFont1A,szFileNameA,MAX_PATH );
|
2015-08-07 17:40:55 +00:00
|
|
|
strcat(szFileNameFont1A, "\\bin\\testdata\\test.ttf");
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
memcpy(szFileNameFont2A,szFileNameA,MAX_PATH );
|
2015-08-07 17:40:55 +00:00
|
|
|
strcat(szFileNameFont2A, "\\bin\\testdata\\test.otf");
|
2010-08-24 13:54:10 +00:00
|
|
|
|
|
|
|
RtlZeroMemory(szFileNameA,MAX_PATH);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start testing Ansi version
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
result = AddFontResourceA(szFileNameFont1A);
|
|
|
|
ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1A, result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing one otf font */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
result = AddFontResourceA(szFileNameFont2A);
|
|
|
|
ok(result == 1, "AddFontResourceA failed, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
/* Testing two fonts */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
sprintf(szFileNameA,"%s|%s",szFileNameFont1A, szFileNameFont2A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
sprintf(szFileNameA,"%s |%s",szFileNameFont1A, szFileNameFont2A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
sprintf(szFileNameA,"%s | %s",szFileNameFont1A, szFileNameFont2A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
GetCurrentDirectoryA(MAX_PATH, szFileNameA);
|
|
|
|
strcpy(szFileNameFont1A, szFileNameA);
|
2015-08-07 17:40:55 +00:00
|
|
|
strcat(szFileNameFont1A, "\\bin\\testdata\\test.pfm");
|
2011-10-13 12:52:25 +00:00
|
|
|
|
|
|
|
strcpy(szFileNameFont2A, szFileNameA);
|
2015-08-07 17:40:55 +00:00
|
|
|
strcat(szFileNameFont2A, "\\bin\\testdata\\test.pfb");
|
2011-10-13 12:52:25 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
|
|
|
|
sprintf(szFileNameA,"%s|%s", szFileNameFont1A, szFileNameFont2A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n",
|
|
|
|
szFileNameFont1A, szFileNameFont2A, result);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
sprintf(szFileNameA,"%s | %s", szFileNameFont1A, szFileNameFont2A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n",
|
|
|
|
szFileNameFont1A, szFileNameFont2A, result);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
sprintf(szFileNameA,"%s|%s", szFileNameFont2A, szFileNameFont1A);
|
|
|
|
result = AddFontResourceA(szFileNameA);
|
|
|
|
ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n",
|
|
|
|
szFileNameFont2A, szFileNameFont1A, result);
|
|
|
|
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError());
|
|
|
|
|
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(AddFontResource)
|
|
|
|
{
|
|
|
|
Test_AddFontResourceA();
|
|
|
|
}
|
|
|
|
|