[PATCH v2 2/2] kernel32/tests: Add SetCurrentConsoleFontEx tests for the maximum window size

Hugh McMaster hugh.mcmaster at outlook.com
Mon Nov 15 06:47:49 CST 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 dlls/kernel32/tests/console.c | 225 +++++++++++++++++++++++++++++++++-
 1 file changed, 223 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 355eb296174..186effa35ad 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3554,24 +3554,30 @@ static void test_GetCurrentConsoleFontEx(HANDLE std_output)
 
 static void test_SetCurrentConsoleFontEx(HANDLE std_output)
 {
-    CONSOLE_FONT_INFOEX orig_cfix, cfix, tmp;
+    CONSOLE_FONT_INFOEX orig_cfix, orig_cfix_max, cfix, tmp;
     BOOL ret;
     HANDLE pipe1, pipe2;
     HANDLE std_input = GetStdHandle(STD_INPUT_HANDLE);
     unsigned int i, cp, font_family;
     const WCHAR *fonts[] = { L"Courier New", L"Liberation Mono" };
     const WCHAR *face_name;
+    CONSOLE_SCREEN_BUFFER_INFO csbi;
 
     font_family = TMPF_VECTOR | TMPF_TRUETYPE | FF_MODERN;
 
     /* Save current console font information */
     cp = GetConsoleOutputCP();
 
-    orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
+    orig_cfix.cbSize = sizeof(orig_cfix);
+    orig_cfix_max.cbSize = sizeof(orig_cfix_max);
 
     ret = GetCurrentConsoleFontEx(std_output, FALSE, &orig_cfix);
     ok(ret, "got %d, expected non-zero\n", ret);
 
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &orig_cfix_max);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    /* Test parameter validity */
     cfix = orig_cfix;
     cfix.cbSize = 0;
 
@@ -3859,9 +3865,224 @@ static void test_SetCurrentConsoleFontEx(HANDLE std_output)
     ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n",
        wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name));
 
+    /* Try setting console font information for the maximum window size (maxwindow = TRUE) */
+    memset(&cfix, 0, sizeof(cfix));
+    cfix.cbSize = sizeof(cfix);
+    cfix.nFont = 0;
+    cfix.dwFontSize.X = 8;
+    cfix.dwFontSize.Y = 16;
+    cfix.FontFamily = font_family;
+    cfix.FontWeight = FW_NORMAL;
+    lstrcpyW(cfix.FaceName, face_name);
+
+    /* Test font size 8x16 */
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.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);
+    ok(!lstrcmpW(tmp.FaceName, cfix.FaceName), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(cfix.FaceName));
+
+    /* Test font size 10x20 */
+    cfix.dwFontSize.X = 10;
+    cfix.dwFontSize.Y = 20;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.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);
+    ok(!lstrcmpW(tmp.FaceName, cfix.FaceName), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(cfix.FaceName));
+
+    /* Test font size 5x12. We pass in 10x12. */
+    cfix.dwFontSize.Y = 12;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.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);
+    ok(!lstrcmpW(tmp.FaceName, cfix.FaceName), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(cfix.FaceName));
+
+    /* Test font size 10x20. Font height is 20. All other metrics are zero. */
+    cfix.dwFontSize.X = 0;
+    cfix.dwFontSize.Y = 20;
+    cfix.FontFamily = 0;
+    cfix.FontWeight = 0;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
+    todo_wine ok(tmp.FontFamily == font_family, "got %u, expected %u\n", tmp.FontFamily, font_family);
+    ok(tmp.FontWeight == FW_NORMAL, "got %u, expected %u\n", tmp.FontWeight, FW_NORMAL);
+    ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name));
+
+    /* Test font size 7x14. We pass in 7x0. */
+    cfix = tmp;
+    cfix.dwFontSize.X = 7;
+    cfix.dwFontSize.Y = 0;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
+    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);
+    ok(!lstrcmpW(tmp.FaceName, cfix.FaceName), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(cfix.FaceName));
+
+    /* Test font size with width and height set to 0x0. */
+    cfix.dwFontSize.X = 0;
+    cfix.dwFontSize.Y = 0;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
+    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);
+    ok(!lstrcmpW(tmp.FaceName, cfix.FaceName), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(cfix.FaceName));
+
+    /* Test with invalid font face name */
+    cfix.dwFontSize.X = 8;
+    cfix.dwFontSize.Y = 16;
+    lstrcpyW(cfix.FaceName, L"MissingFont");
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
+    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);
+    ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name));
+
+    /* Test with no font face name */
+    cfix.FaceName[0] = 0;
+    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());
+
+    ret = GetConsoleScreenBufferInfo(std_output, &csbi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+
+    memset(&tmp, 0, sizeof(tmp));
+    tmp.cbSize = sizeof(tmp);
+    ret = GetCurrentConsoleFontEx(std_output, TRUE, &tmp);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(tmp.nFont == cfix.nFont, "got %u, expected %u\n", tmp.nFont, cfix.nFont);
+    ok(tmp.dwFontSize.X == csbi.dwMaximumWindowSize.X, "got %u, expected %u\n",
+       tmp.dwFontSize.X, csbi.dwMaximumWindowSize.X);
+    ok(tmp.dwFontSize.Y == csbi.dwMaximumWindowSize.Y, "got %u, expected %u\n",
+       tmp.dwFontSize.Y, csbi.dwMaximumWindowSize.Y);
+    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);
+    ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n",
+       wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name));
+
     /* Restore original console font parameters */
     SetConsoleOutputCP(cp);
 
+    SetLastError(0xdeadbeef);
+    ret = SetCurrentConsoleFontEx(std_output, TRUE, &orig_cfix_max);
+    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, FALSE, &orig_cfix);
     todo_wine ok(ret, "got %d, expected non-zero\n", ret);
-- 
2.33.1




More information about the wine-devel mailing list