From 9a297b9476ba260fe73dd46282530d793811b55b Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sun, 8 Sep 2024 20:07:57 +0100 Subject: [PATCH] Add some unit tests. --- src/host/ut_host/ScreenBufferTests.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/host/ut_host/ScreenBufferTests.cpp b/src/host/ut_host/ScreenBufferTests.cpp index f4aa82ac42b..a81d47ec931 100644 --- a/src/host/ut_host/ScreenBufferTests.cpp +++ b/src/host/ut_host/ScreenBufferTests.cpp @@ -16,6 +16,7 @@ #include "../interactivity/inc/ServiceLocator.hpp" #include "../../inc/conattrs.hpp" +#include "../../types/inc/colorTable.hpp" #include "../../types/inc/Viewport.hpp" #include "../../inc/TestUtils.h" @@ -2070,6 +2071,15 @@ void ScreenBufferTests::VtRestoreColorTableReport() // Blue component is clamped at 100%, so 150% interpreted as 100% stateMachine.ProcessString(L"\033P2$p14;2;0;0;150\033\\"); VERIFY_ARE_EQUAL(RGB(0, 0, 255), gci.GetColorTableEntry(14)); + + Log::Comment(L"RIS restores initial Campbell color scheme"); + + stateMachine.ProcessString(L"\033c"); + for (auto i = 0; i < 16; i++) + { + const COLORREF expectedColor = Microsoft::Console::Utils::CampbellColorTable()[i]; + VERIFY_ARE_EQUAL(expectedColor, gci.GetColorTableEntry(i)); + } } void ScreenBufferTests::ResizeTraditionalDoesNotDoubleFreeAttrRows() @@ -3352,6 +3362,13 @@ void ScreenBufferTests::AssignColorAliases() stateMachine.ProcessString(L"\033[2;34;56,|"); VERIFY_ARE_EQUAL(34u, renderSettings.GetColorAliasIndex(ColorAlias::FrameForeground)); VERIFY_ARE_EQUAL(56u, renderSettings.GetColorAliasIndex(ColorAlias::FrameBackground)); + + Log::Comment(L"Test RIS restores initial color assignments"); + stateMachine.ProcessString(L"\033c"); + VERIFY_ARE_EQUAL(defaultFg, renderSettings.GetColorAliasIndex(ColorAlias::DefaultForeground)); + VERIFY_ARE_EQUAL(defaultBg, renderSettings.GetColorAliasIndex(ColorAlias::DefaultBackground)); + VERIFY_ARE_EQUAL(frameFg, renderSettings.GetColorAliasIndex(ColorAlias::FrameForeground)); + VERIFY_ARE_EQUAL(frameBg, renderSettings.GetColorAliasIndex(ColorAlias::FrameBackground)); } void ScreenBufferTests::DeleteCharsNearEndOfLine()