Commit 77a75d74 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

kernel32/tests: Add tests for GetConsoleFontSize.

parent 4925f758
......@@ -2627,6 +2627,60 @@ static void test_GetCurrentConsoleFont(HANDLE std_output)
"got %d, expected %d\n", cfi.dwFontSize.Y, height);
}
static void test_GetConsoleFontSize(HANDLE std_output)
{
COORD c;
DWORD index = 0;
CONSOLE_FONT_INFO cfi;
RECT r;
CONSOLE_SCREEN_BUFFER_INFO csbi;
LONG font_width, font_height;
HMODULE hmod;
DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
memset(&c, 10, sizeof(COORD));
SetLastError(0xdeadbeef);
c = GetConsoleFontSize(NULL, index);
ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
ok(!c.X, "got %d, expected 0\n", c.X);
ok(!c.Y, "got %d, expected 0\n", c.Y);
memset(&c, 10, sizeof(COORD));
SetLastError(0xdeadbeef);
c = GetConsoleFontSize(GetStdHandle(STD_INPUT_HANDLE), index);
ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
ok(!c.X, "got %d, expected 0\n", c.X);
ok(!c.Y, "got %d, expected 0\n", c.Y);
GetCurrentConsoleFont(std_output, FALSE, &cfi);
memset(&c, 10, sizeof(COORD));
SetLastError(0xdeadbeef);
c = GetConsoleFontSize(std_output, cfi.nFont);
ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
GetClientRect(GetConsoleWindow(), &r);
GetConsoleScreenBufferInfo(std_output, &csbi);
font_width = (r.right - r.left + 1) / csbi.srWindow.Right;
font_height = (r.bottom - r.top + 1) / csbi.srWindow.Bottom;
ok(c.X == font_width, "got %d, expected %d\n", c.X, font_width);
ok(c.Y == font_height, "got %d, expected %d\n", c.Y, font_height);
hmod = GetModuleHandleA("kernel32.dll");
pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
if (!pGetNumberOfConsoleFonts)
{
win_skip("GetNumberOfConsoleFonts is not available\n");
return;
}
index = pGetNumberOfConsoleFonts();
memset(&c, 10, sizeof(COORD));
SetLastError(0xdeadbeef);
c = GetConsoleFontSize(std_output, index);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
ok(!c.X, "got %d, expected 0\n", c.X);
ok(!c.Y, "got %d, expected 0\n", c.Y);
}
START_TEST(console)
{
static const char font_name[] = "Lucida Console";
......@@ -2760,4 +2814,5 @@ START_TEST(console)
test_ReadConsoleOutputCharacterW(hConOut);
test_ReadConsoleOutputAttribute(hConOut);
test_GetCurrentConsoleFont(hConOut);
test_GetConsoleFontSize(hConOut);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment