[FileExplorer]Add QoiThumbnailProvider and QoiPreviewHandler (#29735)

* [FileExplorer]QoiThumbnailProvider

* Corrects code documentation

* Adds QoiPreviewHandler

* Corrects GUIDs

* Ensure returned thumbnail image is 32bit ARGB

* Updates following review comments

* More updates following review comments

* Updates following PR comments

* Fix dark theme background in QoiPreviewHandler

* Updates attribution text
This commit is contained in:
Pedro Lamas
2023-11-14 15:41:09 +00:00
committed by GitHub
parent 9d2f9bcff2
commit 0990724e44
70 changed files with 2970 additions and 8 deletions

View File

@@ -0,0 +1,61 @@
// 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 System.Drawing;
using Microsoft.PowerToys.STATestExtension;
using Microsoft.PowerToys.ThumbnailHandler.Qoi;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace QoiThumbnailProviderUnitTests
{
[STATestClass]
public class QoiThumbnailProviderTests
{
[TestMethod]
public void GetThumbnailValidStreamQoi()
{
// Act
var filePath = "HelperFiles/sample.qoi";
QoiThumbnailProvider provider = new QoiThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(256);
Assert.IsTrue(bitmap != null);
}
[TestMethod]
public void GetThumbnailInValidSizeQoi()
{
// Act
var filePath = "HelperFiles/sample.qoi";
QoiThumbnailProvider provider = new QoiThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(0);
Assert.IsTrue(bitmap == null);
}
[TestMethod]
public void GetThumbnailToBigQoi()
{
// Act
var filePath = "HelperFiles/sample.qoi";
QoiThumbnailProvider provider = new QoiThumbnailProvider(filePath);
Bitmap bitmap = provider.GetThumbnail(10001);
Assert.IsTrue(bitmap == null);
}
[TestMethod]
public void CheckNoQoiNullStringShouldReturnNullBitmap()
{
Bitmap thumbnail = QoiThumbnailProvider.GetThumbnail(null, 256);
Assert.IsTrue(thumbnail == null);
}
}
}

View File

@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>UnitTests-QoiThumbnailProvider</AssemblyTitle>
<AssemblyDescription>PowerToys UnitTests-QoiThumbnailProvider</AssemblyDescription>
<AssemblyTitle>UnitTests-QoiThumbnailProvider</AssemblyTitle>
<Description>PowerToys UnitTests-QoiThumbnailProvider</Description>
</PropertyGroup>
<PropertyGroup>
<ProjectGuid>{F8FFFC12-A31A-4AFA-B3DF-14DCF42B5E38}</ProjectGuid>
<RootNamespace>QoiThumbnailProviderUnitTests</RootNamespace>
<TargetFramework>net7.0-windows10.0.20348.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<Import Project="..\..\..\Version.props" />
<ItemGroup>
<None Remove="HelperFiles\sample.qoi" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" />
<PackageReference Include="Moq" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\PreviewHandlerCommon.csproj" />
<ProjectReference Include="..\QoiThumbnailProvider\QoiThumbnailProvider.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\STATestClassAttribute.cs" Link="STATestClassAttribute.cs" />
<Compile Include="..\STATestMethodAttribute.cs" Link="STATestMethodAttribute.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="HelperFiles\sample.qoi">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>