From cd82017a6bc5abddd8092854497675284fb3b3d6 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 24 Jan 2020 08:54:13 -0600 Subject: [PATCH] All the tests pass, it's finally happening --- .../ConptyRoundtripTests.cpp | 40 ++++++++++++------- .../TerminalBufferTests.cpp | 2 +- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp b/src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp index c0a95233f0..c86cc5972a 100644 --- a/src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp +++ b/src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp @@ -473,31 +473,32 @@ void ConptyRoundtripTests::TestResizeHeight() VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); } }; - auto verifyHostData = [&si](TextBuffer& hostTb, const int resizeDy = 0) { + auto verifyHostData = [&si, &initialHostView](TextBuffer& hostTb, const int resizeDy = 0) { const auto hostView = si.GetViewport(); + + const short originalViewHeight = gsl::narrow_cast(resizeDy < 0 ? + initialHostView.Height() + resizeDy : + initialHostView.Height()); + // The last row of the viewport should be empty // The second last row will have '0'+50 // The third last row will have '0'+49 // ... // The last row will have '0'+(50-height+1) - const auto firstChar = static_cast(L'0' + (50 - hostView.Height() + 1)); + // const auto firstChar = static_cast(L'0' + (50 - hostView.Height() + 1)); + // const auto firstChar = static_cast(L'0' + (50 - initialHostView.Height() + 1)); + const auto firstChar = static_cast(L'0' + (50 - originalViewHeight + 1)); // If we increased the height of the buffer, then we're going to insert // pad the top of the buffer with blank lines, to keep the real content // we had at the bottom of the buffer. // In that case, check for the first lines to be filled with spaces. - const short firstRowWithChars = gsl::narrow_cast(resizeDy > 0 ? resizeDy : 0); - if (resizeDy > 0) - { - for (short row = 0; row < firstRowWithChars; row++) - { - auto iter = hostTb.GetCellDataAt({ 0, row }); - VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); - } - } + // const short firstRowWithChars = gsl::narrow_cast(resizeDy > 0 ? resizeDy : 0); + const short firstRowWithChars = gsl::narrow_cast(0); // Don't include the last row of the viewport in this check, since it'll be blank - for (short row = firstRowWithChars; row < hostView.Height() - 1; row++) + short row = firstRowWithChars; + for (; row < originalViewHeight - 1; row++) { auto iter = hostTb.GetCellDataAt({ 0, row }); @@ -511,9 +512,18 @@ void ConptyRoundtripTests::TestResizeHeight() VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); } - // Check the last row of the viewport here - auto iter = hostTb.GetCellDataAt({ 0, hostView.Height() - 1 }); - VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); + // // Check the last row of the viewport here + // auto iter = hostTb.GetCellDataAt({ 0, hostView.Height() - 1 }); + // VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); + + // if (resizeDy > 0) + { + for (; row < hostView.Height(); row++) + { + auto iter = hostTb.GetCellDataAt({ 0, row }); + VERIFY_ARE_EQUAL(L" ", (iter)->Chars()); + } + } }; verifyHostData(*hostTb); verifyTermData(*termTb); diff --git a/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp b/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp index 32edb94898..9734c4062d 100644 --- a/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp +++ b/src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp @@ -101,8 +101,8 @@ void TerminalBufferTests::TestResizeHeight() const auto thirdView = term->GetViewport(); VERIFY_ARE_EQUAL(secondView.Top(), thirdView.Top()); - // VERIFY_ARE_EQUAL(50 - thirdView.Height() + 1, thirdView.Top()); VERIFY_ARE_EQUAL(50 + dy, thirdView.BottomInclusive()); + // VERIFY_ARE_EQUAL(50 - thirdView.Height() + 1, thirdView.Top()); verifyBufferContents(); }