-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ResourceTiffTests
with Cube.tiff
with multiple dpi and scales
- Loading branch information
Showing
7 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<Version>0.7.1-alpha.2</Version> | ||
<Version>0.7.1-alpha.3</Version> | ||
</PropertyGroup> | ||
</Project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using NUnit.Framework; | ||
using System; | ||
|
||
namespace ricaun.Revit.UI.Tests.Resources | ||
{ | ||
public class ResourceTiffTests | ||
{ | ||
/// <summary> | ||
/// Tiff file with multiple scales, 1.0x, 1.5x, 2.0x, 3.0x, 4.0x for 16x16 and 32x32, 10 frames. | ||
/// </summary> | ||
/// <remarks> | ||
/// Tiff file based in the https://github.com/ricaun-io/Autodesk.Icon.Example?tab=readme-ov-file#autodesk-high-resolution-icons | ||
/// </remarks> | ||
const string ResourceNameTiff = "Resources/Images/Cube.tiff"; | ||
|
||
System.Windows.Media.Imaging.BitmapFrame BitmapFrame; | ||
[OneTimeSetUp] | ||
public void Setup() | ||
{ | ||
BitmapFrame = ResourceNameTiff.GetBitmapSource() as System.Windows.Media.Imaging.BitmapFrame; | ||
} | ||
|
||
[Test] | ||
public void GetBitmapSource_NotNull() | ||
{ | ||
Console.WriteLine(ResourceNameTiff.GetBitmapSource()); | ||
Assert.IsNotNull(ResourceNameTiff.GetBitmapSource()); | ||
Assert.IsNotNull(("/" + ResourceNameTiff).GetBitmapSource()); | ||
} | ||
|
||
[TestCase(32, 384)] | ||
public void GetBitmapSource_Default_WidthAndDpi(int width, int dpi) | ||
{ | ||
var source = ResourceNameTiff.GetBitmapSource(); | ||
Assert.AreEqual(width, Math.Round(source.Width)); | ||
Assert.AreEqual(dpi, Math.Round(source.DpiX)); | ||
} | ||
|
||
[TestCase(10)] | ||
public void BitmapFrame_CountFrames(int count) | ||
{ | ||
Assert.IsNotNull(BitmapFrame); | ||
var decoder = BitmapFrame.Decoder; | ||
Assert.AreEqual(count, decoder.Frames.Count); | ||
} | ||
|
||
[TestCase(16, 96)] // 1.0 | ||
[TestCase(16, 144)] // 1.5 | ||
[TestCase(16, 192)] // 2.0 | ||
[TestCase(16, 288)] // 3.0 | ||
[TestCase(16, 384)] // 4.0 | ||
[TestCase(32, 96)] // 1.0 | ||
[TestCase(32, 144)] // 1.5 | ||
[TestCase(32, 192)] // 2.0 | ||
[TestCase(32, 288)] // 3.0 | ||
[TestCase(32, 384)] // 4.0 | ||
public void BitmapFrame_ByWidthAndDpi(int width, int dpi) | ||
{ | ||
Assert.IsNotNull(BitmapFrame); | ||
var decoder = BitmapFrame.Decoder; | ||
var frame = decoder.GetBitmapFrameByWidthAndDpi(width, dpi) as System.Windows.Media.Imaging.BitmapFrame; | ||
Assert.IsNotNull(frame); | ||
Assert.AreEqual(width, Math.Round(frame.Width)); | ||
Assert.AreEqual(dpi, Math.Round(frame.DpiX)); | ||
} | ||
|
||
[TestCase(16, 168, 192)] // 1.75 | ||
[TestCase(32, 168, 192)] // 1.75 | ||
[TestCase(16, 240, 288)] // 2.5 | ||
[TestCase(32, 240, 288)] // 2.5 | ||
[TestCase(16, 336, 384)] // 3.5 | ||
[TestCase(32, 336, 384)] // 3.5 | ||
[TestCase(16, 480, 384)] // 5.0 | ||
[TestCase(32, 480, 384)] // 5.0 | ||
public void BitmapFrame_ByWidthAndDpi_Expected(int width, int dpi, int dpiExpected) | ||
{ | ||
Assert.IsNotNull(BitmapFrame); | ||
var decoder = BitmapFrame.Decoder; | ||
var frame = decoder.GetBitmapFrameByWidthAndDpi(width, dpi) as System.Windows.Media.Imaging.BitmapFrame; | ||
Assert.IsNotNull(frame); | ||
Assert.AreEqual(width, Math.Round(frame.Width)); | ||
Assert.AreEqual(dpiExpected, Math.Round(frame.DpiX)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters