Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions ImageSharp.Textures.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 18
VisualStudioVersion = 18.5.11716.220
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Textures", "src\ImageSharp.Textures\ImageSharp.Textures.csproj", "{1588F6C4-2186-4A35-9693-E9F296791393}"
EndProject
Expand Down Expand Up @@ -50,13 +50,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{1588f6c4-2186-4a35-9693-e9f296791393}*SharedItemsImports = 5
tests\Images\Images.projitems*{17fcbd4d-d232-45e8-876f-dfbc2fad52cf}*SharedItemsImports = 5
tests\Images\Images.projitems*{18be79b6-6b95-4ed7-a963-ad75f6cb9f3c}*SharedItemsImports = 5
tests\Images\Images.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
tests\Images\Images.projitems*{b159ffd1-e646-42d0-892c-4abf69103712}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -94,4 +87,11 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1762A0D-74C4-454A-BCB7-C010BB067E58}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{1588f6c4-2186-4a35-9693-e9f296791393}*SharedItemsImports = 5
tests\Images\Images.projitems*{17fcbd4d-d232-45e8-876f-dfbc2fad52cf}*SharedItemsImports = 5
tests\Images\Images.projitems*{18be79b6-6b95-4ed7-a963-ad75f6cb9f3c}*SharedItemsImports = 5
tests\Images\Images.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
tests\Images\Images.projitems*{b159ffd1-e646-42d0-892c-4abf69103712}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion shared-infrastructure
3 changes: 1 addition & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->

<!-- Import the shared src .props file -->
<Import Project="$(MSBuildThisFileDirectory)..\shared-infrastructure\msbuild\props\SixLabors.Src.props" />
<Import Project="$(MSBuildThisFileDirectory)../shared-infrastructure/msbuild/props/SixLabors.Src.props" />

<!-- Import the solution .props file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
Expand All @@ -22,7 +22,6 @@
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="SixLabors.ImageSharp.Textures.Benchmarks" Key="$(SixLaborsPublicKey)" />
<InternalsVisibleTo Include="SixLabors.ImageSharp.Textures.InteractiveTest" Key="$(SixLaborsPublicKey)" />
<InternalsVisibleTo Include="SixLabors.ImageSharp.Textures.Tests" Key="$(SixLaborsPublicKey)" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->

<!-- Import the shared tests .props file -->
<Import Project="$(MSBuildThisFileDirectory)..\shared-infrastructure\msbuild\props\SixLabors.Tests.props" />
<Import Project="$(MSBuildThisFileDirectory)../shared-infrastructure/msbuild/props/SixLabors.Tests.props" />

<!-- Import the solution .props file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
Expand Down
4 changes: 2 additions & 2 deletions tests/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

<ItemGroup>
<PackageReference Update="BenchmarkDotNet" Version="0.15.8" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="14.10.2" />
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="14.10.3" />
<PackageReference Update="Moq" Version="4.20.72" />
<PackageReference Update="System.Drawing.Common" Version="10.0.2" />
<PackageReference Update="System.Drawing.Common" Version="10.0.3" />
<PackageReference Update="Veldrid.ImageSharp" Version="4.9.0" />
<PackageReference Update="Veldrid.ImGui" Version="5.72.0" />
<PackageReference Update="Veldrid.StartupUtilities" Version="4.9.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<RootNamespace>SixLabors.ImageSharp.Textures.InteractiveTest</RootNamespace>
<!--Used to hide test project from dotnet test-->
<IsTestProject>false</IsTestProject>
<!-- Don't warn about test dependencies not being strong named -->
<NoWarn>$(NoWarn);CS8002</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
44 changes: 44 additions & 0 deletions tests/ImageSharp.Textures.Tests/Formats/Ktx/KtxDecoderFlatTests.cs
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not new, just renamed from KtxDecoderTests.cs, but the test has been updated and improved

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Textures.Formats.Ktx;
using SixLabors.ImageSharp.Textures.Tests.Enums;
using SixLabors.ImageSharp.Textures.Tests.TestUtilities;
using SixLabors.ImageSharp.Textures.Tests.TestUtilities.Attributes;
using SixLabors.ImageSharp.Textures.Tests.TestUtilities.TextureProviders;
using SixLabors.ImageSharp.Textures.TextureFormats;

namespace SixLabors.ImageSharp.Textures.Tests.Formats.Ktx;

