[PATCH v2] kernel32/tests: Add tests for SetCurrentConsoleFontEx

Hugh McMaster hugh.mcmaster at outlook.com
Fri Jan 28 06:40:07 CST 2022


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
Changes in this version:
  - Simplify tests.
  - Verify font size change with GetConsoleFontSize instead of
    calculating manually.
 dlls/kernel32/tests/console.c | 69 ++++++++++++++++++++++++++++++++++-
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index e4d9d43f4c4..9766e5c9fa2 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3560,10 +3560,11 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
 
 static void test_SetCurrentConsoleFontEx(HANDLE std_output)
 {
-    CONSOLE_FONT_INFOEX orig_cfix, cfix;
+    CONSOLE_FONT_INFOEX orig_cfix, cfix, tmp;
     BOOL ret;
     HANDLE pipe1, pipe2;
     HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
+    COORD c;
 
     orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
 
@@ -3657,16 +3658,80 @@ static void test_SetCurrentConsoleFontEx(HANDLE std_output)
     ok(!ret, "got %d, expected 0\n", ret);
     todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
 
+    /* Try setting console font information for the current window size */
+    cfix.cbSize = sizeof(cfix);
+    cfix.nFont = 0;
+    cfix.dwFontSize.X = 0;
+    cfix.FontFamily = TMPF_VECTOR | TMPF_TRUETYPE | FF_MODERN;
+    cfix.FontWeight = FW_NORMAL;
+    lstrcpyW(cfix.FaceName, L"Lucida Console");
+
+    tmp.cbSize = sizeof(tmp);
+
+    /* Test font height 20 */
+    cfix.dwFontSize.Y = 20;
     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());
 
+    ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp);
+    ok(ret, "GetCurrentConsoleFontEx failed: %u\n", GetLastError());
+    todo_wine ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %d, expected %d\n",
+       tmp.dwFontSize.Y, cfix.dwFontSize.Y);
+    c = GetConsoleFontSize(std_output, tmp.nFont);
+    todo_wine ok(c.Y == cfix.dwFontSize.Y, "got %d, expected %d\n", c.Y, cfix.dwFontSize.Y);
+    todo_wine ok(tmp.FontFamily == cfix.FontFamily, "got %u, expected %u\n", tmp.FontFamily, cfix.FontFamily);
+    ok(tmp.FontWeight == cfix.FontWeight, "got %u, expected %u\n", tmp.FontWeight, cfix.FontWeight);
+
+    /* Test font height 16 */
+    cfix.dwFontSize.Y = 16;
     SetLastError(0xdeadbeef);
-    ret = SetCurrentConsoleFontEx(std_output, TRUE, &cfix);
+    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());
+
+    ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp);
+    ok(ret, "GetCurrentConsoleFontEx failed: %u\n", GetLastError());
+    ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %d, expected %d\n",
+       tmp.dwFontSize.Y, cfix.dwFontSize.Y);
+    c = GetConsoleFontSize(std_output, tmp.nFont);
+    ok(c.Y == cfix.dwFontSize.Y, "got %d, expected %d\n", c.Y, cfix.dwFontSize.Y);
+    todo_wine ok(tmp.FontFamily == cfix.FontFamily, "got %u, expected %u\n", tmp.FontFamily, cfix.FontFamily);
+    ok(tmp.FontWeight == cfix.FontWeight, "got %u, expected %u\n", tmp.FontWeight, cfix.FontWeight);
+
+    /* Test invalid font height */
+    cfix.dwFontSize.Y = 0;
+    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());
+
+    ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp);
+    ok(ret, "GetCurrentConsoleFontEx failed: %u\n", GetLastError());
+    todo_wine ok(tmp.dwFontSize.Y == 12, "got %d, expected 12\n", tmp.dwFontSize.Y);
+    c = GetConsoleFontSize(std_output, tmp.nFont);
+    todo_wine ok(c.Y == 12, "got %d, expected 12\n", c.Y);
+    todo_wine ok(tmp.FontFamily == cfix.FontFamily, "got %u, expected %u\n", tmp.FontFamily, cfix.FontFamily);
+    ok(tmp.FontWeight == cfix.FontWeight, "got %u, expected %u\n", tmp.FontWeight, cfix.FontWeight);
+
+    /* Test invalid font weight */
+    cfix.dwFontSize.Y = 16;
+    cfix.FontWeight = 0;
+    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());
 
+    ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp);
+    ok(ret, "GetCurrentConsoleFontEx failed: %u\n", GetLastError());
+    ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %d, expected %d\n",
+       tmp.dwFontSize.Y, cfix.dwFontSize.Y);
+    c = GetConsoleFontSize(std_output, tmp.nFont);
+    ok(c.Y == cfix.dwFontSize.Y, "got %d, expected %d\n", c.Y, cfix.dwFontSize.Y);
+    todo_wine ok(tmp.FontFamily == cfix.FontFamily, "got %u, expected %u\n", tmp.FontFamily, cfix.FontFamily);
+    ok(tmp.FontWeight == FW_NORMAL, "got %u, expected %u\n", tmp.FontWeight, FW_NORMAL);
+
     /* Restore original console font parameters */
     SetLastError(0xdeadbeef);
     ret = SetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix);
-- 
2.34.1




More information about the wine-devel mailing list