[PATCH 1/2] kernel32/tests: Add tests for GetCurrentConsoleFont (v2)
Hugh McMaster
hugh.mcmaster at outlook.com
Wed Oct 21 02:44:17 CDT 2015
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
dlls/kernel32/tests/console.c | 95 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5928e8c..1d3f5a4 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2588,6 +2588,100 @@ 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;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD c;
+ short int width, height;
+
+ 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 non-zero\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 0xdeadbeef\n", GetLastError());
+ GetConsoleScreenBufferInfo(std_output, &csbi);
+ width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ c = GetConsoleFontSize(std_output, cfi.nFont);
+ ok(cfi.dwFontSize.X == width || broken(cfi.dwFontSize.X == c.X)/* Vista and higher */,
+ "got %d, expected %d\n", cfi.dwFontSize.X, width);
+ ok(cfi.dwFontSize.Y == height || broken(cfi.dwFontSize.Y == c.Y)/* Vista and higher */,
+ "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 non-zero\n", ret);
+ ok(GetLastError() == 0xdeadbeef, "got %d, expected 0xdeadbeef\n", GetLastError());
+ GetConsoleScreenBufferInfo(std_error, &csbi);
+ width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+ c = GetConsoleFontSize(std_error, cfi.nFont);
+ ok(cfi.dwFontSize.X == width || broken(cfi.dwFontSize.X == c.X)/* Vista and higher */,
+ "got %d, expected %d\n", cfi.dwFontSize.X, width);
+ ok(cfi.dwFontSize.Y == height || broken(cfi.dwFontSize.Y == c.Y)/* Vista and higher */,
+ "got %d, expected %d\n", cfi.dwFontSize.Y, height);
+}
+
START_TEST(console)
{
static const char font_name[] = "Lucida Console";
@@ -2720,4 +2814,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