Skip to content

Commit

Permalink
Extend CursorSaveRestore test to cover delayed wrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Feb 28, 2023
1 parent a94bf69 commit 4eada04
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6268,48 +6268,55 @@ void ScreenBufferTests::CursorSaveRestore()
VERIFY_SUCCEEDED(si.SetViewportOrigin(true, til::point(0, 0), true));

Log::Comment(L"Restore after save.");
// Set the cursor position, attributes, and character set.
// Set the cursor position, delayed wrap, attributes, and character set.
cursor.SetPosition({ 20, 10 });
cursor.DelayEOLWrap();
si.SetAttributes(colorAttrs);
stateMachine.ProcessString(selectGraphicsChars);
// Save state.
stateMachine.ProcessString(saveCursor);
// Reset the cursor position, attributes, and character set.
// Reset the cursor position, delayed wrap, attributes, and character set.
cursor.SetPosition({ 0, 0 });
si.SetAttributes(defaultAttrs);
stateMachine.ProcessString(selectAsciiChars);
// Restore state.
stateMachine.ProcessString(restoreCursor);
// Verify initial position, colors, and graphic character set.
// Verify initial position, delayed wrap, colors, and graphic character set.
VERIFY_ARE_EQUAL(til::point(20, 10), cursor.GetPosition());
VERIFY_IS_TRUE(cursor.IsDelayedEOLWrap());
cursor.ResetDelayEOLWrap();
VERIFY_ARE_EQUAL(colorAttrs, si.GetAttributes());
stateMachine.ProcessString(asciiText);
VERIFY_IS_TRUE(_ValidateLineContains({ 20, 10 }, graphicText, colorAttrs));

Log::Comment(L"Restore again without save.");
// Reset the cursor position, attributes, and character set.
// Reset the cursor position, delayed wrap, attributes, and character set.
cursor.SetPosition({ 0, 0 });
si.SetAttributes(defaultAttrs);
stateMachine.ProcessString(selectAsciiChars);
// Restore state.
stateMachine.ProcessString(restoreCursor);
// Verify initial saved position, colors, and graphic character set.
// Verify initial saved position, delayed wrap, colors, and graphic character set.
VERIFY_ARE_EQUAL(til::point(20, 10), cursor.GetPosition());
VERIFY_IS_TRUE(cursor.IsDelayedEOLWrap());
cursor.ResetDelayEOLWrap();
VERIFY_ARE_EQUAL(colorAttrs, si.GetAttributes());
stateMachine.ProcessString(asciiText);
VERIFY_IS_TRUE(_ValidateLineContains({ 20, 10 }, graphicText, colorAttrs));

Log::Comment(L"Restore after reset.");
// Soft reset.
stateMachine.ProcessString(L"\x1b[!p");
// Set the cursor position, attributes, and character set.
// Set the cursor position, delayed wrap, attributes, and character set.
cursor.SetPosition({ 20, 10 });
cursor.DelayEOLWrap();
si.SetAttributes(colorAttrs);
stateMachine.ProcessString(selectGraphicsChars);
// Restore state.
stateMachine.ProcessString(restoreCursor);
// Verify home position, default attributes, and ascii character set.
// Verify home position, no delayed wrap, default attributes, and ascii character set.
VERIFY_ARE_EQUAL(til::point(0, 0), cursor.GetPosition());
VERIFY_IS_FALSE(cursor.IsDelayedEOLWrap());
VERIFY_ARE_EQUAL(defaultAttrs, si.GetAttributes());
stateMachine.ProcessString(asciiText);
VERIFY_IS_TRUE(_ValidateLineContains(til::point(0, 0), asciiText, defaultAttrs));
Expand Down

0 comments on commit 4eada04

Please sign in to comment.