Hugh McMaster : kernel32/tests: Test whether console color attributes are copied to the new screen buffer.
Alexandre Julliard
julliard at winehq.org
Wed Jul 21 16:04:31 CDT 2021
Module: wine
Branch: master
Commit: 0a6d0e689b5bf860bdcc5aee5d64c5b71bdc430a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0a6d0e689b5bf860bdcc5aee5d64c5b71bdc430a
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Wed Jul 21 22:24:47 2021 +1000
kernel32/tests: Test whether console color attributes are copied to the new screen buffer.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/console.c | 78 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 918ecac8ac4..6b723c3d6c8 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -973,6 +973,83 @@ static void testScreenBuffer(HANDLE hConOut)
SetConsoleOutputCP(oldcp);
}
+static void test_new_screen_buffer_color_attributes(HANDLE hConOut)
+{
+ CONSOLE_SCREEN_BUFFER_INFOEX csbi, csbi2;
+ BOOL ret;
+ HANDLE hConOut2;
+ WORD orig_attr, orig_popup, attr;
+
+ csbi.cbSize = csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
+
+ ret = GetConsoleScreenBufferInfoEx(hConOut, &csbi);
+ ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+ orig_attr = csbi.wAttributes;
+ orig_popup = csbi.wPopupAttributes;
+
+ hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ CONSOLE_TEXTMODE_BUFFER, NULL);
+ ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+
+ ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
+ ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+ CloseHandle(hConOut2);
+
+ todo_wine ok(csbi2.wAttributes == orig_attr, "Character Attributes should have been copied: "
+ "got %#x, expected %#x\n", csbi2.wAttributes, orig_attr);
+ todo_wine ok(csbi2.wPopupAttributes != orig_popup, "Popup Attributes should not match original value\n");
+ todo_wine ok(csbi2.wPopupAttributes == orig_attr, "Popup Attributes should match Character Attributes\n");
+
+ /* Test different Character Attributes */
+ attr = FOREGROUND_BLUE|BACKGROUND_GREEN;
+ ret = SetConsoleTextAttribute(hConOut, attr);
+ ok(ret, "SetConsoleTextAttribute failed: error %u\n", GetLastError());
+
+ hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ CONSOLE_TEXTMODE_BUFFER, NULL);
+ ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+
+ memset(&csbi2, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFOEX));
+ csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
+
+ ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
+ ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+ CloseHandle(hConOut2);
+
+ todo_wine ok(csbi2.wAttributes == attr, "Character Attributes should have been copied: "
+ "got %#x, expected %#x\n", csbi2.wAttributes, attr);
+ todo_wine ok(csbi2.wPopupAttributes != orig_popup, "Popup Attributes should not match original value\n");
+ todo_wine ok(csbi2.wPopupAttributes == attr, "Popup Attributes should match Character Attributes\n");
+
+ ret = SetConsoleTextAttribute(hConOut, orig_attr);
+ ok(ret, "SetConsoleTextAttribute failed: error %u\n", GetLastError());
+
+ /* Test inheritance of different Popup Attributes */
+ csbi.wPopupAttributes = attr;
+ ret = SetConsoleScreenBufferInfoEx(hConOut, &csbi);
+ ok(ret, "SetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+
+ hConOut2 = CreateConsoleScreenBuffer(GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ CONSOLE_TEXTMODE_BUFFER, NULL);
+ ok(hConOut2 != INVALID_HANDLE_VALUE, "CreateConsoleScreenBuffer failed: error %u\n", GetLastError());
+
+ memset(&csbi2, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFOEX));
+ csbi2.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
+
+ ret = GetConsoleScreenBufferInfoEx(hConOut2, &csbi2);
+ ok(ret, "GetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+ CloseHandle(hConOut2);
+
+ todo_wine ok(csbi2.wAttributes == orig_attr, "Character Attributes should have been copied: "
+ "got %#x, expected %#x\n", csbi2.wAttributes, orig_attr);
+ todo_wine ok(csbi2.wPopupAttributes != orig_popup, "Popup Attributes should not match original value\n");
+ todo_wine ok(csbi2.wPopupAttributes == orig_attr, "Popup Attributes should match Character Attributes\n");
+
+ csbi.wPopupAttributes = orig_popup;
+ ret = SetConsoleScreenBufferInfoEx(hConOut, &csbi);
+ ok(ret, "SetConsoleScreenBufferInfoEx failed: error %u\n", GetLastError());
+}
+
static void CALLBACK signaled_function(void *p, BOOLEAN timeout)
{
HANDLE event = p;
@@ -4506,6 +4583,7 @@ START_TEST(console)
testScroll(hConOut, sbi.dwSize);
/* will test sb creation / modification / codepage handling */
if (!test_current) testScreenBuffer(hConOut);
+ test_new_screen_buffer_color_attributes(hConOut);
/* Test waiting for a console handle */
testWaitForConsoleInput(hConIn);
test_wait(hConIn, hConOut);
More information about the wine-cvs
mailing list