Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a8bd503
I believe this is the bugfix
zadjii-msft Jan 31, 2020
648373d
Try writing tests
zadjii-msft Jan 31, 2020
029b676
clean up these tests for PR
zadjii-msft Jan 31, 2020
0a6f72c
Fix the tests o__o
zadjii-msft Jan 31, 2020
9849fe9
Merge remote-tracking branch 'origin/master' into dev/migrie/b/2455-w…
zadjii-msft Jan 31, 2020
963a830
Add the VERIFY_THROWS for dustin
zadjii-msft Jan 31, 2020
8ed39cd
Merge branch 'master' into dev/migrie/b/2455-with-new-tests
zadjii-msft Mar 18, 2020
82ad8bb
I _think_ this will pull the settings from the control, but I haven't…
zadjii-msft Mar 18, 2020
eafe9c8
Wrap Application::Current in try/catch since that breaks tests
zadjii-msft Mar 18, 2020
908fd74
Try to clone the settings directly from the control
zadjii-msft Mar 18, 2020
4561b9a
Revert "I _think_ this will pull the settings from the control, but I…
zadjii-msft Mar 18, 2020
9eaee52
Revert "Try to clone the settings directly from the control"
zadjii-msft Mar 18, 2020
e952c0d
fix the test so it compiles again
zadjii-msft Mar 18, 2020
07050b5
add a note on what's going wrong here
zadjii-msft Mar 19, 2020
4bb6803
I have no idea why but this seemed to work to initialize the panes
zadjii-msft Mar 19, 2020
499b003
immediately focus new panes
zadjii-msft Mar 19, 2020
95bb854
this works to alternate auto snapping, but maybe there's a better way
zadjii-msft Mar 19, 2020
a058181
precompute auto sizing correctly
zadjii-msft Mar 19, 2020
998318a
Some code cleanup "before" 5pm
zadjii-msft Mar 19, 2020
f3948d8
I somehow totally blew up the test?
zadjii-msft Mar 20, 2020
332a577
Merge remote-tracking branch 'origin/master' into dev/migrie/b/pane-i…
zadjii-msft Mar 20, 2020
1dffef4
okay this fixes this test
zadjii-msft Mar 20, 2020
e2e45a9
try manually cleaning up the page, but this doesn't work
zadjii-msft Mar 20, 2020
808868f
cleanup the test
zadjii-msft Mar 20, 2020
6208f43
This is a ton of colde cleanup ; `wtd split-pane` is broken, doesn't …
zadjii-msft Mar 20, 2020
7e0685f
Merge remote-tracking branch 'origin/master' into dev/migrie/b/pane-i…
zadjii-msft Mar 20, 2020
09ab62a
this fixes just a bare `wt split-pane`; `wt; ; ; focus-tab -t 1; spli…
zadjii-msft Mar 20, 2020
ce2b948
this fixes `focus-tab` during startup, but it's kinda janky
zadjii-msft Mar 20, 2020
4306389
god bless, I fixed the tests
zadjii-msft Mar 23, 2020
2b3b517
add an Initialized event so the tests can know when we're finished in…
zadjii-msft Mar 23, 2020
e80ee31
some test code cleanup
zadjii-msft Mar 23, 2020
9cd77e8
code cleanup for review
zadjii-msft Mar 23, 2020
7507f9f
finalize code cleanup
zadjii-msft Mar 23, 2020
60b2a49
Merge remote-tracking branch 'origin/master' into dev/migrie/b/pane-i…
zadjii-msft Mar 23, 2020
393492b
Tons of non-test code cleanup
zadjii-msft Mar 24, 2020
a1c7f7e
wacky--;
zadjii-msft Mar 24, 2020
1a15db3
Merge remote-tracking branch 'origin/master' into dev/migrie/b/pane-i…
DHowett Mar 25, 2020
34391c7
Merge remote-tracking branch 'origin/master' into dev/migrie/b/pane-i…
DHowett Mar 25, 2020
c3facb5
spelling
DHowett Mar 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ namespace TerminalAppLocalTests

TEST_METHOD(TestTerminalArgsForBinding);

TEST_METHOD(FindMissingProfile);
TEST_METHOD(MakeSettingsForProfileThatDoesntExist);
TEST_METHOD(MakeSettingsForDefaultProfileThatDoesntExist);

TEST_METHOD(TestLayerProfileOnColorScheme);

TEST_METHOD(ValidateKeybindingsWarnings);
Expand Down Expand Up @@ -2094,6 +2098,146 @@ namespace TerminalAppLocalTests
}
}

void SettingsTests::FindMissingProfile()
{
// Test that CascadiaSettings::FindProfile returns null for a GUID that
// doesn't exist
const std::string settingsString{ R"(
{
"defaultProfile": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"profiles": [
{
"name" : "profile0",
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}"
},
{
"name" : "profile1",
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}"
}
]
})" };
const auto settingsJsonObj = VerifyParseSucceeded(settingsString);
auto settings = CascadiaSettings::FromJson(settingsJsonObj);

const auto guid1 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-1111-49a3-80bd-e8fdd045185c}");
const auto guid2 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-2222-49a3-80bd-e8fdd045185c}");
const auto guid3 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-3333-49a3-80bd-e8fdd045185c}");

const Profile* const profile1 = settings->FindProfile(guid1);
const Profile* const profile2 = settings->FindProfile(guid2);
const Profile* const profile3 = settings->FindProfile(guid3);

VERIFY_IS_NOT_NULL(profile1);
VERIFY_IS_NOT_NULL(profile2);
VERIFY_IS_NULL(profile3);

VERIFY_ARE_EQUAL(L"profile0", profile1->GetName());
VERIFY_ARE_EQUAL(L"profile1", profile2->GetName());
}

void SettingsTests::MakeSettingsForProfileThatDoesntExist()
{
// Test that MakeSettings throws when the GUID doesn't exist
const std::string settingsString{ R"(
{
"defaultProfile": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"profiles": [
{
"name" : "profile0",
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"historySize": 1
},
{
"name" : "profile1",
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}",
"historySize": 2
}
]
})" };
const auto settingsJsonObj = VerifyParseSucceeded(settingsString);
auto settings = CascadiaSettings::FromJson(settingsJsonObj);

const auto guid1 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-1111-49a3-80bd-e8fdd045185c}");
const auto guid2 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-2222-49a3-80bd-e8fdd045185c}");
const auto guid3 = Microsoft::Console::Utils::GuidFromString(L"{6239a42c-3333-49a3-80bd-e8fdd045185c}");

try
{
auto terminalSettings = settings->BuildSettings(guid1);
VERIFY_ARE_NOT_EQUAL(nullptr, terminalSettings);
VERIFY_ARE_EQUAL(1, terminalSettings.HistorySize());
}
catch (...)
{
VERIFY_IS_TRUE(false, L"This call to BuildSettings should succeed");
}

try
{
auto terminalSettings = settings->BuildSettings(guid2);
VERIFY_ARE_NOT_EQUAL(nullptr, terminalSettings);
VERIFY_ARE_EQUAL(2, terminalSettings.HistorySize());
}
catch (...)
{
VERIFY_IS_TRUE(false, L"This call to BuildSettings should succeed");
}

VERIFY_THROWS(auto terminalSettings = settings->BuildSettings(guid3), wil::ResultException, L"This call to BuildSettings should fail");

try
{
const auto [guid, termSettings] = settings->BuildSettings(nullptr);
VERIFY_ARE_NOT_EQUAL(nullptr, termSettings);
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
}
catch (...)
{
VERIFY_IS_TRUE(false, L"This call to BuildSettings should succeed");
}
}

void SettingsTests::MakeSettingsForDefaultProfileThatDoesntExist()
{
// Test that MakeSettings _doesnt_ throw when we load settings with a
// defaultProfile that's not in the list, we validate the settings, and
// then call MakeSettings(nullopt). The validation should ensure that
// the default profile is something reasonable
const std::string settingsString{ R"(
{
"defaultProfile": "{6239a42c-3333-49a3-80bd-e8fdd045185c}",
"profiles": [
{
"name" : "profile0",
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
"historySize": 1
},
{
"name" : "profile1",
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}",
"historySize": 2
}
]
})" };
const auto settingsJsonObj = VerifyParseSucceeded(settingsString);
auto settings = CascadiaSettings::FromJson(settingsJsonObj);
settings->_ValidateSettings();

VERIFY_ARE_EQUAL(2u, settings->_warnings.size());
VERIFY_ARE_EQUAL(2u, settings->_profiles.size());
VERIFY_ARE_EQUAL(settings->_globals.GetDefaultProfile(), settings->_profiles.at(0).GetGuid());
try
{
const auto [guid, termSettings] = settings->BuildSettings(nullptr);
Comment thread
zadjii-msft marked this conversation as resolved.
VERIFY_ARE_NOT_EQUAL(nullptr, termSettings);
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
}
catch (...)
{
VERIFY_IS_TRUE(false, L"This call to BuildSettings should succeed");
}
}

void SettingsTests::TestLayerProfileOnColorScheme()
{
Log::Comment(NoThrowString().Format(
Expand Down
Loading