1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:         ReactOS api tests
3c2c66affSColin Finck  * LICENSE:         GPL - See COPYING in the top level directory
4c2c66affSColin Finck  * PURPOSE:         Test for AddFontResourceEx
5c2c66affSColin Finck  * PROGRAMMERS:     Timo Kreuzer
6c2c66affSColin Finck  */
7c2c66affSColin Finck 
8aee83c35SAmine Khaldi #include "precomp.h"
9c2c66affSColin Finck 
10*e470b583SJérôme Gardou #include <pseh/pseh2.h>
11*e470b583SJérôme Gardou 
Test_AddFontResourceExW()12c2c66affSColin Finck void Test_AddFontResourceExW()
13c2c66affSColin Finck {
14c2c66affSColin Finck 	WCHAR szFileName[MAX_PATH];
15c2c66affSColin Finck 	int result;
16c2c66affSColin Finck 
17c2c66affSColin Finck 	/* Test NULL filename */
18c2c66affSColin Finck 	SetLastError(ERROR_SUCCESS);
19c2c66affSColin Finck 
20c2c66affSColin Finck 	/* Windows crashes, need SEH here */
21c2c66affSColin Finck 	_SEH2_TRY
22c2c66affSColin Finck 	{
23c2c66affSColin Finck     	result = AddFontResourceExW(NULL, 0, 0);
24c2c66affSColin Finck 	}
25c2c66affSColin Finck 	_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
26c2c66affSColin Finck 	{
27c2c66affSColin Finck 	    result = -1;
28c2c66affSColin Finck 	    SetLastError(_SEH2_GetExceptionCode());
29c2c66affSColin Finck 	}
30c2c66affSColin Finck 	_SEH2_END
31c2c66affSColin Finck 	ok(result == -1, "AddFontResourceExW should throw an exception!, result == %d\n", result);
32c2c66affSColin Finck 	ok(GetLastError() == 0xc0000005, "GetLastError()==%lx\n", GetLastError());
33c2c66affSColin Finck 
34c2c66affSColin Finck 	/* Test "" filename */
35c2c66affSColin Finck 	SetLastError(ERROR_SUCCESS);
36c2c66affSColin Finck 	result = AddFontResourceExW(L"", 0, 0);
37c2c66affSColin Finck 	ok(result == 0, "AddFontResourceExW(L"", 0, 0) succeeded, result==%d\n", result);
38c2c66affSColin Finck 	ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
39c2c66affSColin Finck 
40c2c66affSColin Finck 	GetEnvironmentVariableW(L"systemroot", szFileName, MAX_PATH);
41c2c66affSColin Finck 	wcscat(szFileName, L"\\Fonts\\cour.ttf");
42c2c66affSColin Finck 
43c2c66affSColin Finck 	/* Test flags = 0 */
44c2c66affSColin Finck 	SetLastError(ERROR_SUCCESS);
45c2c66affSColin Finck 	result = AddFontResourceExW(szFileName, 0, 0);
46c2c66affSColin Finck 	ok(result == 1, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
47c2c66affSColin Finck 	ok(GetLastError() == ERROR_SUCCESS, "GetLastError()==%ld\n", GetLastError());
48c2c66affSColin Finck 
49c2c66affSColin Finck 	SetLastError(ERROR_SUCCESS);
50c2c66affSColin Finck 	result = AddFontResourceExW(szFileName, 256, 0);
51c2c66affSColin Finck 	ok(result == 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
52c2c66affSColin Finck 	ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
53c2c66affSColin Finck 
54c2c66affSColin Finck 	/* Test invalid pointer as last parameter */
55c2c66affSColin Finck 	result = AddFontResourceExW(szFileName, 0, (void*)-1);
56c2c66affSColin Finck 	ok(result != 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result);
57c2c66affSColin Finck 	ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError());
58c2c66affSColin Finck 
59c2c66affSColin Finck }
60c2c66affSColin Finck 
START_TEST(AddFontResourceEx)61c2c66affSColin Finck START_TEST(AddFontResourceEx)
62c2c66affSColin Finck {
63c2c66affSColin Finck     Test_AddFontResourceExW();
64c2c66affSColin Finck }
65c2c66affSColin Finck 
66