mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-01 06:55:17 +00:00
* here are the tests for the fancy zones * Wrote tests for GridLayoutModel * Move FancyZonesEditor tests to right place, tests for default layout model * fixed SettingTheVerticalLayoutShouldBeTheDefault test * removed coverlet in the test project * Fixes for comments on pr * squashed and updated for comments * Added the test to the pipeline --------- Co-authored-by: Drew Gordon <andrewbengordon@gmail.com> Co-authored-by: Caleb Wightman <agentcboy@gmail.com>
This commit is contained in:
@@ -197,6 +197,7 @@ steps:
|
|||||||
**\UnitTests-PdfThumbnailProvider.dll
|
**\UnitTests-PdfThumbnailProvider.dll
|
||||||
**\Settings.UI.UnitTests.dll
|
**\Settings.UI.UnitTests.dll
|
||||||
**\UnitTests-GcodePreviewHandler.dll
|
**\UnitTests-GcodePreviewHandler.dll
|
||||||
|
**\UnitTests-FancyZonesEditor.dll
|
||||||
**\UnitTests-PdfPreviewHandler.dll
|
**\UnitTests-PdfPreviewHandler.dll
|
||||||
**\UnitTests-PreviewHandlerCommon.dll
|
**\UnitTests-PreviewHandlerCommon.dll
|
||||||
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
|
**\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.dll
|
||||||
|
@@ -537,6 +537,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLock", "src\modules\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CropAndLockModuleInterface", "src\modules\CropAndLock\CropAndLockModuleInterface\CropAndLockModuleInterface.vcxproj", "{3157FA75-86CF-4EE2-8F62-C43F776493C6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-FancyZonesEditor", "src\modules\fancyzones\UnitTests-FancyZonesEditor\UnitTests-FancyZonesEditor.csproj", "{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|ARM64 = Debug|ARM64
|
Debug|ARM64 = Debug|ARM64
|
||||||
@@ -2307,6 +2309,18 @@ Global
|
|||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x64.Build.0 = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x64.Build.0 = Release|x64
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.ActiveCfg = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.ActiveCfg = Release|x64
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.Build.0 = Release|x64
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6}.Release|x86.Build.0 = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|ARM64.Build.0 = Release|ARM64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B}.Release|x86.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -2501,6 +2515,7 @@ Global
|
|||||||
{3B227528-4BA6-4CAF-B44A-A10C78A64849} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
|
{3B227528-4BA6-4CAF-B44A-A10C78A64849} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
|
||||||
{F5E1146E-B7B3-4E11-85FD-270A500BD78C} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
{F5E1146E-B7B3-4E11-85FD-270A500BD78C} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
||||||
{3157FA75-86CF-4EE2-8F62-C43F776493C6} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
{3157FA75-86CF-4EE2-8F62-C43F776493C6} = {3B227528-4BA6-4CAF-B44A-A10C78A64849}
|
||||||
|
{FC8EB78F-F061-4BD9-A3F6-507BEA965E2B} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
@@ -0,0 +1,59 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
using FancyZonesEditor.Models;
|
||||||
|
|
||||||
|
namespace UnitTestsFancyZonesEditor;
|
||||||
|
|
||||||
|
[TestClass]
|
||||||
|
public class DefaultLayoutsModelTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void LayoutCapacityShouldBeNumberOfMonitorConfigurations()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
var expectedOptionCount = Enum.GetValues(typeof(MonitorConfigurationType)).Length;
|
||||||
|
|
||||||
|
var actualCapacity = defaultLayoutsModel.Layouts.Capacity;
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedOptionCount, actualCapacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void OverridingLayoutClearsOldDefault()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
CanvasLayoutModel secondLayout = new CanvasLayoutModel("steve");
|
||||||
|
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], firstLayout);
|
||||||
|
|
||||||
|
defaultLayoutsModel.Set(secondLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
Assert.AreNotEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], firstLayout);
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Horizontal], secondLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void SettingTheVerticalLayoutShouldBeTheDefault()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Horizontal);
|
||||||
|
defaultLayoutsModel.Set(firstLayout, MonitorConfigurationType.Vertical);
|
||||||
|
|
||||||
|
Assert.AreEqual(defaultLayoutsModel.Layouts[(int)MonitorConfigurationType.Vertical], firstLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void RestoringLayoutShouldSetLayouts()
|
||||||
|
{
|
||||||
|
var defaultLayoutsModel = new DefaultLayoutsModel();
|
||||||
|
GridLayoutModel firstLayout = new GridLayoutModel();
|
||||||
|
CanvasLayoutModel secondLayout = new CanvasLayoutModel("steve");
|
||||||
|
var restoredLayouts = new List<LayoutModel> { firstLayout, secondLayout };
|
||||||
|
defaultLayoutsModel.Restore(restoredLayouts);
|
||||||
|
|
||||||
|
CollectionAssert.AreEqual(defaultLayoutsModel.Layouts, restoredLayouts);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,95 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using FancyZonesEditor.Models;
|
||||||
|
|
||||||
|
namespace UnitTestsFancyZonesEditor;
|
||||||
|
|
||||||
|
[TestClass]
|
||||||
|
public class GridLayoutModelTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void EmptyGridLayoutModelIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidRowAndColumnCountsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 0;
|
||||||
|
gridLayoutModel.Columns = 0;
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidRowPercentsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 1;
|
||||||
|
gridLayoutModel.Columns = 1;
|
||||||
|
gridLayoutModel.RowPercents = new List<int> { 0 }; // Invalid percentage
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidColumnPercentsIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 1;
|
||||||
|
gridLayoutModel.Columns = 1;
|
||||||
|
gridLayoutModel.ColumnPercents = new List<int> { 0 }; // Invalid percentage
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidCellChildMapLengthIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
gridLayoutModel.CellChildMap = new int[2, 1]; // Invalid length
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithInvalidZoneCountIsNotValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
gridLayoutModel.CellChildMap = new int[,]
|
||||||
|
{
|
||||||
|
{ 1, 2 },
|
||||||
|
{ 3, 4 },
|
||||||
|
}; // Invalid zone count
|
||||||
|
Assert.IsFalse(gridLayoutModel.IsModelValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void GridLayoutModelWithValidPropertiesIsValid()
|
||||||
|
{
|
||||||
|
GridLayoutModel gridLayoutModel = new GridLayoutModel();
|
||||||
|
|
||||||
|
// Set valid row and column counts
|
||||||
|
gridLayoutModel.Rows = 2;
|
||||||
|
gridLayoutModel.Columns = 2;
|
||||||
|
|
||||||
|
// Set valid percentages for rows and columns
|
||||||
|
// Should add up to 10000
|
||||||
|
gridLayoutModel.RowPercents = new List<int> { 5000, 5000 };
|
||||||
|
gridLayoutModel.ColumnPercents = new List<int> { 5000, 5000 };
|
||||||
|
|
||||||
|
// Set a valid CellChildMap
|
||||||
|
gridLayoutModel.CellChildMap = new int[,]
|
||||||
|
{
|
||||||
|
{ 0, 1 },
|
||||||
|
{ 2, 3 },
|
||||||
|
}; // corresponds to 4 zones
|
||||||
|
|
||||||
|
Assert.IsTrue(gridLayoutModel.IsModelValid(), "GridLayoutModel with valid properties should be valid.");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
|
||||||
|
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
|
||||||
|
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\tests\UnitTest-FancyZonesEditor\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Windows.CsWinRT" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" />
|
||||||
|
<PackageReference Include="System.IO.Abstractions" />
|
||||||
|
<PackageReference Include="System.IO.Abstractions.TestingHelpers" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\editor\FancyZonesEditor\FancyZonesEditor.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -0,0 +1,5 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
Reference in New Issue
Block a user