Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- dlls/kernel32/tests/console.c | 149 ++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index bd5cad428bc..2097e8e53d3 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3536,6 +3536,154 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output) ok(cfix.dwFontSize.Y == cfi.dwFontSize.Y, "expected values to match\n"); }
+static void test_SetCurrentConsoleFontEx(HANDLE std_output) +{ + HANDLE hmod; + BOOL (WINAPI *pGetCurrentConsoleFontEx)(HANDLE, BOOL, CONSOLE_FONT_INFOEX *); + BOOL (WINAPI *pSetCurrentConsoleFontEx)(HANDLE, BOOL, CONSOLE_FONT_INFOEX *); + CONSOLE_FONT_INFOEX orig_cfix, cfix; + BOOL ret; + HANDLE pipe1, pipe2; + HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE); + + hmod = GetModuleHandleA("kernel32.dll"); + pGetCurrentConsoleFontEx = (void *)GetProcAddress(hmod, "GetCurrentConsoleFontEx"); + pSetCurrentConsoleFontEx = (void *)GetProcAddress(hmod, "SetCurrentConsoleFontEx"); + + if (!pGetCurrentConsoleFontEx || !pSetCurrentConsoleFontEx) + { + win_skip("GetCurrentConsoleFontEx and SetCurrentConsoleFontEx are not available\n"); + return; + } + + orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX); + + ret = pGetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix); + ok(ret, "got %d, expected non-zero\n", ret); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(NULL, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(NULL, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + CreatePipe(&pipe1, &pipe2, NULL, 0); + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(pipe1, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + CloseHandle(pipe1); + CloseHandle(pipe2); + + CreatePipe(&pipe1, &pipe2, NULL, 0); + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(pipe1, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + CloseHandle(pipe1); + CloseHandle(pipe2); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_input, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_input, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_output, FALSE, &cfix); + ok(!ret || broken(ret), "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER || + broken(GetLastError() == 0xdeadbeef), "got %u, expected 87\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_output, TRUE, &cfix); + ok(!ret || broken(ret), "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER || + broken(GetLastError() == 0xdeadbeef), "got %u, expected 87\n", GetLastError()); + + cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(NULL, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(NULL, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + CreatePipe(&pipe1, &pipe2, NULL, 0); + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(pipe1, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError()); + CloseHandle(pipe1); + CloseHandle(pipe2); + + CreatePipe(&pipe1, &pipe2, NULL, 0); + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(pipe1, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError()); + CloseHandle(pipe1); + CloseHandle(pipe2); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_input, FALSE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_input, TRUE, &cfix); + ok(!ret, "got %d, expected 0\n", ret); + todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER /* 32-bit */ || + GetLastError() == ERROR_INVALID_HANDLE /* 64-bit */, + "got %u, expected 87 (32-bit) or 6 (64-bit)\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_output, FALSE, &cfix); + todo_wine ok(ret, "got %d, expected non-zero\n", ret); + todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_output, TRUE, &cfix); + todo_wine ok(ret, "got %d, expected non-zero\n", ret); + todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError()); + + /* Restore original console font parameters */ + SetLastError(0xdeadbeef); + ret = pSetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix); + todo_wine ok(ret, "got %d, expected non-zero\n", ret); + todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError()); +} + static void test_GetConsoleFontSize(HANDLE std_output) { COORD c; @@ -4688,6 +4836,7 @@ START_TEST(console) { test_GetCurrentConsoleFont(hConOut); test_GetCurrentConsoleFontEx(hConOut); + test_SetCurrentConsoleFontEx(hConOut); test_GetConsoleFontSize(hConOut); test_GetLargestConsoleWindowSize(hConOut); test_GetConsoleFontInfo(hConOut);