diff --git a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp index 9848044b25..a4446f984e 100644 --- a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp @@ -52,6 +52,9 @@ namespace TerminalAppLocalTests TEST_METHOD(TestLayerGlobalsOnRoot); + TEST_METHOD(TestProfileIconWithEnvVar); + TEST_METHOD(TestProfileBackgroundImageWithEnvVar); + TEST_CLASS_SETUP(ClassSetup) { InitializeJsonReader(); @@ -1366,4 +1369,49 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(guid3, settings._globals._defaultProfile); } } + void SettingsTests::TestProfileIconWithEnvVar() + { + const auto expectedPath = wil::ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\x_80.png"); + + const std::string settingsJson{ R"( + { + "profiles": [ + { + "name": "profile0", + "icon": "%WINDIR%\\System32\\x_80.png" + } + ] + })" }; + + VerifyParseSucceeded(settingsJson); + CascadiaSettings settings{}; + settings._ParseJsonString(settingsJson, false); + settings.LayerJson(settings._userSettings); + VERIFY_IS_FALSE(settings._profiles.empty(), 0); + VERIFY_ARE_EQUAL(expectedPath, settings._profiles[0].GetExpandedIconPath()); + } + void SettingsTests::TestProfileBackgroundImageWithEnvVar() + { + const auto expectedPath = wil::ExpandEnvironmentStringsW(L"%WINDIR%\\System32\\x_80.png"); + + const std::string settingsJson{ R"( + { + "profiles": [ + { + "name": "profile0", + "backgroundImage": "%WINDIR%\\System32\\x_80.png" + } + ] + })" }; + + VerifyParseSucceeded(settingsJson); + CascadiaSettings settings{}; + settings._ParseJsonString(settingsJson, false); + settings.LayerJson(settings._userSettings); + VERIFY_IS_FALSE(settings._profiles.empty(), 0); + + GlobalAppSettings globalSettings{}; + auto terminalSettings = settings._profiles[0].CreateTerminalSettings(globalSettings.GetColorSchemes()); + VERIFY_ARE_EQUAL(expectedPath, terminalSettings.BackgroundImage()); + } } diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp index b0bf89e3fa..70165a87c5 100644 --- a/src/cascadia/TerminalApp/Profile.cpp +++ b/src/cascadia/TerminalApp/Profile.cpp @@ -214,9 +214,9 @@ TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map(_backgroundImage.value().data()); + } + + return result; +} + // Method Description: // - Returns the name of this profile. // Arguments: diff --git a/src/cascadia/TerminalApp/Profile.h b/src/cascadia/TerminalApp/Profile.h index 26e488b56f..7b221a4fca 100644 --- a/src/cascadia/TerminalApp/Profile.h +++ b/src/cascadia/TerminalApp/Profile.h @@ -82,6 +82,9 @@ public: winrt::hstring GetExpandedIconPath() const; void SetIconPath(std::wstring_view path); + bool HasBackgroundImage() const noexcept; + winrt::hstring GetExpandedBackgroundImagePath() const; + bool GetCloseOnExit() const noexcept; bool IsHidden() const noexcept; diff --git a/src/inc/LibraryIncludes.h b/src/inc/LibraryIncludes.h index 91308664a0..d45d42bdac 100644 --- a/src/inc/LibraryIncludes.h +++ b/src/inc/LibraryIncludes.h @@ -54,6 +54,7 @@ #include #include #include +#include // GSL // Block GSL Multi Span include because it both has C++17 deprecated iterators