Aaro Altonen : kernel32/tests: Add tests for SetConsoleScreenBufferInfoEx().

Alexandre Julliard julliard at winehq.org
Thu Mar 5 16:35:27 CST 2020


Module: wine
Branch: master
Commit: 723506ef4834cd9a16b890042a1c43861b39f3e1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=723506ef4834cd9a16b890042a1c43861b39f3e1

Author: Aaro Altonen <a.altonen at hotmail.com>
Date:   Wed Mar  4 09:47:51 2020 +0200

kernel32/tests: Add tests for SetConsoleScreenBufferInfoEx().

Signed-off-by: Aaro Altonen <a.altonen at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/console.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5f8003760d..8f19161c9c 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3142,6 +3142,53 @@ static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
     ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
 }
 
+static void test_SetConsoleScreenBufferInfoEx(HANDLE std_output)
+{
+    BOOL ret;
+    HANDLE hmod;
+    HANDLE std_input = CreateFileA("CONIN$", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
+    BOOL (WINAPI *pSetConsoleScreenBufferInfoEx)(HANDLE, CONSOLE_SCREEN_BUFFER_INFOEX *);
+    BOOL (WINAPI *pGetConsoleScreenBufferInfoEx)(HANDLE, CONSOLE_SCREEN_BUFFER_INFOEX *);
+    CONSOLE_SCREEN_BUFFER_INFOEX info;
+
+    hmod = GetModuleHandleA("kernel32.dll");
+    pSetConsoleScreenBufferInfoEx = (void *)GetProcAddress(hmod, "SetConsoleScreenBufferInfoEx");
+    pGetConsoleScreenBufferInfoEx = (void *)GetProcAddress(hmod, "GetConsoleScreenBufferInfoEx");
+    if (!pSetConsoleScreenBufferInfoEx || !pGetConsoleScreenBufferInfoEx)
+    {
+        win_skip("SetConsoleScreenBufferInfoEx is not available\n");
+        return;
+    }
+
+    memset(&info, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFOEX));
+    info.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
+    pGetConsoleScreenBufferInfoEx(std_output, &info);
+
+    SetLastError(0xdeadbeef);
+    ret = pSetConsoleScreenBufferInfoEx(NULL, &info);
+    ok(!ret, "got %d, expected zero\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pSetConsoleScreenBufferInfoEx(std_output, &info);
+    todo_wine ok(ret, "got %d, expected one\n", ret);
+    todo_wine ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pSetConsoleScreenBufferInfoEx(std_input, &info);
+    ok(!ret, "got %d, expected zero\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_HANDLE || GetLastError() == ERROR_ACCESS_DENIED,
+            "got %u, expected 5 or 6\n", GetLastError());
+
+    info.cbSize = 0;
+    SetLastError(0xdeadbeef);
+    ret = pSetConsoleScreenBufferInfoEx(std_output, &info);
+    ok(!ret, "got %d, expected zero\n", ret);
+    todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %u, expected 87\n", GetLastError());
+
+    CloseHandle(std_input);
+}
+
 static void test_AttachConsole_child(DWORD console_pid)
 {
     HANDLE pipe_in, pipe_out;
@@ -3398,5 +3445,6 @@ START_TEST(console)
     test_GetConsoleFontInfo(hConOut);
     test_SetConsoleFont(hConOut);
     test_GetConsoleScreenBufferInfoEx(hConOut);
+    test_SetConsoleScreenBufferInfoEx(hConOut);
     test_AttachConsole(hConOut);
 }




More information about the wine-cvs mailing list