Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- dlls/kernel32/tests/console.c | 146 +++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 8b5abfa2da9..8c487497cef 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3554,10 +3554,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); + unsigned int cp;
orig_cfix.cbSize = sizeof(CONSOLE_FONT_INFOEX);
@@ -3651,17 +3652,158 @@ 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());
+ /* Save current console font information */ + cp = GetConsoleOutputCP(); + SetConsoleOutputCP(CP_UTF8); + + /* Try setting console font information for the current window size */ + /* Set general font parameters */ + 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"); + + /* Test font height 16 */ + 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.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); + + /* Test font height 20 */ + cfix.dwFontSize.Y = 20; + lstrcpyW(cfix.FaceName, tmp.FaceName); + 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.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 height 12. 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.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 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()); + + 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.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 with no 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()); + + 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.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 == FW_NORMAL, "got %u, expected %u\n", tmp.FontWeight, FW_NORMAL); + 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.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.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); + + /* 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.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); + /* 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);