aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Model.Tests
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-08-10 23:03:52 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-08-10 23:03:52 +0200
commit7b6ae06f3bc3f630828a77c0f2b0c2e1d6bd85cd (patch)
tree2fe06b0dcd958836550c5f2d62321957c2828d81 /tests/Jellyfin.Model.Tests
parent8c4dfc0b710c9314061911eea0daacfd855326e4 (diff)
parent35e86416af32adaa220a241f756544cd316bd866 (diff)
Merge remote-tracking branch 'upstream/master' into safeguard-invalid-provider-ids
Diffstat (limited to 'tests/Jellyfin.Model.Tests')
-rw-r--r--tests/Jellyfin.Model.Tests/Drawing/DrawingUtilsTests.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/Jellyfin.Model.Tests/Drawing/DrawingUtilsTests.cs b/tests/Jellyfin.Model.Tests/Drawing/DrawingUtilsTests.cs
new file mode 100644
index 0000000000..473b07a8a1
--- /dev/null
+++ b/tests/Jellyfin.Model.Tests/Drawing/DrawingUtilsTests.cs
@@ -0,0 +1,28 @@
+using MediaBrowser.Model.Drawing;
+using Xunit;
+
+namespace Jellyfin.Model.Drawing;
+
+public static class DrawingUtilsTests
+{
+ [Theory]
+ // Already inside the box, returned untouched.
+ [InlineData(600, 336, 1920, 1080, 600, 336)]
+ [InlineData(1920, 1080, 1920, 1080, 1920, 1080)]
+ // Scaled down uniformly, requested aspect ratio preserved.
+ [InlineData(23100, 23100, 1920, 1080, 1080, 1080)]
+ [InlineData(3840, 2160, 1920, 1080, 1920, 1080)]
+ [InlineData(1200, 400, 600, 336, 600, 200)]
+ // Extreme ratios still produce at least one pixel per axis.
+ [InlineData(10000, 1, 100, 100, 100, 1)]
+ // Degenerate inputs are passed through rather than dividing by zero.
+ [InlineData(600, 336, 0, 0, 600, 336)]
+ [InlineData(0, 0, 1920, 1080, 0, 0)]
+ public static void ScaleDownToFit_Bounds_WithoutUpscaling(int width, int height, int boxWidth, int boxHeight, int expectedWidth, int expectedHeight)
+ {
+ var scaled = DrawingUtils.ScaleDownToFit(new ImageDimensions(width, height), new ImageDimensions(boxWidth, boxHeight));
+
+ Assert.Equal(expectedWidth, scaled.Width);
+ Assert.Equal(expectedHeight, scaled.Height);
+ }
+}