Skip to content
Merged
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
148 changes: 148 additions & 0 deletions Tests/Issues/RunTest-3.4.6.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<testrun version="1.0.0.0" date="2024-01-23T05:25:19.8410688+09:00">
<tests category="Passing">
<test name="__AJ_Digital_Camera.svg" exception="false" percent="30.88" />
<test name="__issue-015-01.svg" exception="false" percent="11.92" />
<test name="__issue-016-01.svg" exception="false" percent="7.89" />
<test name="__issue-034-02.svg" exception="false" percent="18.49" />
<test name="__issue-036-01.svg" exception="false" percent="6.87" />
<test name="__issue-064-01.svg" exception="false" percent="5.18" />
<test name="__issue-064-02.svg" exception="false" percent="2.37" />
<test name="__issue-074-01.svg" exception="false" percent="0" />
<test name="__issue-082-01.svg" exception="false" percent="25.95" />
<test name="__issue-083-01.svg" exception="false" percent="10.9" />
<test name="__issue-084-01.svg" exception="false" percent="1.49" />
<test name="__issue-109-01.svg" exception="false" percent="0.61" />
<test name="__issue-1101-01.svg" exception="false" percent="0" />
<test name="__issue-114-01.svg" exception="false" percent="0" />
<test name="__issue-116-01.svg" exception="false" percent="0" />
<test name="__issue-123-01.svg" exception="false" percent="1.04" />
<test name="__issue-129-01.svg" exception="false" percent="2.91" />
<test name="__issue-131-01.svg" exception="false" percent="2.1" />
<test name="__issue-134-01.svg" exception="false" percent="15.48" />
<test name="__issue-143-01.svg" exception="false" percent="0.02" />
<test name="__issue-166-01.svg" exception="false" percent="9.68" />
<test name="__issue-191-01.svg" exception="false" percent="0" />
<test name="__issue-202-01.svg" exception="false" percent="0" />
<test name="__issue-214-01.svg" exception="false" percent="0" />
<test name="__issue-215-01.svg" exception="false" percent="0.77" />
<test name="__issue-223-01.svg" exception="false" percent="1.32" />
<test name="__issue-223-02.svg" exception="false" percent="1.64" />
<test name="__issue-224-01.svg" exception="false" percent="10.13" />
<test name="__issue-227-01.svg" exception="false" percent="0" />
<test name="__issue-227-02.svg" exception="false" percent="0.02" />
<test name="__issue-239-01.svg" exception="false" percent="0" />
<test name="__issue-242-01.svg" exception="false" percent="0.02" />
<test name="__issue-252-01.svg" exception="false" percent="0" />
<test name="__issue-279-01.svg" exception="false" percent="0" />
<test name="__issue-280-01.svg" exception="false" percent="1.97" />
<test name="__issue-280-02.svg" exception="false" percent="4.19" />
<test name="__issue-318-01.svg" exception="false" percent="3.64" />
<test name="__issue-323-02.svg" exception="false" percent="0.55" />
<test name="__issue-323-03.svg" exception="false" percent="1.47" />
<test name="__issue-329-01.svg" exception="false" percent="0" />
<test name="__issue-338-01_stroke_width.svg" exception="false" percent="0.01" />
<test name="__issue-342-01.svg" exception="false" percent="3.08" />
<test name="__issue-345-01.svg" exception="false" percent="0" />
<test name="__issue-354-01.svg" exception="false" percent="0" />
<test name="__issue-363-01.svg" exception="false" percent="1.6" />
<test name="__issue-385-01_Test_text-anchor-middle.svg" exception="false" percent="0.05" />
<test name="__issue-391-01.svg" exception="false" percent="0" />
<test name="__issue-398-01.svg" exception="false" percent="0" />
<test name="__issue-419-01.svg" exception="false" percent="3.31" />
<test name="__issue-436-01.svg" exception="false" percent="2.67" />
<test name="__issue-437-01.svg" exception="false" percent="0" />
<test name="__issue-437-02.svg" exception="false" percent="0" />
<test name="__issue-437-03.svg" exception="false" percent="0" />
<test name="__issue-460-01.svg" exception="false" percent="0" />
<test name="__issue-479-01.svg" exception="false" percent="0" />
<test name="__issue-488-01.svg" exception="false" percent="0" />
<test name="__issue-508-01.svg" exception="false" percent="0" />
<test name="__issue-541-01.svg" exception="false" percent="0" />
<test name="__issue-554-01.svg" exception="false" percent="0" />
<test name="__issue-554-02.svg" exception="false" percent="0" />
<test name="__issue-578-01.svg" exception="false" percent="11.92" />
<test name="__issue-592-01.svg" exception="false" percent="0" />
<test name="__issue-592-02.svg" exception="false" percent="0" />
<test name="__issue-622-01.svg" exception="false" percent="0" />
<test name="__issue-626-01.svg" exception="false" percent="0" />
<test name="__issue-634-01.svg" exception="false" percent="0" />
<test name="__issue-664-01.svg" exception="false" percent="0" />
<test name="__issue-675-01.svg" exception="false" percent="0" />
<test name="__issue-732-01.svg" exception="false" percent="0" />
<test name="__issue-744-01.svg" exception="false" percent="3.1" />
<test name="__issue-747-01.svg" exception="false" percent="0" />
<test name="__issue-755-01.svg" exception="false" percent="0" />
<test name="__issue-758-01.svg" exception="false" percent="0" />
<test name="__issue-769-01.svg" exception="false" percent="0" />
<test name="__issue-785-01.svg" exception="false" percent="0.37" />
<test name="__issue-830-01.svg" exception="false" percent="0" />
<test name="__issue-863-01.svg" exception="false" percent="0" />
<test name="__issue-886-01.svg" exception="false" percent="0" />
<test name="__issue-888-01.svg" exception="false" percent="0" />
<test name="__issue-917-01.svg" exception="false" percent="0" />
<test name="__issue-917-02.svg" exception="false" percent="0" />
<test name="__issue-941-01.svg" exception="false" percent="0" />
<test name="__issue-960-01.svg" exception="false" percent="0" />
<test name="__issue-966-01.svg" exception="false" percent="0" />
<test name="__issue-966-02.svg" exception="false" percent="0" />
<test name="__issue-989-01.svg" exception="false" percent="0" />
<test name="__pull_request-1045-01.svg" exception="false" percent="0" />
<test name="__pull_request-373-01.svg" exception="false" percent="0" />
<test name="__pull_request-374-01.svg" exception="false" percent="0" />
<test name="__pull_request-414-01.svg" exception="false" percent="0" />
<test name="__pull_request-433-01.svg" exception="false" percent="0" />
<test name="__pull_request-444-01.svg" exception="false" percent="0" />
<test name="__pull_request-462-01.svg" exception="false" percent="0" />
<test name="__pull_request-471-01.svg" exception="false" percent="0" />
<test name="__pull_request-492-01.svg" exception="false" percent="0" />
<test name="__pull_request-500-01.svg" exception="false" percent="0" />
<test name="__pull_request-500-02.svg" exception="false" percent="0" />
<test name="__pull_request-504-01.svg" exception="false" percent="0" />
<test name="__pull_request-537-01.svg" exception="false" percent="0" />
<test name="__pull_request-537-02.svg" exception="false" percent="0" />
<test name="__pull_request-551-01.svg" exception="false" percent="0" />
<test name="__pull_request-564-01.svg" exception="false" percent="0" />
<test name="__pull_request-564-02.svg" exception="false" percent="0" />
<test name="__pull_request-575-01.svg" exception="false" percent="0" />
<test name="__pull_request-640-01.svg" exception="false" percent="0" />
<test name="__pull_request-640-02.svg" exception="false" percent="0" />
<test name="__pull_request-642-01.svg" exception="false" percent="0" />
<test name="__pull_request-656-01.svg" exception="false" percent="0" />
<test name="__pull_request-656-02.svg" exception="false" percent="0" />
<test name="__pull_request-658-01.svg" exception="false" percent="0" />
<test name="__pull_request-659-01.svg" exception="false" percent="0" />
<test name="__pull_request-686-01.svg" exception="false" percent="0" />
<test name="__pull_request-690-01.svg" exception="false" percent="0" />
<test name="__pull_request-706-01.svg" exception="false" percent="0" />
<test name="__pull_request-727-01.svg" exception="false" percent="0" />
<test name="__pull_request-873-01.svg" exception="false" percent="0" />
<test name="__pull_request-873-02.svg" exception="false" percent="0" />
<test name="__pull_request-925-01.svg" exception="false" percent="0" />
<test name="__pull_request-925-02.svg" exception="false" percent="0" />
<test name="__pull_request-925-03.svg" exception="false" percent="0" />
<test name="__pull_request-925-04.svg" exception="false" percent="0" />
<test name="__pull_request-925-05.svg" exception="false" percent="0" />
<test name="__pull_request-961-01.svg" exception="false" percent="0" />
<test name="__pull_request-963-01.svg" exception="false" percent="0" />
<test name="__Telefunken_FuBK_test_pattern.svg" exception="false" percent="1.16" />
<test name="__tiger.svg" exception="false" percent="13.66" />
<test name="__title.svg" exception="false" percent="0.31" />
</tests>
<tests category="Failing">
<test name="__issue-084-02.svg" exception="false" percent="12.95" />
<test name="__issue-127-01.svg" exception="false" percent="5.68" />
<test name="__issue-244-01.svg" exception="false" percent="72.32" />
<test name="__issue-247-01.svg" exception="false" percent="65.57" />
<test name="__issue-247-02.svg" exception="false" percent="7.31" />
<test name="__issue-263-01.svg" exception="false" percent="3.69" />
<test name="__issue-315-01.svg" exception="false" percent="50.64" />
<test name="__issue-323-01.svg" exception="false" percent="3.95" />
<test name="__issue-345-02.svg" exception="false" percent="26.9" />
<test name="__issue-362-01.svg" exception="false" percent="11.91" />
<test name="__issue-789-01.svg" exception="false" percent="0.02" />
<test name="__issue-789-02.svg" exception="false" percent="4.64" />
<test name="__issue-789-03.svg" exception="false" percent="0" />
<test name="__text-fonts-06-t.svg" exception="false" percent="0" />
</tests>
</testrun>
Binary file added Tests/SvgW3CTestRunner/App.ico
Binary file not shown.
117 changes: 117 additions & 0 deletions Tests/SvgW3CTestRunner/BitmapExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Drawing.Imaging;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace SvgW3CTestRunner
{
Expand Down Expand Up @@ -61,4 +62,120 @@ public int Reserved
}
}
}

/// <summary>
/// Taken from https://web.archive.org/web/20130111215043/http://www.switchonthecode.com/tutorials/csharp-tutorial-convert-a-color-image-to-grayscale
/// and slightly modified.
/// Image width and height, default threshold and handling of alpha values have been adapted.
/// </summary>
static class ExtensionMethods
{
private static readonly int ImageWidth = 64;
private static readonly int ImageHeight = 64;

public static float PercentageDifference(this Image img1, Image img2, byte threshold = 10)
Copy link
Member

Choose a reason for hiding this comment

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

I understand this is copied over from ImageComparisonTest. I wonder if it makes sense to move this into a common component to avoid the duplication (and potential bugs if the code is changed in ne place only).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense as the shared parts are increasing. What name will you suggest for the shared code?

  • Svg.Tests.Common
  • Svg.Tests.Shared
  • Svg.Tests.Core
  • etc

Copy link
Member

Choose a reason for hiding this comment

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

Common sounds fine, but I have no strong feelings here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will look into it - I will be leaving for church service, and they also requested some IT services from me so will not be available for at least 8 hours.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrbean-bremen After looking into it, we should consider the shared library as separate PR.
Currently, the Svg.Benchmark project references the Svg.UnitTests project just to access an extension method, and I think the shared library should extend there too.
As a separate PR, we will give it a better review.

