1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for AddFontResource 5 * PROGRAMMERS: Timo Kreuzer 6 */ 7 8 #include "precomp.h" 9 10 #define COUNT 26 11 12 void Test_AddFontResourceA() 13 { 14 CHAR szCurrentDir[MAX_PATH]; 15 CHAR szFileNameFont1[MAX_PATH]; 16 CHAR szFileNameFont2[MAX_PATH]; 17 CHAR szFileName[MAX_PATH*2 + 3]; 18 int result; 19 20 GetCurrentDirectoryA(MAX_PATH, szCurrentDir); 21 22 snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.ttf", szCurrentDir); 23 snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.otf", szCurrentDir); 24 25 //RtlZeroMemory(szFileNameA, sizeof(szFileNameA)); 26 27 /* Testing NULL pointer */ 28 SetLastError(ERROR_SUCCESS); 29 result = AddFontResourceA(NULL); 30 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 31 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 32 33 /* Testing -1 pointer */ 34 SetLastError(ERROR_SUCCESS); 35 result = AddFontResourceA((CHAR*)-1); 36 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 37 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 38 39 /* Testing address 1 pointer */ 40 SetLastError(ERROR_SUCCESS); 41 result = AddFontResourceA((CHAR*)1); 42 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 43 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 44 45 /* Testing address empty string */ 46 SetLastError(ERROR_SUCCESS); 47 result = AddFontResourceA(""); 48 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 49 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError()); 50 51 /* Testing one ttf font */ 52 SetLastError(ERROR_SUCCESS); 53 result = AddFontResourceA(szFileNameFont1); 54 ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1, result); 55 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 56 RemoveFontResourceA(szFileNameFont1); 57 58 /* Testing one otf font */ 59 SetLastError(ERROR_SUCCESS); 60 result = AddFontResourceA(szFileNameFont2); 61 ok(result == 1, "AddFontResourceA failed, result=%d\n", result); 62 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 63 RemoveFontResourceA(szFileNameFont2); 64 65 /* Testing two fonts */ 66 SetLastError(ERROR_SUCCESS); 67 sprintf(szFileName,"%s|%s",szFileNameFont1, szFileNameFont2); 68 result = AddFontResourceA(szFileName); 69 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 70 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 71 72 SetLastError(ERROR_SUCCESS); 73 sprintf(szFileName,"%s |%s",szFileNameFont1, szFileNameFont2); 74 result = AddFontResourceA(szFileName); 75 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 76 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 77 78 SetLastError(ERROR_SUCCESS); 79 sprintf(szFileName,"%s | %s",szFileNameFont1, szFileNameFont2); 80 result = AddFontResourceA(szFileName); 81 ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); 82 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); 83 84 snprintf(szFileNameFont1, MAX_PATH, "%s\\testdata\\test.pfm", szCurrentDir); 85 snprintf(szFileNameFont2, MAX_PATH, "%s\\testdata\\test.pfb", szCurrentDir); 86 87 SetLastError(ERROR_SUCCESS); 88 89 sprintf(szFileName,"%s|%s", szFileNameFont1, szFileNameFont2); 90 result = AddFontResourceA(szFileName); 91 ok(result == 1, "AddFontResourceA(\"%s|%s\") failed, result=%d\n", 92 szFileNameFont1, szFileNameFont2, result); 93 ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); 94 RemoveFontResourceA(szFileName); 95 96 sprintf(szFileName,"%s | %s", szFileNameFont1, szFileNameFont2); 97 result = AddFontResourceA(szFileName); 98 ok(result == 0, "AddFontResourceA(\"%s | %s\") succeeded, result=%d\n", 99 szFileNameFont1, szFileNameFont2, result); 100 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); 101 RemoveFontResourceA(szFileName); 102 103 sprintf(szFileName,"%s|%s", szFileNameFont2, szFileNameFont1); 104 result = AddFontResourceA(szFileName); 105 ok(result == 0, "AddFontResourceA(\"%s|%s\") succeeded, result=%d\n", 106 szFileNameFont2, szFileNameFont1, result); 107 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); 108 } 109 110 START_TEST(AddFontResource) 111 { 112 Test_AddFontResourceA(); 113 } 114 115