Repository: microsoft/terminal
File: src/cascadia/LocalTests_SettingsModel/TerminalSettingsTests.cpp (C++)

Code before:

        VERIFY_ARE_EQUAL(6u, settings->ActiveProfiles().Size());
        VERIFY_ARE_EQUAL(2u, settings->GlobalSettings().ColorSchemes().Size());

        auto createTerminalSettings = [&](const auto& profile, const auto& schemes) {
            auto terminalSettings{ winrt::make_self<implementation::TerminalSettings>() };
            terminalSettings->_ApplyProfileSettings(profile);
            terminalSettings->_ApplyAppearanceSettings(profile.DefaultAppearance(), schemes);
            return terminalSettings;
        };

        const auto activeProfiles = settings->ActiveProfiles();
        const auto colorSchemes = settings->GlobalSettings().ColorSchemes();
        const auto terminalSettings0 = createTerminalSettings(activeProfiles.GetAt(0), colorSchemes);
        const auto terminalSettings1 = createTerminalSettings(activeProfiles.GetAt(1), colorSchemes);
        const auto terminalSettings2 = createTerminalSettings(activeProfiles.GetAt(2), colorSchemes);
        const auto terminalSettings3 = createTerminalSettings(activeProfiles.GetAt(3), colorSchemes);
        const auto terminalSettings4 = createTerminalSettings(activeProfiles.GetAt(4), colorSchemes);
        const auto terminalSettings5 = createTerminalSettings(activeProfiles.GetAt(5), colorSchemes);

        VERIFY_ARE_EQUAL(ARGB(0, 0x12, 0x34, 0x56), terminalSettings0->CursorColor()); // from color scheme
        VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1->CursorColor()); // default
        VERIFY_ARE_EQUAL(ARGB(0, 0x23, 0x45, 0x67), terminalSettings2->CursorColor()); // from profile (trumps color scheme)
        VERIFY_ARE_EQUAL(ARGB(0, 0x34, 0x56, 0x78), terminalSettings3->CursorColor()); // from profile (not set in color scheme)
        VERIFY_ARE_EQUAL(ARGB(0, 0x45, 0x67, 0x89), terminalSettings4->CursorColor()); // from profile (no color scheme)
        VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings5->CursorColor()); // default
    }

    void TerminalSettingsTests::TestCommandlineToTitlePromotion()
    {
        static constexpr std::string_view settingsJson{ R"(
        {
            "defaultProfile": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
            "profiles": { "list": [
                {
                    "name": "profile0",
                    "guid": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
                    "historySize": 1,
                    "commandline": "cmd.exe"
                },
            ],
            "defaults": {
                "historySize": 29
            } }
        })" };

        const auto settings = winrt::make_self<implementation::CascadiaSettings>(settingsJson);

        { // just a profile (profile wins)
            NewTerminalArgs args{};
            args.Profile(L"profile0");

Review comment (suggestion):
Since we're no longer including `argb.h`, the standard `RGB` macro will create `COLORREF`s with a zero alpha, which is no different from the previous `ARGB` usage here.

Code after:

        VERIFY_ARE_EQUAL(6u, settings->ActiveProfiles().Size());
        VERIFY_ARE_EQUAL(2u, settings->GlobalSettings().ColorSchemes().Size());

        auto createTerminalSettings = [&](const auto& profile, const auto& schemes) {
            auto terminalSettings{ winrt::make_self<implementation::TerminalSettings>() };
            terminalSettings->_ApplyProfileSettings(profile);
            terminalSettings->_ApplyAppearanceSettings(profile.DefaultAppearance(), schemes);
            return terminalSettings;
        };

        const auto activeProfiles = settings->ActiveProfiles();
        const auto colorSchemes = settings->GlobalSettings().ColorSchemes();
        const auto terminalSettings0 = createTerminalSettings(activeProfiles.GetAt(0), colorSchemes);
        const auto terminalSettings1 = createTerminalSettings(activeProfiles.GetAt(1), colorSchemes);
        const auto terminalSettings2 = createTerminalSettings(activeProfiles.GetAt(2), colorSchemes);
        const auto terminalSettings3 = createTerminalSettings(activeProfiles.GetAt(3), colorSchemes);
        const auto terminalSettings4 = createTerminalSettings(activeProfiles.GetAt(4), colorSchemes);
        const auto terminalSettings5 = createTerminalSettings(activeProfiles.GetAt(5), colorSchemes);

        VERIFY_ARE_EQUAL(RGB(0x12, 0x34, 0x56), terminalSettings0->CursorColor()); // from color scheme
        VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1->CursorColor()); // default
        VERIFY_ARE_EQUAL(RGB(0x23, 0x45, 0x67), terminalSettings2->CursorColor()); // from profile (trumps color scheme)
        VERIFY_ARE_EQUAL(RGB(0x34, 0x56, 0x78), terminalSettings3->CursorColor()); // from profile (not set in color scheme)
        VERIFY_ARE_EQUAL(RGB(0x45, 0x67, 0x89), terminalSettings4->CursorColor()); // from profile (no color scheme)
        VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings5->CursorColor()); // default
    }

    void TerminalSettingsTests::TestCommandlineToTitlePromotion()
    {
        static constexpr std::string_view settingsJson{ R"(
        {
            "defaultProfile": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
            "profiles": { "list": [
                {
                    "name": "profile0",
                    "guid": "{6239a42c-0000-49a3-80bd-e8fdd045185c}",
                    "historySize": 1,
                    "commandline": "cmd.exe"
                },
            ],
            "defaults": {
                "historySize": 29
            } }
        })" };

        const auto settings = winrt::make_self<implementation::CascadiaSettings>(settingsJson);

        { // just a profile (profile wins)
            NewTerminalArgs args{};
            args.Profile(L"profile0");