    <ItemGroup>
        <ProjectReference Include="..\..\Source\Svg.csproj" />
        <ProjectReference Include="..\Svg.UnitTests\Svg.UnitTests.csproj" />
    </ItemGroup>

Copy link
Member

Choose a reason for hiding this comment

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

Sure, agreed!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, if there is no remaining issue on this PR, can I proceed with the merge?

{
byte[,] differences = img1.GetDifferences(img2);

int diffPixels = 0;

foreach (byte b in differences)
{
if (b > threshold) { diffPixels++; }
}

return diffPixels / (float)(differences.GetLength(0) * differences.GetLength(1));
}

public static Bitmap Resize(this Image originalImage, int newWidth, int newHeight)
{
if (originalImage.Width > originalImage.Height)
newWidth = originalImage.Width * newHeight / originalImage.Height;
else
newHeight = originalImage.Height * newWidth / originalImage.Width;

var smallVersion = new Bitmap(newWidth, newHeight);
using (var g = Graphics.FromImage(smallVersion))
{
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(originalImage, 0, 0, smallVersion.Width, smallVersion.Height);
}

return smallVersion;
}

public static byte[,] GetGrayScaleValues(this Bitmap img)
{
byte[,] grayScale = new byte[img.Width, img.Height];

for (int y = 0; y < grayScale.GetLength(1); y++)
{
for (int x = 0; x < grayScale.GetLength(0); x++)
{
var alpha = img.GetPixel(x, y).A;
var gray = img.GetPixel(x, y).R;
grayScale[x, y] = (byte)Math.Abs(gray * alpha / 255);
}
}
return grayScale;
}

// the colormatrix needed to grayscale an image
static readonly ColorMatrix ColorMatrix = new ColorMatrix(new float[][]
{
new float[] {.3f, .3f, .3f, 0, 0},
new float[] {.59f, .59f, .59f, 0, 0},
new float[] {.11f, .11f, .11f, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}
});

public static Bitmap GetGrayScaleVersion(this Bitmap original)
{
// create a blank bitmap the same size as original
// https://web.archive.org/web/20130111215043/http://www.switchonthecode.com/tutorials/csharp-tutorial-convert-a-color-image-to-grayscale
var newBitmap = new Bitmap(original.Width, original.Height);

// get a graphics object from the new image
using (var g = Graphics.FromImage(newBitmap))
// create some image attributes
using (var attributes = new ImageAttributes())
{
// set the color matrix attribute
attributes.SetColorMatrix(ColorMatrix);

// draw the original image on the new image
// using the grayscale color matrix
g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
}

return newBitmap;
}

public static byte[,] GetDifferences(this Image img1, Image img2)
{
using (var resizedThisOne = img1.Resize(ImageWidth, ImageHeight))
using (var thisOne = resizedThisOne.GetGrayScaleVersion())
using (var resizedTheOtherOne = img2.Resize(ImageWidth, ImageHeight))
using (var theOtherOne = resizedTheOtherOne.GetGrayScaleVersion())
{
byte[,] differences = new byte[thisOne.Width, thisOne.Height];
byte[,] firstGray = thisOne.GetGrayScaleValues();
byte[,] secondGray = theOtherOne.GetGrayScaleValues();

for (int y = 0; y < differences.GetLength(1); y++)
{
for (int x = 0; x < differences.GetLength(0); x++)
{
differences[x, y] = (byte)Math.Abs(firstGray[x, y] - secondGray[x, y]);
}
}
return differences;
}
}
}

}
7 changes: 5 additions & 2 deletions Tests/SvgW3CTestRunner/BitmapUtils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Drawing.Imaging;
using System.Drawing;
using System;

