[PATCH] kernel32/tests: Add initial tests for GetConsoleFontInfo (v2)

Hugh McMaster hugh.mcmaster at outlook.com
Fri Apr 22 08:21:32 CDT 2016


Changes since v1: Use CONSOLE_FONT_INFO instead of undocumented CONSOLE_FONT.
The structure is identical.

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

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 4dca17d..26ee777 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2779,6 +2779,62 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
     pSetConsoleFont(std_output, index); /* restore original font size */
 }
 
+static void test_GetConsoleFontInfo(HANDLE std_output)
+{
+    HANDLE hmod;
+    BOOL (WINAPI *pGetConsoleFontInfo)(HANDLE, BOOL, DWORD, CONSOLE_FONT_INFO *);
+    CONSOLE_FONT_INFO cfi;
+    BOOL ret;
+
+    hmod = GetModuleHandleA("kernel32.dll");
+    pGetConsoleFontInfo = (void *)GetProcAddress(hmod, "GetConsoleFontInfo");
+    if (!pGetConsoleFontInfo)
+    {
+        win_skip("GetConsoleFontInfo is not available\n");
+        return;
+    }
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(NULL, FALSE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), FALSE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(std_output, FALSE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(std_output, FALSE, 1, &cfi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(NULL, TRUE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(GetStdHandle(STD_INPUT_HANDLE), TRUE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(std_output, TRUE, 0, &cfi);
+    ok(!ret, "got %d, expected zero\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetConsoleFontInfo(std_output, TRUE, 1, &cfi);
+    ok(ret, "got %d, expected non-zero\n", ret);
+    ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+}
+
 START_TEST(console)
 {
     static const char font_name[] = "Lucida Console";
@@ -2925,4 +2981,5 @@ START_TEST(console)
     test_GetCurrentConsoleFont(hConOut);
     test_GetConsoleFontSize(hConOut);
     test_GetLargestConsoleWindowSize(hConOut);
+    test_GetConsoleFontInfo(hConOut);
 }
-- 
1.9.1




More information about the wine-patches mailing list