Store and expose hidden profiles (#8070)
## Summary of the Pull Request This PR replaces `CascadiaSettings::_profiles` with... - `_allProfiles`: the list of all available profiles in the settings model (i.e. settings.json, dynamic profiles, etc...) - `_activeProfiles`: the list of all non-hidden profiles (used for the new tab dropdown) ## References #8018: maintaining a list of all profiles allows us to serialize hidden profiles #1564: Settings UI can link to `AllProfiles()` instead of `ActiveProfiles()` to expose hidden profiles ## PR Checklist * [x] Closes #4139 * [x] Tests added/passed ## Validation Steps Performed Deploy and testing succeeded
This commit is contained in:
parent
e21f9f5ac6
commit
242833f8b2
File diff suppressed because it is too large
Load diff
|
@ -256,7 +256,7 @@ namespace SettingsModelLocalTests
|
|||
|
||||
auto settings = winrt::make_self<implementation::CascadiaSettings>();
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
|
@ -264,7 +264,7 @@ namespace SettingsModelLocalTests
|
|||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
|
||||
settings->_LayerOrCreateProfile(profile0Json);
|
||||
VERIFY_ARE_EQUAL(1u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(1u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
|
@ -272,7 +272,7 @@ namespace SettingsModelLocalTests
|
|||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
|
||||
settings->_LayerOrCreateProfile(profile1Json);
|
||||
VERIFY_ARE_EQUAL(2u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
|
@ -280,31 +280,31 @@ namespace SettingsModelLocalTests
|
|||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
|
||||
settings->_LayerOrCreateProfile(profile2Json);
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile3Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(0).Name());
|
||||
|
||||
settings->_LayerOrCreateProfile(profile3Json);
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile3Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_allProfiles.GetAt(0).Name());
|
||||
|
||||
settings->_LayerOrCreateProfile(profile4Json);
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile0Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile1Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile2Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile3Json));
|
||||
VERIFY_IS_NOT_NULL(settings->_FindMatchingProfile(profile4Json));
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_allProfiles.GetAt(0).Name());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -139,9 +139,9 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
auto keymap = settings.GlobalSettings().KeyMap();
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
const auto profile2Guid = settings.Profiles().GetAt(2).Guid();
|
||||
const auto profile2Guid = settings.ActiveProfiles().GetAt(2).Guid();
|
||||
VERIFY_ARE_NOT_EQUAL(winrt::guid{}, profile2Guid);
|
||||
|
||||
VERIFY_ARE_EQUAL(12u, keymap.Size());
|
||||
|
@ -478,8 +478,8 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsString) };
|
||||
|
||||
VERIFY_ARE_EQUAL(2u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(settings.GlobalSettings().DefaultProfile(), settings.Profiles().GetAt(0).Guid());
|
||||
VERIFY_ARE_EQUAL(2u, settings.ActiveProfiles().Size());
|
||||
VERIFY_ARE_EQUAL(settings.GlobalSettings().DefaultProfile(), settings.ActiveProfiles().GetAt(0).Guid());
|
||||
try
|
||||
{
|
||||
const auto [guid, termSettings] = winrt::TerminalApp::implementation::TerminalSettings::BuildSettings(settings, nullptr, nullptr);
|
||||
|
@ -540,7 +540,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
CascadiaSettings settings{ til::u8u16(settings0String) };
|
||||
|
||||
VERIFY_ARE_EQUAL(6u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(6u, settings.ActiveProfiles().Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings.GlobalSettings().ColorSchemes().Size());
|
||||
|
||||
auto createTerminalSettings = [&](const auto& profile, const auto& schemes) {
|
||||
|
@ -549,12 +549,12 @@ namespace TerminalAppLocalTests
|
|||
return terminalSettings;
|
||||
};
|
||||
|
||||
auto terminalSettings0 = createTerminalSettings(settings.Profiles().GetAt(0), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings1 = createTerminalSettings(settings.Profiles().GetAt(1), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings2 = createTerminalSettings(settings.Profiles().GetAt(2), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings3 = createTerminalSettings(settings.Profiles().GetAt(3), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings4 = createTerminalSettings(settings.Profiles().GetAt(4), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings5 = createTerminalSettings(settings.Profiles().GetAt(5), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings0 = createTerminalSettings(settings.ActiveProfiles().GetAt(0), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings1 = createTerminalSettings(settings.ActiveProfiles().GetAt(1), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings2 = createTerminalSettings(settings.ActiveProfiles().GetAt(2), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings3 = createTerminalSettings(settings.ActiveProfiles().GetAt(3), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings4 = createTerminalSettings(settings.ActiveProfiles().GetAt(4), settings.GlobalSettings().ColorSchemes());
|
||||
auto terminalSettings5 = createTerminalSettings(settings.ActiveProfiles().GetAt(5), settings.GlobalSettings().ColorSchemes());
|
||||
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x12, 0x34, 0x56), terminalSettings0->CursorColor()); // from color scheme
|
||||
VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1->CursorColor()); // default
|
||||
|
@ -609,7 +609,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
@ -632,7 +632,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -736,7 +736,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
@ -759,7 +759,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -865,7 +865,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
@ -888,7 +888,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1002,10 +1002,10 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1097,10 +1097,10 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1220,10 +1220,10 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1357,10 +1357,10 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1460,10 +1460,10 @@ namespace TerminalAppLocalTests
|
|||
CascadiaSettings settings{ til::u8u16(settingsJson) };
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings.Warnings().Size());
|
||||
|
@ -1602,7 +1602,7 @@ namespace TerminalAppLocalTests
|
|||
// we add a warning saying "the color scheme is unknown"
|
||||
VERIFY_ARE_EQUAL(1u, settings.Warnings().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings.Profiles().Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings.ActiveProfiles().Size());
|
||||
|
||||
auto commands = settings.GlobalSettings().Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
@ -1625,7 +1625,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${scheme.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.Profiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
auto expandedCommands = winrt::TerminalApp::implementation::TerminalPage::_ExpandCommands(commands, settings.ActiveProfiles().GetView(), settings.GlobalSettings().ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
// This is the same warning as above
|
||||
|
|
|
@ -139,7 +139,7 @@ winrt::fire_and_forget Jumplist::UpdateJumplist(const CascadiaSettings& settings
|
|||
THROW_IF_FAILED(jumplistItems->Clear());
|
||||
|
||||
// Update the list of profiles.
|
||||
THROW_IF_FAILED(_updateProfiles(jumplistItems.get(), strongSettings.Profiles().GetView()));
|
||||
THROW_IF_FAILED(_updateProfiles(jumplistItems.get(), strongSettings.ActiveProfiles().GetView()));
|
||||
|
||||
// TODO GH#1571: Add items from the future customizable new tab dropdown as well.
|
||||
// This could either replace the default profiles, or be added alongside them.
|
||||
|
|
|
@ -425,10 +425,10 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
const auto defaultProfileGuid = _settings.GlobalSettings().DefaultProfile();
|
||||
// the number of profiles should not change in the loop for this to work
|
||||
auto const profileCount = gsl::narrow_cast<int>(_settings.Profiles().Size());
|
||||
auto const profileCount = gsl::narrow_cast<int>(_settings.ActiveProfiles().Size());
|
||||
for (int profileIndex = 0; profileIndex < profileCount; profileIndex++)
|
||||
{
|
||||
const auto profile = _settings.Profiles().GetAt(profileIndex);
|
||||
const auto profile = _settings.ActiveProfiles().GetAt(profileIndex);
|
||||
auto profileMenuItem = WUX::Controls::MenuFlyoutItem{};
|
||||
|
||||
// Add the keyboard shortcuts based on the number of profiles defined
|
||||
|
@ -2066,7 +2066,7 @@ namespace winrt::TerminalApp::implementation
|
|||
_HookupKeyBindings(_settings.KeyMap());
|
||||
|
||||
// Refresh UI elements
|
||||
auto profiles = _settings.Profiles();
|
||||
auto profiles = _settings.ActiveProfiles();
|
||||
for (const auto& profile : profiles)
|
||||
{
|
||||
const auto profileGuid = profile.Guid();
|
||||
|
@ -2179,7 +2179,7 @@ namespace winrt::TerminalApp::implementation
|
|||
void TerminalPage::_UpdateCommandsForPalette()
|
||||
{
|
||||
IMap<winrt::hstring, Command> copyOfCommands = _ExpandCommands(_settings.GlobalSettings().Commands(),
|
||||
_settings.Profiles().GetView(),
|
||||
_settings.ActiveProfiles().GetView(),
|
||||
_settings.GlobalSettings().ColorSchemes());
|
||||
|
||||
_recursiveUpdateCommandKeybindingLabels(_settings, copyOfCommands.GetView());
|
||||
|
|
|
@ -45,7 +45,8 @@ CascadiaSettings::CascadiaSettings() :
|
|||
// - addDynamicProfiles: if true, we'll add the built-in DPGs.
|
||||
CascadiaSettings::CascadiaSettings(const bool addDynamicProfiles) :
|
||||
_globals{ winrt::make_self<implementation::GlobalAppSettings>() },
|
||||
_profiles{ winrt::single_threaded_observable_vector<Model::Profile>() },
|
||||
_allProfiles{ winrt::single_threaded_observable_vector<Model::Profile>() },
|
||||
_activeProfiles{ winrt::single_threaded_observable_vector<Model::Profile>() },
|
||||
_warnings{ winrt::single_threaded_vector<SettingsLoadWarnings>() },
|
||||
_deserializationErrorMessage{ L"" }
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ void CascadiaSettings::_CopyProfileInheritanceTree(winrt::com_ptr<CascadiaSettin
|
|||
// we now have a root. So we'll do just that, then copy the inheritance graph
|
||||
// from the dummyRoot.
|
||||
auto dummyRootSource{ winrt::make_self<Profile>() };
|
||||
for (const auto& profile : _profiles)
|
||||
for (const auto& profile : _allProfiles)
|
||||
{
|
||||
winrt::com_ptr<Profile> profileImpl;
|
||||
profileImpl.copy_from(winrt::get_self<Profile>(profile));
|
||||
|
@ -124,7 +125,11 @@ void CascadiaSettings::_CopyProfileInheritanceTree(winrt::com_ptr<CascadiaSettin
|
|||
const auto cloneParents{ dummyRootClone->Parents() };
|
||||
for (const auto& profile : cloneParents)
|
||||
{
|
||||
cloneSettings->_profiles.Append(*profile);
|
||||
cloneSettings->_allProfiles.Append(*profile);
|
||||
if (!profile->Hidden())
|
||||
{
|
||||
cloneSettings->_activeProfiles.Append(*profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +144,7 @@ void CascadiaSettings::_CopyProfileInheritanceTree(winrt::com_ptr<CascadiaSettin
|
|||
winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::FindProfile(winrt::guid profileGuid) const noexcept
|
||||
{
|
||||
const winrt::guid guid{ profileGuid };
|
||||
for (auto profile : _profiles)
|
||||
for (const auto& profile : _allProfiles)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -159,9 +164,20 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::FindProfi
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - an iterable collection of all of our Profiles.
|
||||
IObservableVector<winrt::Microsoft::Terminal::Settings::Model::Profile> CascadiaSettings::Profiles() const noexcept
|
||||
IObservableVector<winrt::Microsoft::Terminal::Settings::Model::Profile> CascadiaSettings::AllProfiles() const noexcept
|
||||
{
|
||||
return _profiles;
|
||||
return _allProfiles;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Returns an iterable collection of all of our non-hidden Profiles.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - an iterable collection of all of our Profiles.
|
||||
IObservableVector<winrt::Microsoft::Terminal::Settings::Model::Profile> CascadiaSettings::ActiveProfiles() const noexcept
|
||||
{
|
||||
return _activeProfiles;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -242,7 +258,7 @@ void CascadiaSettings::_ValidateSettings()
|
|||
|
||||
// Remove hidden profiles _after_ re-ordering. The re-ordering uses the raw
|
||||
// json, and will get confused if the profile isn't in the list.
|
||||
_RemoveHiddenProfiles();
|
||||
_UpdateActiveProfiles();
|
||||
|
||||
// Then do some validation on the profiles. The order of these does not
|
||||
// terribly matter.
|
||||
|
@ -279,7 +295,7 @@ void CascadiaSettings::_ValidateSettings()
|
|||
// profiles at all, we'll throw an error if there aren't any profiles.
|
||||
void CascadiaSettings::_ValidateProfilesExist()
|
||||
{
|
||||
const bool hasProfiles = _profiles.Size() > 0;
|
||||
const bool hasProfiles = _allProfiles.Size() > 0;
|
||||
if (!hasProfiles)
|
||||
{
|
||||
// Throw an exception. This is an invalid state, and we want the app to
|
||||
|
@ -298,7 +314,7 @@ void CascadiaSettings::_ValidateProfilesExist()
|
|||
// temporary runtime GUID for it. This validation does not add any warnings.
|
||||
void CascadiaSettings::_ValidateProfilesHaveGuid()
|
||||
{
|
||||
for (auto profile : _profiles)
|
||||
for (auto profile : _allProfiles)
|
||||
{
|
||||
auto profileImpl = winrt::get_self<implementation::Profile>(profile);
|
||||
profileImpl->GenerateGuidIfNecessary();
|
||||
|
@ -331,7 +347,7 @@ void CascadiaSettings::_ValidateDefaultProfileExists()
|
|||
const winrt::guid defaultProfileGuid{ GlobalSettings().DefaultProfile() };
|
||||
const bool nullDefaultProfile = defaultProfileGuid == winrt::guid{};
|
||||
bool defaultProfileNotInProfiles = true;
|
||||
for (const auto& profile : _profiles)
|
||||
for (const auto& profile : _allProfiles)
|
||||
{
|
||||
if (profile.Guid() == defaultProfileGuid)
|
||||
{
|
||||
|
@ -347,7 +363,7 @@ void CascadiaSettings::_ValidateDefaultProfileExists()
|
|||
|
||||
// _temporarily_ set the default profile to the first profile. Because
|
||||
// we're adding a warning, this settings change won't be re-serialized.
|
||||
GlobalSettings().DefaultProfile(_profiles.GetAt(0).Guid());
|
||||
GlobalSettings().DefaultProfile(_allProfiles.GetAt(0).Guid());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,9 +383,9 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles()
|
|||
|
||||
// Try collecting all the unique guids. If we ever encounter a guid that's
|
||||
// already in the set, then we need to delete that profile.
|
||||
for (uint32_t i = 0; i < _profiles.Size(); i++)
|
||||
for (uint32_t i = 0; i < _allProfiles.Size(); i++)
|
||||
{
|
||||
if (!uniqueGuids.insert(_profiles.GetAt(i).Guid()).second)
|
||||
if (!uniqueGuids.insert(_allProfiles.GetAt(i).Guid()).second)
|
||||
{
|
||||
foundDupe = true;
|
||||
indicesToDelete.push_back(i);
|
||||
|
@ -380,7 +396,7 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles()
|
|||
// Walk backwards, so we don't accidentally shift any of the elements
|
||||
for (auto iter = indicesToDelete.rbegin(); iter != indicesToDelete.rend(); iter++)
|
||||
{
|
||||
_profiles.RemoveAt(*iter);
|
||||
_allProfiles.RemoveAt(*iter);
|
||||
}
|
||||
|
||||
if (foundDupe)
|
||||
|
@ -423,7 +439,7 @@ void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder()
|
|||
// Push all the defaultSettings profiles' GUIDS into the set
|
||||
collectGuids(_defaultSettings);
|
||||
std::equal_to<winrt::guid> equals;
|
||||
// Re-order the list of _profiles to match that ordering
|
||||
// Re-order the list of profiles to match that ordering
|
||||
// for (gIndex=0 -> uniqueGuids.size)
|
||||
// pIndex = the pIndex of the profile with guid==guids[gIndex]
|
||||
// profiles.swap(pIndex <-> gIndex)
|
||||
|
@ -431,14 +447,14 @@ void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder()
|
|||
for (uint32_t gIndex = 0; gIndex < guidOrder.size(); gIndex++)
|
||||
{
|
||||
const auto guid = guidOrder.at(gIndex);
|
||||
for (uint32_t pIndex = gIndex; pIndex < _profiles.Size(); pIndex++)
|
||||
for (uint32_t pIndex = gIndex; pIndex < _allProfiles.Size(); pIndex++)
|
||||
{
|
||||
auto profileGuid = _profiles.GetAt(pIndex).Guid();
|
||||
auto profileGuid = _allProfiles.GetAt(pIndex).Guid();
|
||||
if (equals(profileGuid, guid))
|
||||
{
|
||||
auto prof1 = _profiles.GetAt(pIndex);
|
||||
_profiles.SetAt(pIndex, _profiles.GetAt(gIndex));
|
||||
_profiles.SetAt(gIndex, prof1);
|
||||
auto prof1 = _allProfiles.GetAt(pIndex);
|
||||
_allProfiles.SetAt(pIndex, _allProfiles.GetAt(gIndex));
|
||||
_allProfiles.SetAt(gIndex, prof1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -446,30 +462,27 @@ void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder()
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// - Removes any profiles marked "hidden" from the list of profiles.
|
||||
// - Updates the list of active profiles from the list of all profiles
|
||||
// - If there are no active profiles (all profiles are hidden), throw a SettingsException
|
||||
// - Does not set any warnings.
|
||||
// Arguments:
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void CascadiaSettings::_RemoveHiddenProfiles()
|
||||
void CascadiaSettings::_UpdateActiveProfiles()
|
||||
{
|
||||
for (uint32_t i = 0; i < _profiles.Size();)
|
||||
_activeProfiles.Clear();
|
||||
for (auto const& profile : _allProfiles)
|
||||
{
|
||||
if (_profiles.GetAt(i).Hidden())
|
||||
if (!profile.Hidden())
|
||||
{
|
||||
// remove hidden profile, don't increment 'i'
|
||||
_profiles.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
_activeProfiles.Append(profile);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that we still have some profiles here. If we don't, then throw an
|
||||
// exception, so the app can use the defaults.
|
||||
const bool hasProfiles = _profiles.Size() > 0;
|
||||
const bool hasProfiles = _activeProfiles.Size() > 0;
|
||||
if (!hasProfiles)
|
||||
{
|
||||
// Throw an exception. This is an invalid state, and we want the app to
|
||||
|
@ -491,7 +504,7 @@ void CascadiaSettings::_RemoveHiddenProfiles()
|
|||
void CascadiaSettings::_ValidateAllSchemesExist()
|
||||
{
|
||||
bool foundInvalidScheme = false;
|
||||
for (auto profile : _profiles)
|
||||
for (auto profile : _allProfiles)
|
||||
{
|
||||
const auto schemeName = profile.ColorSchemeName();
|
||||
if (!_globals->ColorSchemes().HasKey(schemeName))
|
||||
|
@ -523,7 +536,7 @@ void CascadiaSettings::_ValidateMediaResources()
|
|||
bool invalidBackground{ false };
|
||||
bool invalidIcon{ false };
|
||||
|
||||
for (auto profile : _profiles)
|
||||
for (auto profile : _allProfiles)
|
||||
{
|
||||
if (!profile.BackgroundImagePath().empty())
|
||||
{
|
||||
|
@ -635,7 +648,7 @@ try
|
|||
// Here, we were unable to use the profile string as a GUID to
|
||||
// lookup a profile. Instead, try using the string to look the
|
||||
// Profile up by name.
|
||||
for (auto profile : _profiles)
|
||||
for (auto profile : _allProfiles)
|
||||
{
|
||||
if (profile.Name() == name)
|
||||
{
|
||||
|
@ -669,9 +682,9 @@ std::optional<winrt::guid> CascadiaSettings::_GetProfileGuidByIndex(std::optiona
|
|||
const auto realIndex{ index.value() };
|
||||
// If we don't have that many profiles, then do nothing.
|
||||
if (realIndex >= 0 &&
|
||||
realIndex < gsl::narrow_cast<decltype(realIndex)>(_profiles.Size()))
|
||||
realIndex < gsl::narrow_cast<decltype(realIndex)>(_activeProfiles.Size()))
|
||||
{
|
||||
const auto& selectedProfile = _profiles.GetAt(realIndex);
|
||||
const auto& selectedProfile = _activeProfiles.GetAt(realIndex);
|
||||
return selectedProfile.Guid();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
static Model::CascadiaSettings LoadUniversal();
|
||||
|
||||
Model::GlobalAppSettings GlobalSettings() const;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> Profiles() const noexcept;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> AllProfiles() const noexcept;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> ActiveProfiles() const noexcept;
|
||||
Model::KeyMapping KeyMap() const noexcept;
|
||||
|
||||
static com_ptr<CascadiaSettings> FromJson(const Json::Value& json);
|
||||
|
@ -92,7 +93,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
|
||||
private:
|
||||
com_ptr<GlobalAppSettings> _globals;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> _profiles;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> _allProfiles;
|
||||
Windows::Foundation::Collections::IObservableVector<Model::Profile> _activeProfiles;
|
||||
Windows::Foundation::Collections::IVector<Model::SettingsLoadWarnings> _warnings;
|
||||
Windows::Foundation::IReference<SettingsLoadErrors> _loadError;
|
||||
hstring _deserializationErrorMessage;
|
||||
|
@ -136,7 +138,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
void _ValidateNoDuplicateProfiles();
|
||||
void _ResolveDefaultProfile();
|
||||
void _ReorderProfilesToMatchUserSettingsOrder();
|
||||
void _RemoveHiddenProfiles();
|
||||
void _UpdateActiveProfiles();
|
||||
void _ValidateAllSchemesExist();
|
||||
void _ValidateMediaResources();
|
||||
void _ValidateKeybindings();
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace Microsoft.Terminal.Settings.Model
|
|||
|
||||
GlobalAppSettings GlobalSettings { get; };
|
||||
|
||||
Windows.Foundation.Collections.IObservableVector<Profile> Profiles { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<Profile> AllProfiles { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<Profile> ActiveProfiles { get; };
|
||||
|
||||
KeyMapping KeyMap { get; };
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ void CascadiaSettings::_LoadDynamicProfiles()
|
|||
// we'll synthesize a GUID for it in _ValidateProfilesHaveGuid
|
||||
profile.Source(generatorNamespace);
|
||||
|
||||
_profiles.Append(profile);
|
||||
_allProfiles.Append(profile);
|
||||
}
|
||||
}
|
||||
CATCH_LOG_MSG("Dynamic Profile Namespace: \"%ls\"", generatorNamespace.data());
|
||||
|
@ -517,7 +517,7 @@ bool CascadiaSettings::_AppendDynamicProfilesToUserSettings()
|
|||
|
||||
bool changedFile = false;
|
||||
|
||||
for (const auto& profile : _profiles)
|
||||
for (const auto& profile : _allProfiles)
|
||||
{
|
||||
// Skip profiles that are in the user settings or the default settings.
|
||||
if (isInJsonObj(profile, _userSettings) || isInJsonObj(profile, _defaultSettings))
|
||||
|
@ -626,7 +626,7 @@ void CascadiaSettings::_LayerOrCreateProfile(const Json::Value& profileJson)
|
|||
auto profileIndex{ _FindMatchingProfileIndex(profileJson) };
|
||||
if (profileIndex)
|
||||
{
|
||||
auto parentProj{ _profiles.GetAt(*profileIndex) };
|
||||
auto parentProj{ _allProfiles.GetAt(*profileIndex) };
|
||||
auto parent{ winrt::get_self<Profile>(parentProj) };
|
||||
|
||||
if (_userDefaultProfileSettings)
|
||||
|
@ -643,7 +643,7 @@ void CascadiaSettings::_LayerOrCreateProfile(const Json::Value& profileJson)
|
|||
childImpl->LayerJson(profileJson);
|
||||
|
||||
// replace parent in _profiles with child
|
||||
_profiles.SetAt(*profileIndex, *childImpl);
|
||||
_allProfiles.SetAt(*profileIndex, *childImpl);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -663,7 +663,7 @@ void CascadiaSettings::_LayerOrCreateProfile(const Json::Value& profileJson)
|
|||
}
|
||||
|
||||
profile->LayerJson(profileJson);
|
||||
_profiles.Append(*profile);
|
||||
_allProfiles.Append(*profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ winrt::com_ptr<Profile> CascadiaSettings::_FindMatchingProfile(const Json::Value
|
|||
auto index{ _FindMatchingProfileIndex(profileJson) };
|
||||
if (index)
|
||||
{
|
||||
auto profile{ _profiles.GetAt(*index) };
|
||||
auto profile{ _allProfiles.GetAt(*index) };
|
||||
auto profileImpl{ winrt::get_self<Profile>(profile) };
|
||||
return profileImpl->get_strong();
|
||||
}
|
||||
|
@ -703,9 +703,9 @@ winrt::com_ptr<Profile> CascadiaSettings::_FindMatchingProfile(const Json::Value
|
|||
// - The index for the matching Profile, iff it exists. Otherwise, nullopt.
|
||||
std::optional<uint32_t> CascadiaSettings::_FindMatchingProfileIndex(const Json::Value& profileJson)
|
||||
{
|
||||
for (uint32_t i = 0; i < _profiles.Size(); ++i)
|
||||
for (uint32_t i = 0; i < _allProfiles.Size(); ++i)
|
||||
{
|
||||
const auto profile{ _profiles.GetAt(i) };
|
||||
const auto profile{ _allProfiles.GetAt(i) };
|
||||
const auto profileImpl = winrt::get_self<Profile>(profile);
|
||||
if (profileImpl->ShouldBeLayered(profileJson))
|
||||
{
|
||||
|
@ -750,11 +750,11 @@ void CascadiaSettings::_ApplyDefaultsFromUserSettings()
|
|||
_userDefaultProfileSettings = winrt::make_self<Profile>();
|
||||
_userDefaultProfileSettings->LayerJson(defaultSettings);
|
||||
|
||||
const auto numOfProfiles{ _profiles.Size() };
|
||||
const auto numOfProfiles{ _allProfiles.Size() };
|
||||
for (uint32_t profileIndex = 0; profileIndex < numOfProfiles; ++profileIndex)
|
||||
{
|
||||
// create a child, so we inherit from the defaults.json layer
|
||||
auto parentProj{ _profiles.GetAt(profileIndex) };
|
||||
auto parentProj{ _allProfiles.GetAt(profileIndex) };
|
||||
auto parentImpl{ winrt::get_self<Profile>(parentProj) };
|
||||
auto childImpl{ parentImpl->CreateChild() };
|
||||
|
||||
|
@ -762,7 +762,7 @@ void CascadiaSettings::_ApplyDefaultsFromUserSettings()
|
|||
childImpl->InsertParent(0, _userDefaultProfileSettings);
|
||||
|
||||
// replace parent in _profiles with child
|
||||
_profiles.SetAt(profileIndex, *childImpl);
|
||||
_allProfiles.SetAt(profileIndex, *childImpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,13 +99,13 @@ namespace TerminalAppUnitTests
|
|||
settings->_profileGenerators.emplace_back(std::move(gen1));
|
||||
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(2u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).HasGuid());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).HasGuid());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).HasGuid());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).HasGuid());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::TestGenGuidsForProfiles()
|
||||
|
@ -119,7 +119,7 @@ namespace TerminalAppUnitTests
|
|||
gen0->pfnGenerate = []() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0;
|
||||
p0.Name(L"profile0"); // this is _profiles.at(2)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(2)
|
||||
profiles.push_back(p0);
|
||||
return profiles;
|
||||
};
|
||||
|
@ -127,8 +127,8 @@ namespace TerminalAppUnitTests
|
|||
gen1->pfnGenerate = []() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0, p1;
|
||||
p0.Name(L"profile0"); // this is _profiles.at(3)
|
||||
p1.Name(L"profile1"); // this is _profiles.at(4)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(3)
|
||||
p1.Name(L"profile1"); // this is _allProfiles.at(4)
|
||||
profiles.push_back(p0);
|
||||
profiles.push_back(p1);
|
||||
return profiles;
|
||||
|
@ -139,54 +139,54 @@ namespace TerminalAppUnitTests
|
|||
settings->_profileGenerators.emplace_back(std::move(gen1));
|
||||
|
||||
Profile p0, p1;
|
||||
p0.Name(L"profile0"); // this is _profiles.GetAt(0)
|
||||
p1.Name(L"profile1"); // this is _profiles.GetAt(1)
|
||||
settings->_profiles.Append(p0);
|
||||
settings->_profiles.Append(p1);
|
||||
p0.Name(L"profile0"); // this is _allProfiles.GetAt(0)
|
||||
p1.Name(L"profile1"); // this is _allProfiles.GetAt(1)
|
||||
settings->_allProfiles.Append(p0);
|
||||
settings->_allProfiles.Append(p1);
|
||||
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(5u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(5u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(2).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(2).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(3).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(3).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(3).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(3).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_profiles.GetAt(4).Name());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(4).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(4).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_allProfiles.GetAt(4).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(4).HasGuid());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(4).Source().empty());
|
||||
|
||||
settings->_ValidateProfilesHaveGuid();
|
||||
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(4).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(4).HasGuid());
|
||||
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_profiles.GetAt(0).Guid(),
|
||||
settings->_profiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_profiles.GetAt(0).Guid(),
|
||||
settings->_profiles.GetAt(2).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_profiles.GetAt(0).Guid(),
|
||||
settings->_profiles.GetAt(3).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_allProfiles.GetAt(0).Guid(),
|
||||
settings->_allProfiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_allProfiles.GetAt(0).Guid(),
|
||||
settings->_allProfiles.GetAt(2).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_allProfiles.GetAt(0).Guid(),
|
||||
settings->_allProfiles.GetAt(3).Guid());
|
||||
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_profiles.GetAt(1).Guid(),
|
||||
settings->_profiles.GetAt(4).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_allProfiles.GetAt(1).Guid(),
|
||||
settings->_allProfiles.GetAt(4).Guid());
|
||||
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_profiles.GetAt(3).Guid(),
|
||||
settings->_profiles.GetAt(4).Guid());
|
||||
VERIFY_ARE_NOT_EQUAL(settings->_allProfiles.GetAt(3).Guid(),
|
||||
settings->_allProfiles.GetAt(4).Guid());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::DontLayerUserProfilesOnDynamicProfiles()
|
||||
|
@ -212,7 +212,7 @@ namespace TerminalAppUnitTests
|
|||
gen0->pfnGenerate = [guid0, guid1]() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(0)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(0)
|
||||
profiles.push_back(p0);
|
||||
return profiles;
|
||||
};
|
||||
|
@ -221,8 +221,8 @@ namespace TerminalAppUnitTests
|
|||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
Profile p1 = winrt::make<implementation::Profile>(guid1);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _profiles.at(2)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _allProfiles.at(2)
|
||||
profiles.push_back(p0);
|
||||
profiles.push_back(p1);
|
||||
return profiles;
|
||||
|
@ -238,33 +238,33 @@ namespace TerminalAppUnitTests
|
|||
|
||||
// parse userProfiles as the user settings
|
||||
settings->_ParseJsonString(userProfiles, false);
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size(), L"Just parsing the user settings doesn't actually layer them");
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size(), L"Just parsing the user settings doesn't actually layer them");
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_EQUAL(5u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(5u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(3).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(4).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(3).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(4).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.0", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.0", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(2).Source());
|
||||
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(4).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(3).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(4).HasGuid());
|
||||
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_profiles.GetAt(0).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_profiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_profiles.GetAt(2).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_profiles.GetAt(3).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_profiles.GetAt(4).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_allProfiles.GetAt(0).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_allProfiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_allProfiles.GetAt(2).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_allProfiles.GetAt(3).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_allProfiles.GetAt(4).Guid());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::DoLayerUserProfilesOnDynamicsWhenSourceMatches()
|
||||
|
@ -276,12 +276,12 @@ namespace TerminalAppUnitTests
|
|||
{
|
||||
"profiles": [
|
||||
{
|
||||
"name" : "profile0FromUserSettings", // this is _profiles.at(0)
|
||||
"name" : "profile0FromUserSettings", // this is _allProfiles.at(0)
|
||||
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
|
||||
"source": "Terminal.App.UnitTest.0"
|
||||
},
|
||||
{
|
||||
"name" : "profile1FromUserSettings", // this is _profiles.at(2)
|
||||
"name" : "profile1FromUserSettings", // this is _allProfiles.at(2)
|
||||
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}",
|
||||
"source": "Terminal.App.UnitTest.1"
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ namespace TerminalAppUnitTests
|
|||
gen0->pfnGenerate = [guid0, guid1]() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(0)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(0)
|
||||
profiles.push_back(p0);
|
||||
return profiles;
|
||||
};
|
||||
|
@ -301,8 +301,8 @@ namespace TerminalAppUnitTests
|
|||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
Profile p1 = winrt::make<implementation::Profile>(guid1);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _profiles.at(2)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _allProfiles.at(2)
|
||||
profiles.push_back(p0);
|
||||
profiles.push_back(p1);
|
||||
return profiles;
|
||||
|
@ -318,31 +318,31 @@ namespace TerminalAppUnitTests
|
|||
|
||||
// parse userProfiles as the user settings
|
||||
settings->_ParseJsonString(userProfiles, false);
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size(), L"Just parsing the user settings doesn't actually layer them");
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size(), L"Just parsing the user settings doesn't actually layer them");
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.0", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.0", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(2).Source());
|
||||
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(2).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(0).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(1).HasGuid());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(2).HasGuid());
|
||||
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_profiles.GetAt(0).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_profiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_profiles.GetAt(2).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_allProfiles.GetAt(0).Guid());
|
||||
VERIFY_ARE_EQUAL(guid0, settings->_allProfiles.GetAt(1).Guid());
|
||||
VERIFY_ARE_EQUAL(guid1, settings->_allProfiles.GetAt(2).Guid());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0FromUserSettings", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1FromUserSettings", settings->_profiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile0FromUserSettings", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1FromUserSettings", settings->_allProfiles.GetAt(2).Name());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::TestDontRunDisabledGenerators()
|
||||
|
@ -405,19 +405,19 @@ namespace TerminalAppUnitTests
|
|||
settings->_ParseJsonString(settings0String, false);
|
||||
settings->_LoadDynamicProfiles();
|
||||
|
||||
VERIFY_ARE_EQUAL(4u, settings->_profiles.Size());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(3).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_profiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_profiles.GetAt(3).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_profiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_profiles.GetAt(3).Name());
|
||||
VERIFY_ARE_EQUAL(4u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(3).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.1", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_allProfiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_allProfiles.GetAt(3).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_allProfiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_allProfiles.GetAt(3).Name());
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -438,13 +438,13 @@ namespace TerminalAppUnitTests
|
|||
settings->_ParseJsonString(settings1String, false);
|
||||
settings->_LoadDynamicProfiles();
|
||||
|
||||
VERIFY_ARE_EQUAL(2u, settings->_profiles.Size());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_allProfiles.Size());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Terminal.App.UnitTest.2", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4", settings->_allProfiles.GetAt(1).Name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,27 +461,27 @@ namespace TerminalAppUnitTests
|
|||
"profiles": [
|
||||
{
|
||||
// This pwsh profile does not have a source, but should still be layered
|
||||
"name" : "profile0FromUserSettings", // this is _profiles.at(0)
|
||||
"name" : "profile0FromUserSettings", // this is _allProfiles.at(0)
|
||||
"guid": "{6239a42c-0000-49a3-80bd-e8fdd045185c}"
|
||||
},
|
||||
{
|
||||
// This Azure profile does not have a source, but should still be layered
|
||||
"name" : "profile3FromUserSettings", // this is _profiles.at(3)
|
||||
"name" : "profile3FromUserSettings", // this is _allProfiles.at(3)
|
||||
"guid": "{6239a42c-3333-49a3-80bd-e8fdd045185c}"
|
||||
},
|
||||
{
|
||||
// This profile did not come from a dynamic source
|
||||
"name" : "profile4FromUserSettings", // this is _profiles.at(4)
|
||||
"name" : "profile4FromUserSettings", // this is _allProfiles.at(4)
|
||||
"guid": "{6239a42c-4444-49a3-80bd-e8fdd045185c}"
|
||||
},
|
||||
{
|
||||
// This WSL profile does not have a source, but should still be layered
|
||||
"name" : "profile1FromUserSettings", // this is _profiles.at(1)
|
||||
"name" : "profile1FromUserSettings", // this is _allProfiles.at(1)
|
||||
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}"
|
||||
},
|
||||
{
|
||||
// This WSL profile does have a source, and should be layered
|
||||
"name" : "profile2FromUserSettings", // this is _profiles.at(2)
|
||||
"name" : "profile2FromUserSettings", // this is _allProfiles.at(2)
|
||||
"guid": "{6239a42c-2222-49a3-80bd-e8fdd045185c}",
|
||||
"source": "Windows.Terminal.Wsl"
|
||||
}
|
||||
|
@ -522,42 +522,42 @@ namespace TerminalAppUnitTests
|
|||
settings->_profileGenerators.emplace_back(std::move(gen2));
|
||||
|
||||
settings->_ParseJsonString(settings0String, false);
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size());
|
||||
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(4u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(4u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(3).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.PowershellCore", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_profiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Azure", settings->_profiles.GetAt(3).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2", settings->_profiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_profiles.GetAt(3).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(3).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.PowershellCore", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_allProfiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Azure", settings->_allProfiles.GetAt(3).Source());
|
||||
VERIFY_ARE_EQUAL(L"profile0", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2", settings->_allProfiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3", settings->_allProfiles.GetAt(3).Name());
|
||||
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_EQUAL(5u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(5u, settings->_allProfiles.Size());
|
||||
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_profiles.GetAt(3).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_profiles.GetAt(4).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.PowershellCore", settings->_profiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_profiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_profiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Azure", settings->_profiles.GetAt(3).Source());
|
||||
// settings->_profiles.GetAt(4) does not have a source
|
||||
VERIFY_ARE_EQUAL(L"profile0FromUserSettings", settings->_profiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1FromUserSettings", settings->_profiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2FromUserSettings", settings->_profiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3FromUserSettings", settings->_profiles.GetAt(3).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4FromUserSettings", settings->_profiles.GetAt(4).Name());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(0).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(1).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(2).Source().empty());
|
||||
VERIFY_IS_FALSE(settings->_allProfiles.GetAt(3).Source().empty());
|
||||
VERIFY_IS_TRUE(settings->_allProfiles.GetAt(4).Source().empty());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.PowershellCore", settings->_allProfiles.GetAt(0).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_allProfiles.GetAt(1).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Wsl", settings->_allProfiles.GetAt(2).Source());
|
||||
VERIFY_ARE_EQUAL(L"Windows.Terminal.Azure", settings->_allProfiles.GetAt(3).Source());
|
||||
// settings->_allProfiles.GetAt(4) does not have a source
|
||||
VERIFY_ARE_EQUAL(L"profile0FromUserSettings", settings->_allProfiles.GetAt(0).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile1FromUserSettings", settings->_allProfiles.GetAt(1).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile2FromUserSettings", settings->_allProfiles.GetAt(2).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile3FromUserSettings", settings->_allProfiles.GetAt(3).Name());
|
||||
VERIFY_ARE_EQUAL(L"profile4FromUserSettings", settings->_allProfiles.GetAt(4).Name());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::UserProfilesWithInvalidSourcesAreIgnored()
|
||||
|
@ -569,7 +569,7 @@ namespace TerminalAppUnitTests
|
|||
{
|
||||
"profiles": [
|
||||
{
|
||||
"name" : "profile0FromUserSettings", // this is _profiles.at(0)
|
||||
"name" : "profile0FromUserSettings", // this is _allProfiles.at(0)
|
||||
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
|
||||
"source": "Terminal.App.UnitTest.0"
|
||||
},
|
||||
|
@ -579,7 +579,7 @@ namespace TerminalAppUnitTests
|
|||
"source": "Terminal.App.UnitTest.1"
|
||||
},
|
||||
{
|
||||
"name" : "profile3", // this is _profiles.at(3)
|
||||
"name" : "profile3", // this is _allProfiles.at(3)
|
||||
"guid": "{6239a42c-4444-49a3-80bd-e8fdd045185c}"
|
||||
}
|
||||
]
|
||||
|
@ -589,7 +589,7 @@ namespace TerminalAppUnitTests
|
|||
gen0->pfnGenerate = [guid0, guid1]() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(0)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(0)
|
||||
profiles.push_back(p0);
|
||||
return profiles;
|
||||
};
|
||||
|
@ -598,8 +598,8 @@ namespace TerminalAppUnitTests
|
|||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
Profile p1 = winrt::make<implementation::Profile>(guid1);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _profiles.at(2)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(1)
|
||||
p1.Name(L"profile1"); // this is _allProfiles.at(2)
|
||||
profiles.push_back(p0);
|
||||
profiles.push_back(p1);
|
||||
return profiles;
|
||||
|
@ -610,13 +610,13 @@ namespace TerminalAppUnitTests
|
|||
settings->_profileGenerators.emplace_back(std::move(gen1));
|
||||
|
||||
settings->_ParseJsonString(settings0String, false);
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size());
|
||||
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_allProfiles.Size());
|
||||
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_EQUAL(4u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(4u, settings->_allProfiles.Size());
|
||||
}
|
||||
|
||||
void DynamicProfileTests::UserProfilesFromDisabledSourcesDontAppear()
|
||||
|
@ -629,7 +629,7 @@ namespace TerminalAppUnitTests
|
|||
"disabledProfileSources": ["Terminal.App.UnitTest.1"],
|
||||
"profiles": [
|
||||
{
|
||||
"name" : "profile0FromUserSettings", // this is _profiles.at(0)
|
||||
"name" : "profile0FromUserSettings", // this is _allProfiles.at(0)
|
||||
"guid": "{6239a42c-1111-49a3-80bd-e8fdd045185c}",
|
||||
"source": "Terminal.App.UnitTest.0"
|
||||
},
|
||||
|
@ -639,7 +639,7 @@ namespace TerminalAppUnitTests
|
|||
"source": "Terminal.App.UnitTest.1"
|
||||
},
|
||||
{
|
||||
"name" : "profile3", // this is _profiles.at(1)
|
||||
"name" : "profile3", // this is _allProfiles.at(1)
|
||||
"guid": "{6239a42c-4444-49a3-80bd-e8fdd045185c}"
|
||||
}
|
||||
]
|
||||
|
@ -649,7 +649,7 @@ namespace TerminalAppUnitTests
|
|||
gen0->pfnGenerate = [guid0, guid1]() {
|
||||
std::vector<Profile> profiles;
|
||||
Profile p0 = winrt::make<implementation::Profile>(guid0);
|
||||
p0.Name(L"profile0"); // this is _profiles.at(0)
|
||||
p0.Name(L"profile0"); // this is _allProfiles.at(0)
|
||||
profiles.push_back(p0);
|
||||
return profiles;
|
||||
};
|
||||
|
@ -670,13 +670,13 @@ namespace TerminalAppUnitTests
|
|||
settings->_profileGenerators.emplace_back(std::move(gen1));
|
||||
|
||||
settings->_ParseJsonString(settings0String, false);
|
||||
VERIFY_ARE_EQUAL(0u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_allProfiles.Size());
|
||||
|
||||
settings->_LoadDynamicProfiles();
|
||||
VERIFY_ARE_EQUAL(1u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(1u, settings->_allProfiles.Size());
|
||||
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_EQUAL(2u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_allProfiles.Size());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue