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