Hugh McMaster : kernel32/tests: Add tests for SetCurrentConsoleFontEx.

Alexandre Julliard julliard at winehq.org
Tue Aug 17 16:26:53 CDT 2021


Module: wine
Branch: master
Commit: ec25eeab4c18d9697bbd6ad1822368aa6330cc2f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ec25eeab4c18d9697bbd6ad1822368aa6330cc2f

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Tue Aug 17 22:11:11 2021 +1000

kernel32/tests: Add tests for SetCurrentConsoleFontEx.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/console.c | 117 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 759a0572b13..3003ff63f5a 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3536,6 +3536,122 @@ 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)
+{
+    CONSOLE_FONT_INFOEX orig_cfix, cfix;
+    BOOL ret;
+    HANDLE pipe1, pipe2;
+    HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
+
+    orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
+
+    ret = GetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    cfix = orig_cfix;
+    cfix.cbSize = 0;
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(NULL, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(NULL, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    CreatePipe(&pipe1, &pipe2, NULL, 0);
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(pipe1, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    CloseHandle(pipe1);
+    CloseHandle(pipe2);
+
+    CreatePipe(&pipe1, &pipe2, NULL, 0);
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(pipe1, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+    CloseHandle(pipe1);
+    CloseHandle(pipe2);
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_input, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_input, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_output, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_output, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    cfix = orig_cfix;
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(NULL, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(NULL, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    CreatePipe(&pipe1, &pipe2, NULL, 0);
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(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 = SetCurrentConsoleFontEx(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 = SetCurrentConsoleFontEx(std_input, FALSE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_input, TRUE, &cfix);
+    ok(!ret, "got %d, expected 0\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(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 = SetCurrentConsoleFontEx(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 = SetCurrentConsoleFontEx(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;
@@ -4692,6 +4808,7 @@ START_TEST(console)
     {
         test_GetCurrentConsoleFont(hConOut);
         test_GetCurrentConsoleFontEx(hConOut);
+        test_SetCurrentConsoleFontEx(hConOut);
         test_GetConsoleFontSize(hConOut);
         test_GetLargestConsoleWindowSize(hConOut);
         test_GetConsoleFontInfo(hConOut);




More information about the wine-cvs mailing list