[PATCH 1/2] kernel32/tests: Add a test for GetLargestConsoleWindowSize

Hugh McMaster hugh.mcmaster at outlook.com
Sun Jun 14 06:24:13 CDT 2015


The test includes a fallback to calculate the console font size, as
GetCurrentConsoleFont and GetConsoleFontSize are unimplemented.
---
 dlls/kernel32/tests/console.c | 45 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5928e8c..254922c 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -1307,6 +1307,50 @@ static void test_GetSetStdHandle(void)
     ok(error == 0xdeadbeef, "wrong GetLastError() %d\n", error);
 }
 
+static void test_GetLargestConsoleWindowSize(HANDLE hConOut)
+{
+    CONSOLE_FONT_INFO cfi;
+    RECT r;
+    unsigned int caption;
+    LONG maxconwin_x, maxconwin_y;
+    COORD fontsize, c;
+
+    GetCurrentConsoleFont(hConOut, TRUE, &cfi);
+    fontsize = GetConsoleFontSize(hConOut, cfi.nFont);
+    /* GetCurrentConsoleFont and GetConsoleFontSize are unimplemented,
+     * so allow the test suite to continue by calculating the font size. */
+    if (!fontsize.X || !fontsize.Y)
+    {
+        CONSOLE_SCREEN_BUFFER_INFO csbi;
+        unsigned int columns, rows;
+        HWND hwnd;
+        RECT rcClient;
+
+        GetConsoleScreenBufferInfo(hConOut, &csbi);
+        columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+        rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+
+        hwnd = GetConsoleWindow();
+        GetClientRect(hwnd, &rcClient);
+
+        fontsize.X = rcClient.right / columns;
+        fontsize.Y = rcClient.bottom / rows;
+    }
+
+    SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
+    caption = GetSystemMetrics(SM_CYCAPTION);
+
+    maxconwin_x = (r.right - r.left) / fontsize.X;
+    maxconwin_y = (r.bottom - r.top - caption) / fontsize.Y;
+
+    c = GetLargestConsoleWindowSize(hConOut);
+
+    todo_wine
+    ok(maxconwin_x == c.X, "incorrect maximum width, got %d, expected %d\n", maxconwin_x, c.X);
+    todo_wine
+    ok(maxconwin_y == c.Y, "incorrect maximum height, got %d, expected %d\n", maxconwin_y, c.Y);
+}
+
 static void test_GetNumberOfConsoleInputEvents(HANDLE input_handle)
 {
     DWORD count;
@@ -2708,6 +2752,7 @@ START_TEST(console)
     test_OpenCON();
     test_VerifyConsoleIoHandle(hConOut);
     test_GetSetStdHandle();
+    test_GetLargestConsoleWindowSize(hConOut);
     test_GetNumberOfConsoleInputEvents(hConIn);
     test_WriteConsoleInputA(hConIn);
     test_WriteConsoleInputW(hConIn);
-- 
1.9.1




More information about the wine-patches mailing list