namespace SvgW3CTestRunner
{
Expand All @@ -10,8 +11,10 @@ internal static class BitmapUtils
#endif
public static unsafe Bitmap PixelDiff(Bitmap a, Bitmap b)
{
Bitmap output = new Bitmap(a.Width, a.Height, PixelFormat.Format32bppArgb);
Rectangle rect = new Rectangle(Point.Empty, a.Size);
var width = Math.Min(a.Width, b.Width);
var height = Math.Min(a.Height, b.Height);
Bitmap output = new Bitmap(width, height, PixelFormat.Format32bppArgb);
Rectangle rect = new Rectangle(Point.Empty, new Size(width, height));
using (var aData = a.LockBitsDisposable(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb))
using (var bData = b.LockBitsDisposable(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb))
using (var outputData = output.LockBitsDisposable(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb))
Expand Down
1 change: 1 addition & 0 deletions Tests/SvgW3CTestRunner/ListSearchDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions Tests/SvgW3CTestRunner/ListSearchDialog.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SvgW3CTestRunner
Expand All @@ -18,14 +11,12 @@ public partial class ListSearchDialog : Form
public ListSearchDialog()
{
InitializeComponent();

this.Load += OnFormDialogLoad;
}

public int SeletedTabIndex { get => _seletedTabIndex; set => _seletedTabIndex = value; }
public ListBox[] ListItems { get => _listItems; set => _listItems = value; }

private void OnFormDialogLoad(object sender, EventArgs e)
private void OnLoadDialog(object sender, EventArgs e)
{
if (_listItems != null && _listItems.Length == 4)
{
Expand Down
Loading