Compare commits

...

7 Commits

Author SHA1 Message Date
Mike Griese
fc09777bd9 tests! 2023-01-04 12:12:17 -06:00
Mike Griese
77316029eb Merge remote-tracking branch 'origin/main' into dev/migrie/b/14557-empty-folder-dropdown 2023-01-04 11:35:47 -06:00
Mike Griese
6ce479bd7f this fixes the settings tests 2023-01-04 11:30:09 -06:00
Mike Griese
c26655a2f6 this fixes it but this should have a test 2023-01-04 09:42:34 -06:00
Mike Griese
67a7f66498 Merge remote-tracking branch 'origin/main' into dev/migrie/s/theme-schema 2022-12-15 12:30:15 -06:00
Dustin L. Howett
0b745f0af0 Migrate spelling-0.0.21 changes from main 2022-09-15 07:04:27 -05:00
Mike Griese
1b85605f83 early and often 2022-09-15 07:04:27 -05:00
5 changed files with 166 additions and 8 deletions

View File

@@ -1722,6 +1722,41 @@
}
]
},
"TabTheme": {
"additionalProperties": false,
"description": "A set of properties for customizing the appearance of the tab row",
"properties": {
"background": {
"$ref": "#/$defs/ThemeColor"
},
"unfocusedBackground": {
"$ref": "#/$defs/ThemeColor"
},
"showCloseButton": {
"$ref": "#/$defs/ShowCloseButton"
}
}
},
"Theme": {
"additionalProperties": false,
"description": "A set of properties for customizing the appearance of the window. This controls things like the titlebar, the tabs, the application theme.",
"properties": {
"name": {
"type": "string",
"description": "The name of the theme. This will be displayed in the settings UI.",
"noneOf": [ "light", "dark", "system" ]
},
"tab": {
"$ref": "#/$defs/TabTheme"
},
"tabRow": {
"$ref": "#/$defs/TabRowTheme"
},
"window": {
"$ref": "#/$defs/WindowTheme"
}
}
},
"NewTabMenu": {
"description": "Defines the order and structure of the 'new tab' menu. It can consist of e.g. profiles, folders, and separators.",
"type": "array",
@@ -2132,15 +2167,17 @@
"type": "string"
},
"theme": {
"default": "system",
"description": "Sets the theme of the application. The special value \"system\" refers to the active Windows system theme.",
"enum": [
"light",
"dark",
"system"
],
"default": "dark",
"description": "Sets the theme of the application. This value should be the name of one of the themes defined in `themes`. The Terminal also includes the themes `dark`, `light`, and `system`.",
"type": "string"
},
"themes": {
"description": "The list of available themes",
"items": {
"$ref": "#/$defs/Theme"
},
"type": "array"
},
"showTabsInTitlebar": {
"default": true,
"description": "When set to true, the tabs are moved into the titlebar and the titlebar disappears. When set to false, the titlebar sits above the tabs.",

View File

@@ -0,0 +1,107 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "../TerminalSettingsModel/NewTabMenuEntry.h"
#include "../TerminalSettingsModel/FolderEntry.h"
#include "../TerminalSettingsModel/CascadiaSettings.h"
#include "../types/inc/colorTable.hpp"
#include "JsonTestClass.h"
#include <defaults.h>
using namespace Microsoft::Console;
using namespace winrt::Microsoft::Terminal;
using namespace winrt::Microsoft::Terminal::Settings::Model::implementation;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace WEX::Common;
namespace SettingsModelLocalTests
{
// TODO:microsoft/terminal#3838:
// Unfortunately, these tests _WILL NOT_ work in our CI. We're waiting for
// an updated TAEF that will let us install framework packages when the test
// package is deployed. Until then, these tests won't deploy in CI.
class NewTabMenuTests : public JsonTestClass
{
// Use a custom AppxManifest to ensure that we can activate winrt types
// from our test. This property will tell taef to manually use this as
// the AppxManifest for this test class.
// This does not yet work for anything XAML-y. See TabTests.cpp for more
// details on that.
BEGIN_TEST_CLASS(NewTabMenuTests)
TEST_CLASS_PROPERTY(L"RunAs", L"UAP")
TEST_CLASS_PROPERTY(L"UAP:AppXManifest", L"TestHostAppXManifest.xml")
END_TEST_CLASS()
TEST_METHOD(DefaultsToRemainingProfiles);
TEST_METHOD(ParseEmptyFolder);
};
void NewTabMenuTests::DefaultsToRemainingProfiles()
{
Log::Comment(L"If the user doesn't customize the menu, put one entry for each profile");
static constexpr std::string_view settingsString{ R"json({
})json" };
try
{
const auto settings{ winrt::make_self<CascadiaSettings>(settingsString, DefaultJson) };
VERIFY_ARE_EQUAL(0u, settings->Warnings().Size());
const auto& entries = settings->GlobalSettings().NewTabMenu();
VERIFY_ARE_EQUAL(1u, entries.Size());
VERIFY_ARE_EQUAL(winrt::Microsoft::Terminal::Settings::Model::NewTabMenuEntryType::RemainingProfiles, entries.GetAt(0).Type());
}
catch (const SettingsException& ex)
{
auto loadError = ex.Error();
loadError;
throw ex;
}
catch (const SettingsTypedDeserializationException& e)
{
auto deserializationErrorMessage = til::u8u16(e.what());
Log::Comment(NoThrowString().Format(deserializationErrorMessage.c_str()));
throw e;
}
}
void NewTabMenuTests::ParseEmptyFolder()
{
Log::Comment(L"GH #14557 - An empty folder entry shouldn't crash");
static constexpr std::string_view settingsString{ R"json({
"newTabMenu": [
{ "type": "folder" }
]
})json" };
try
{
const auto settings{ winrt::make_self<CascadiaSettings>(settingsString, DefaultJson) };
VERIFY_ARE_EQUAL(0u, settings->Warnings().Size());
const auto& entries = settings->GlobalSettings().NewTabMenu();
VERIFY_ARE_EQUAL(1u, entries.Size());
}
catch (const SettingsException& ex)
{
auto loadError = ex.Error();
loadError;
throw ex;
}
catch (const SettingsTypedDeserializationException& e)
{
auto deserializationErrorMessage = til::u8u16(e.what());
Log::Comment(NoThrowString().Format(deserializationErrorMessage.c_str()));
throw e;
}
}
}

View File

@@ -406,6 +406,12 @@ namespace SettingsModelLocalTests
"$schema" : "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-1111-5271-96e7-009a87ff44bf}",
"disabledProfileSources": [ "Windows.Terminal.Wsl" ],
"newTabMenu":
[
{
"type": "remainingProfiles"
}
],
"profiles": {
"defaults": {
"font": {

View File

@@ -39,6 +39,7 @@
<ClCompile Include="KeyBindingsTests.cpp" />
<ClCompile Include="CommandTests.cpp" />
<ClCompile Include="DeserializationTests.cpp" />
<ClCompile Include="NewTabMenuTests.cpp" />
<ClCompile Include="SerializationTests.cpp" />
<ClCompile Include="TerminalSettingsTests.cpp" />
<ClCompile Include="ThemeTests.cpp" />

View File

@@ -48,7 +48,10 @@ winrt::com_ptr<NewTabMenuEntry> FolderEntry::FromJson(const Json::Value& json)
JsonUtils::GetValueForKey(json, NameKey, entry->_Name);
JsonUtils::GetValueForKey(json, IconKey, entry->_Icon);
JsonUtils::GetValueForKey(json, EntriesKey, entry->_Entries);
if (const auto& entries{ JsonUtils::GetValueForKey<decltype(entry->_Entries)>(json, EntriesKey) })
{
entry->_Entries = entries;
}
JsonUtils::GetValueForKey(json, InliningKey, entry->_Inlining);
JsonUtils::GetValueForKey(json, AllowEmptyKey, entry->_AllowEmpty);
@@ -63,6 +66,10 @@ IVector<NewTabMenuEntryModel> FolderEntry::Entries() const
// We filter the full list of entries from JSON to just include the
// non-empty ones.
IVector<NewTabMenuEntryModel> result{ winrt::single_threaded_vector<NewTabMenuEntryModel>() };
if (_Entries == nullptr)
{
return result;
}
for (const auto& entry : _Entries)
{