[GroupOutput("Ktx")]
[Trait("Format", "Ktx")]
public class KtxDecoderFlatTests
{
private static readonly KtxDecoder KtxDecoder = new();

[Theory]
[WithFile(TestTextureFormat.Ktx, TestTextureType.Flat, TestTextureTool.PvrTexToolCli, TestImages.Ktx.Rgba32UnormMipMap)]
public void CanDecode_Rgba32_MipMaps(TestTextureProvider provider)
{
using Texture texture = provider.GetTexture(KtxDecoder);
provider.SaveTextures(texture);
FlatTexture flatTexture = texture as FlatTexture;

Assert.NotNull(flatTexture?.MipMaps);
Assert.Equal(8, flatTexture.MipMaps.Count);

int[] expectedSizes = [200, 100, 50, 25, 12, 6, 3, 1];
for (int i = 0; i < expectedSizes.Length; i++)
{
using Image mipImage = flatTexture.MipMaps[i].GetImage();
Assert.Equal(expectedSizes[i], mipImage.Height);
Assert.Equal(expectedSizes[i], mipImage.Width);
}

using Image firstMipMap = flatTexture.MipMaps[0].GetImage();
Assert.Equal(32, firstMipMap.PixelType.BitsPerPixel);
Image<Rgba32> firstMipMapImage = firstMipMap as Image<Rgba32>;
firstMipMapImage.CompareToReferenceOutput(provider, appendPixelTypeToFileName: false);
}
}
52 changes: 0 additions & 52 deletions tests/ImageSharp.Textures.Tests/Formats/Ktx/KtxDecoderTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public void Ktx2Decoder_LevelCountZero_DecodesBaseLevelMipMap(TestTextureProvide
FlatTexture flatTexture = texture as FlatTexture;
Assert.NotNull(flatTexture);
Assert.Single(flatTexture.MipMaps);
Assert.Equal(256, flatTexture.MipMaps[0].GetImage().Width);
Assert.Equal(256, flatTexture.MipMaps[0].GetImage().Height);
using Image mipImage = flatTexture.MipMaps[0].GetImage();
Assert.Equal(256, mipImage.Width);
Assert.Equal(256, mipImage.Height);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<DebugSymbols>True</DebugSymbols>
<Platforms>AnyCPU;x64;x86</Platforms>
<AssemblyName>SixLabors.ImageSharp.Textures.Tests</AssemblyName>
<RootNamespace>SixLabors.ImageSharp.Textures.Tests</RootNamespace>
<IsTestProject>true</IsTestProject>
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageSharp.Textures.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class TestImages
{
public static class Ktx
{
public const string Rgba = "rgba8888.ktx";
public const string Rgba32UnormMipMap = "rgba32-unorm-mipmap.ktx";
}

public static class Ktx2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,69 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using SixLabors.ImageSharp.Textures.Tests.Enums;
using SixLabors.ImageSharp.Textures.Tests.TestUtilities.TextureProviders;
using Xunit.Sdk;

namespace SixLabors.ImageSharp.Textures.Tests.TestUtilities.Attributes
namespace SixLabors.ImageSharp.Textures.Tests.TestUtilities.Attributes;

public class WithFileAttribute : DataAttribute
{
public class WithFileAttribute : DataAttribute
private readonly TestTextureFormat textureFormat;
private readonly TestTextureType textureType;
private readonly TestTextureTool textureTool;
private readonly string inputFile;

public WithFileAttribute(TestTextureFormat textureFormat, TestTextureType textureType, TestTextureTool textureTool, string inputFile)
{
private readonly TestTextureFormat textureFormat;
private readonly TestTextureType textureType;
private readonly TestTextureTool textureTool;
private readonly string inputFile;
private readonly bool isRegex;
this.textureFormat = textureFormat;
this.textureType = textureType;
this.textureTool = textureTool;
this.inputFile = inputFile;
}

public WithFileAttribute(TestTextureFormat textureFormat, TestTextureType textureType, TestTextureTool textureTool, string inputFile, bool isRegex = false)
{
this.textureFormat = textureFormat;
this.textureType = textureType;
this.textureTool = textureTool;
this.inputFile = inputFile;
this.isRegex = isRegex;
}
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
ArgumentNullException.ThrowIfNull(testMethod);

string outputSubfolderName = testMethod.DeclaringType?.GetCustomAttribute<GroupOutputAttribute>()?.Subfolder ?? string.Empty;
string testGroupName = testMethod.DeclaringType?.Name ?? string.Empty;

public override IEnumerable<object[]> GetData(MethodInfo testMethod)
string[] featureLevels = this.textureTool == TestTextureTool.TexConv ? new[] { "9.1", "9.2", "9.3", "10.0", "10.1", "11.0", "11.1", "12.0", "12.1" } : new[] { string.Empty };

foreach (string featureLevel in featureLevels)
{
ArgumentNullException.ThrowIfNull(testMethod);
string basePath = Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.textureFormat.ToString());

if (!string.IsNullOrEmpty(featureLevel))
{
basePath = Path.Combine(basePath, featureLevel);
}

if (!Directory.Exists(basePath))
{
continue;
}

// First try direct path construction (handles subdirectory paths like "Flat/Astc/file.ktx2").
string file = Path.Combine(basePath, this.inputFile);
if (File.Exists(file))
{
TestTextureProvider testTextureProvider = new(testMethod.Name, this.textureFormat, this.textureType, this.textureTool, file, false, testGroupName, outputSubfolderName);
yield return new object[] { testTextureProvider };
continue;
}

string[] featureLevels = this.textureTool == TestTextureTool.TexConv ? new[] { "9.1", "9.2", "9.3", "10.0", "10.1", "11.0", "11.1", "12.0", "12.1" } : new[] { string.Empty };
// Fall back to case-insensitive filename matching to handle
// cross-platform casing differences (e.g. ".DDS" vs ".dds").
string match = Directory.GetFiles(basePath)
.FirstOrDefault(f => Path.GetFileName(f).Equals(this.inputFile, StringComparison.OrdinalIgnoreCase));

foreach (string featureLevel in featureLevels)
if (match is not null)
{
string path = Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.textureFormat.ToString());

if (!string.IsNullOrEmpty(featureLevel))
{
path = Path.Combine(path, featureLevel);
}

string[] files = Directory.GetFiles(path);
string[] filteredFiles = files.Where(f => this.isRegex ? new Regex(this.inputFile).IsMatch(Path.GetFileName(f)) : Path.GetFileName(f).Equals(this.inputFile, StringComparison.OrdinalIgnoreCase)).ToArray();
foreach (string file in filteredFiles)
{
var testTextureProvider = new TestTextureProvider(testMethod.Name, this.textureFormat, this.textureType, this.textureTool, file, false);
yield return new object[] { testTextureProvider };
}
TestTextureProvider testTextureProvider = new(testMethod.Name, this.textureFormat, this.textureType, this.textureTool, match, false, testGroupName, outputSubfolderName);
yield return new object[] { testTextureProvider };
}
}
}
Expand Down
Loading
Loading