-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Summary of the Pull Request #4354 is a pretty complicated PR. It's got a bunch of conpty changes, but what it also has was some critical improvements to the roundtrip test suite. I'm working on some other bugfixes in the same area currently, and need these tests enhancements in those branches _now_. The rest of #4354 is complex enough that I don't trust it will get merged soon (if ever). However, these fixes _should_ be in regardless. ## PR Checklist * [x] Taken directly from #4354 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments This is four main changes: * Enable conpty to be fully enabled in unittests. Just setting up a VT renderer isn't enough to trick the host into being in conpty mode - it also needs to have some other flags set. * Some minor changes to `CommonState` to better configure the common test state for conpty * Move some of the verify helpers from `ConptyRoundtripTests` into their own helper class, to be shared in multiple tests * Add a `TerminalBufferTests` class, for testing the Terminal buffer directly (without conpty). This change is really easier than ![image](https://user-images.githubusercontent.com/18356694/73278427-2d1b4480-41b1-11ea-9bbe-70671c557f49.png) would suggest, I promise.
- Loading branch information
1 parent
e8658cd
commit 685720a
Showing
15 changed files
with
365 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "precomp.h" | ||
#include <WexTestClass.h> | ||
|
||
#include "../renderer/inc/DummyRenderTarget.hpp" | ||
#include "../cascadia/TerminalCore/Terminal.hpp" | ||
#include "MockTermSettings.h" | ||
#include "consoletaeftemplates.hpp" | ||
#include "TestUtils.h" | ||
|
||
using namespace winrt::Microsoft::Terminal::Settings; | ||
using namespace Microsoft::Terminal::Core; | ||
|
||
using namespace WEX::Common; | ||
using namespace WEX::Logging; | ||
using namespace WEX::TestExecution; | ||
|
||
namespace TerminalCoreUnitTests | ||
{ | ||
class TerminalBufferTests; | ||
}; | ||
using namespace TerminalCoreUnitTests; | ||
|
||
class TerminalCoreUnitTests::TerminalBufferTests final | ||
{ | ||
TEST_CLASS(TerminalBufferTests); | ||
|
||
TEST_METHOD(TestSimpleBufferWriting); | ||
|
||
TEST_METHOD_SETUP(MethodSetup) | ||
{ | ||
// STEP 1: Set up the Terminal | ||
term = std::make_unique<Terminal>(); | ||
term->Create({ 80, 32 }, 100, emptyRT); | ||
return true; | ||
} | ||
|
||
TEST_METHOD_CLEANUP(MethodCleanup) | ||
{ | ||
term = nullptr; | ||
return true; | ||
} | ||
|
||
private: | ||
DummyRenderTarget emptyRT; | ||
std::unique_ptr<Terminal> term; | ||
}; | ||
|
||
void TerminalBufferTests::TestSimpleBufferWriting() | ||
{ | ||
auto& termTb = *term->_buffer; | ||
auto& termSm = *term->_stateMachine; | ||
const auto initialView = term->GetViewport(); | ||
|
||
VERIFY_ARE_EQUAL(0, initialView.Top()); | ||
VERIFY_ARE_EQUAL(32, initialView.BottomExclusive()); | ||
|
||
termSm.ProcessString(L"Hello World"); | ||
|
||
const auto secondView = term->GetViewport(); | ||
|
||
VERIFY_ARE_EQUAL(0, secondView.Top()); | ||
VERIFY_ARE_EQUAL(32, secondView.BottomExclusive()); | ||
|
||
TestUtils::VerifyExpectedString(termTb, L"Hello World", { 0, 0 }); | ||
} |
Oops, something went wrong.