Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- Changes in v4: - Use CP_ACP code page due to Wine bug detecting DBCS. - Remove todo_wine. - Add extra tests. dlls/kernel32/tests/console.c | 271 +++++++++++++++++++++++++++++++++- 1 file changed, 269 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 8b5abfa2da9..ad98d9a7fbb 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3554,10 +3554,17 @@ 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); + unsigned int cp, font_family; + WCHAR face_name[] = L"Courier New"; + + font_family = TMPF_VECTOR | TMPF_TRUETYPE | FF_MODERN; + + /* Save current console font information */ + cp = GetConsoleOutputCP();
orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
@@ -3651,17 +3658,277 @@ 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 */ + SetConsoleOutputCP(CP_ACP); + + 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); + + tmp.cbSize = sizeof(tmp); + + /* Courier New is available in the console by default from Windows 10 build 1607 */ + ret = SetCurrentConsoleFontEx(std_output, FALSE, &cfix); + todo_wine ok(ret, "got %d, expected non-zero\n", ret); + + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + if (lstrcmpW(tmp.FaceName, face_name)) + { + SetConsoleOutputCP(cp); + skip("%s not available. Skipping SetCurrentConsoleFontEx tests.\n", wine_dbgstr_w(face_name)); + return; + } + + /* Test font size 8x16 */ 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());
+ memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.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); + 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); + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.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); + 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.X = 10; + cfix.dwFontSize.Y = 12; + + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == 5, "got %u, expected font width of 5\n", tmp.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == 12, "got %u, expected font height of 12\n", tmp.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); + 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. We pass in 0x20. */ + cfix.dwFontSize.X = 0; + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == 10, "got %u, expected font width of 10\n", tmp.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == 20, "got %u, expected font height of 20\n", tmp.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); + ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n", + wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name)); + + /* Test invalid font size 7x0 */ + cfix = tmp; + cfix.dwFontSize.X = 7; + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == 5, "got %u, expected font width of 5\n", tmp.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == 12, "got %u, expected font height of 12\n", tmp.dwFontSize.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 13x24 */ + cfix.dwFontSize.X = 13; + cfix.dwFontSize.Y = 24; + + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.Y, cfix.dwFontSize.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 0x0 */ + cfix.dwFontSize.X = 0; + 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());
+ memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + todo_wine ok(tmp.dwFontSize.X == 5, "got %u, expected font width of 5\n", tmp.dwFontSize.X); + todo_wine ok(tmp.dwFontSize.Y == 12, "got %u, expected font height of 12\n", tmp.dwFontSize.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)); + + /* Reset to font size 8x16 */ + cfix.dwFontSize.X = 8; + cfix.dwFontSize.Y = 16; + + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.Y, cfix.dwFontSize.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 weight */ + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.Y); + ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.Y, cfix.dwFontSize.Y); + 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); + ok(!lstrcmpW(tmp.FaceName, face_name), "got %s, expected %s\n", + wine_dbgstr_w(tmp.FaceName), wine_dbgstr_w(face_name)); + + /* Test with invalid font face name */ + cfix.FontWeight = FW_NORMAL; + lstrcpyW(cfix.FaceName, L"MissingFont"); + + 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()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.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); + 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, FALSE, &cfix); + todo_wine ok(ret, "got %d, expected non-zero\n", ret); + todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError()); + + memset(&tmp, 0, sizeof(tmp)); + tmp.cbSize = sizeof(tmp); + ret = GetCurrentConsoleFontEx(std_output, FALSE, &tmp); + ok(ret, "got %d, expected non-zero\n", ret); + + ok(tmp.dwFontSize.X == cfix.dwFontSize.X, "got %u, expected font width of %u\n", + tmp.dwFontSize.X, cfix.dwFontSize.X); + ok(tmp.dwFontSize.Y == cfix.dwFontSize.Y, "got %u, expected font height of %u\n", + tmp.dwFontSize.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); + 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, FALSE, &orig_cfix); todo_wine ok(ret, "got %d, expected non-zero\n", ret);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=102317
Your paranoid android.
=== debiant2 (32 bit report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit Arabic:Morocco report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit German report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit French report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit Hebrew:Israel report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit Hindi:India report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit Chinese:China report) ===
kernel32: console.c:3699: Test failed: got 9, expected font width of 8 console.c:3853: Test failed: got 9, expected font width of 8 console.c:3875: Test failed: got 9, expected font width of 16 console.c:3898: Test failed: got 9, expected font width of 8 console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3920: Test failed: got 9, expected font width of 8 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (32 bit WoW report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1
=== debiant2 (64 bit WoW report) ===
kernel32: console.c:3902: Test succeeded inside todo block: got 1, expected 1 console.c:3924: Test succeeded inside todo block: got 1, expected 1