[PATCH 3/4] kernel32/tests: Add tests for GetCurrentConsoleFont
Hugh McMaster
hugh.mcmaster at outlook.com
Tue Oct 20 19:43:55 CDT 2015
Windows 2000, XP and Server 2003 return the number of columns and rows
when passing in FALSE. Windows Vista and higher return the font size.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
dlls/kernel32/tests/console.c | 126 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5928e8c..8cedaba 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2588,6 +2588,131 @@ static void test_ReadConsole(void)
ok(bytes == 0xdeadbeef, "expected 0xdeadbeef, got %#x\n", bytes);
}
+static void test_GetCurrentConsoleFont(HANDLE std_output)
+{
+ CONSOLE_FONT_INFO cfi;
+ BOOL ret;
+ HANDLE std_input, std_error;
+ OSVERSIONINFOW osvi;
+
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(NULL, FALSE, NULL);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(NULL, TRUE, NULL);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(NULL, FALSE, &cfi);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+ ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
+ ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(NULL, TRUE, &cfi);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+ ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
+ ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
+
+ std_input = GetStdHandle(STD_INPUT_HANDLE);
+
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_input, FALSE, NULL);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_input, TRUE, NULL);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_input, FALSE, &cfi);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+ ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
+ ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_input, TRUE, &cfi);
+ ok(!ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %d, expected 6\n", GetLastError());
+ ok(!cfi.dwFontSize.X, "got %d, expected 0\n", cfi.dwFontSize.X);
+ ok(!cfi.dwFontSize.Y, "got %d, expected 0\n", cfi.dwFontSize.Y);
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_output, FALSE, &cfi);
+ ok(ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 12 or 998\n", GetLastError());
+
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+ GetVersionExW(&osvi);
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_output, FALSE, &cfi);
+ ok(ret, "got %d, expected non-zero\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 0xdeadbeef\n", GetLastError());
+ if (osvi.dwMajorVersion >= 6) /* Windows Vista or higher */
+ {
+ COORD c;
+ c = GetConsoleFontSize(std_output, cfi.nFont);
+ todo_wine ok(cfi.dwFontSize.X == c.X, "got %d, expected %d\n", cfi.dwFontSize.X, c.X);
+ todo_wine ok(cfi.dwFontSize.Y == c.Y, "got %d, expected %d\n", cfi.dwFontSize.Y, c.Y);
+ }
+ else
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ short int width, height;
+ GetConsoleScreenBufferInfo(std_output, &csbi);
+ width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ ok(cfi.dwFontSize.X == width, "got %d, expected %d\n", cfi.dwFontSize.X, width);
+ ok(cfi.dwFontSize.Y == height, "got %d, expected %d\n", cfi.dwFontSize.Y, height);
+ }
+
+ std_error = GetStdHandle(STD_ERROR_HANDLE);
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_error, FALSE, &cfi);
+ ok(ret, "got %d, expected 0\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 12 or 998\n", GetLastError());
+
+ memset(&cfi, 0, sizeof(CONSOLE_FONT_INFO));
+ SetLastError(0xdeadbeef);
+ ret = GetCurrentConsoleFont(std_error, FALSE, &cfi);
+ ok(ret, "got %d, expected non-zero\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 0xdeadbeef\n", GetLastError());
+ if (osvi.dwMajorVersion >= 6) /* Windows Vista or higher */
+ {
+ COORD c;
+ c = GetConsoleFontSize(std_error, cfi.nFont);
+ todo_wine ok(cfi.dwFontSize.X == c.X, "got %d, expected %d\n", cfi.dwFontSize.X, c.X);
+ todo_wine ok(cfi.dwFontSize.Y == c.Y, "got %d, expected %d\n", cfi.dwFontSize.Y, c.Y);
+ }
+ else
+ {
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ short int width, height;
+ GetConsoleScreenBufferInfo(std_error, &csbi);
+ width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ ok(cfi.dwFontSize.X == width, "got %d, expected %d\n", cfi.dwFontSize.X, width);
+ ok(cfi.dwFontSize.Y == height, "got %d, expected %d\n", cfi.dwFontSize.Y, height);
+ }
+}
+
START_TEST(console)
{
static const char font_name[] = "Lucida Console";
@@ -2720,4 +2845,5 @@ START_TEST(console)
test_ReadConsoleOutputCharacterA(hConOut);
test_ReadConsoleOutputCharacterW(hConOut);
test_ReadConsoleOutputAttribute(hConOut);
+ test_GetCurrentConsoleFont(hConOut);
}
--
1.9.1
More information about the wine-patches
mailing list