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 #include <pseh/pseh2.h> 11 12 void Test_AddFontResourceExW() 13 { 14 WCHAR szFileName[MAX_PATH]; 15 int result; 16 17 /* Test NULL filename */ 18 SetLastError(ERROR_SUCCESS); 19 20 /* Windows crashes, need SEH here */ 21 _SEH2_TRY 22 { 23 result = AddFontResourceExW(NULL, 0, 0); 24 } 25 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 26 { 27 result = -1; 28 SetLastError(_SEH2_GetExceptionCode()); 29 } 30 _SEH2_END 31 ok(result == -1, "AddFontResourceExW should throw an exception!, result == %d\n", result); 32 ok(GetLastError() == 0xc0000005, "GetLastError()==%lx\n", GetLastError()); 33 34 /* Test "" filename */ 35 SetLastError(ERROR_SUCCESS); 36 result = AddFontResourceExW(L"", 0, 0); 37 ok(result == 0, "AddFontResourceExW(L"", 0, 0) succeeded, result==%d\n", result); 38 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); 39 40 GetEnvironmentVariableW(L"systemroot", szFileName, MAX_PATH); 41 wcscat(szFileName, L"\\Fonts\\cour.ttf"); 42 43 /* Test flags = 0 */ 44 SetLastError(ERROR_SUCCESS); 45 result = AddFontResourceExW(szFileName, 0, 0); 46 ok(result == 1, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); 47 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()==%ld\n", GetLastError()); 48 49 SetLastError(ERROR_SUCCESS); 50 result = AddFontResourceExW(szFileName, 256, 0); 51 ok(result == 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); 52 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); 53 54 /* Test invalid pointer as last parameter */ 55 result = AddFontResourceExW(szFileName, 0, (void*)-1); 56 ok(result != 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); 57 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); 58 59 } 60 61 START_TEST(AddFontResourceEx) 62 { 63 Test_AddFontResourceExW(); 64 } 65 66