Skip to content

Commit

Permalink
Add unit test for DECRQM.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Nov 26, 2022
1 parent 1eb21ba commit 53329c9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/terminal/adapter/ut_adapter/adapterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,40 @@ class AdapterTest
_testGetSet->ValidateInputEvent(L"\033P0$r\033\\");
}

TEST_METHOD(RequestModeTests)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"Data:modeNumber", L"{1, 3, 5, 6, 8, 12, 25, 40, 66, 67, 1000, 1002, 1003, 1004, 1005, 1006, 1007, 1049, 9001}")
END_TEST_METHOD_PROPERTIES()

VTInt modeNumber;
VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"modeNumber", modeNumber));
const auto mode = DispatchTypes::DECPrivateMode(modeNumber);

if (mode == DispatchTypes::DECCOLM_SetNumberOfColumns)
{
Log::Comment(L"Make sure DECCOLM is allowed");
VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::XTERM_EnableDECCOLMSupport));
}

Log::Comment(NoThrowString().Format(L"Setting private mode %d", modeNumber));
_testGetSet->PrepData();
VERIFY_IS_TRUE(_pDispatch->SetMode(mode));
VERIFY_IS_TRUE(_pDispatch->RequestMode(mode));

wchar_t expectedResponse[20];
swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[?%d;1$y", modeNumber);
_testGetSet->ValidateInputEvent(expectedResponse);

Log::Comment(NoThrowString().Format(L"Resetting private mode %d", modeNumber));
_testGetSet->PrepData();
VERIFY_IS_TRUE(_pDispatch->ResetMode(mode));
VERIFY_IS_TRUE(_pDispatch->RequestMode(mode));

swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[?%d;2$y", modeNumber);
_testGetSet->ValidateInputEvent(expectedResponse);
}

TEST_METHOD(CursorKeysModeTest)
{
Log::Comment(L"Starting test...");
Expand Down

0 comments on commit 53329c9

Please sign in to comment.