Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-12-02 13:16:17 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-12-02 13:16:17 +0400
commit31083e058e7bf79504d01de9d5486d7ca478a1f6 (patch)
tree9b5a40d4e3edac9b39e1d0dfc0c7dfb99c69b2f9 /Testing
parent2b7a78e58e6571505eae8b8797fe1a76d30cd5de (diff)
Fixed rendering of 9-patch images in retina resolution
Diffstat (limited to 'Testing')
-rw-r--r--Testing/GtkTestRunner.csproj12
-rw-r--r--Testing/MacTestRunner.csproj12
-rw-r--r--Testing/Tests/DrawingTestsBase.cs4
-rw-r--r--Testing/Tests/NinePatchTests.cs161
-rw-r--r--Testing/Tests/ReferenceImageManager.cs21
-rw-r--r--Testing/Tests/ninep-ss.9@2x.pngbin0 -> 2239 bytes
-rw-r--r--Testing/Tests/ninep-st.9@2x.pngbin0 -> 2243 bytes
-rw-r--r--Testing/Tests/ninep-ts.9@2x.pngbin0 -> 2242 bytes
-rw-r--r--Testing/Tests/ninep-tt.9@2x.pngbin0 -> 2247 bytes
9 files changed, 198 insertions, 12 deletions
diff --git a/Testing/GtkTestRunner.csproj b/Testing/GtkTestRunner.csproj
index dfaf3fea..864fac51 100644
--- a/Testing/GtkTestRunner.csproj
+++ b/Testing/GtkTestRunner.csproj
@@ -143,5 +143,17 @@
<EmbeddedResource Include="Tests\ninep-tt.9.png">
<LogicalName>ninep-tt.9.png</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-ss.9%402x.png">
+ <LogicalName>ninep-ss.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-st.9%402x.png">
+ <LogicalName>ninep-st.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-ts.9%402x.png">
+ <LogicalName>ninep-ts.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-tt.9%402x.png">
+ <LogicalName>ninep-tt.9@2x.png</LogicalName>
+ </EmbeddedResource>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Testing/MacTestRunner.csproj b/Testing/MacTestRunner.csproj
index 587d5812..1039b3da 100644
--- a/Testing/MacTestRunner.csproj
+++ b/Testing/MacTestRunner.csproj
@@ -270,5 +270,17 @@
<EmbeddedResource Include="Tests\ninep-tt.9.png">
<LogicalName>ninep-tt.9.png</LogicalName>
</EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-ss.9%402x.png">
+ <LogicalName>ninep-ss.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-st.9%402x.png">
+ <LogicalName>ninep-st.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-ts.9%402x.png">
+ <LogicalName>ninep-ts.9@2x.png</LogicalName>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Tests\ninep-tt.9%402x.png">
+ <LogicalName>ninep-tt.9@2x.png</LogicalName>
+ </EmbeddedResource>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Testing/Tests/DrawingTestsBase.cs b/Testing/Tests/DrawingTestsBase.cs
index 959014d0..98bf0fcb 100644
--- a/Testing/Tests/DrawingTestsBase.cs
+++ b/Testing/Tests/DrawingTestsBase.cs
@@ -52,11 +52,11 @@ namespace Xwt
context.SetLineWidth (1);
}
- protected void CheckImage (string refImageName)
+ protected void CheckImage (string refImageName, double scaleFactor = 1)
{
if (builder == null)
return;
- var img = builder.ToBitmap ();
+ var img = builder.ToBitmap (scaleFactor);
builder.Dispose ();
builder = null;
diff --git a/Testing/Tests/NinePatchTests.cs b/Testing/Tests/NinePatchTests.cs
index d3d17122..5f20a6d8 100644
--- a/Testing/Tests/NinePatchTests.cs
+++ b/Testing/Tests/NinePatchTests.cs
@@ -189,6 +189,167 @@ namespace Xwt
context.DrawImage (np, 0, 0);
CheckImage ("NinePatchTileTileHigher.png");
}
+
+ // 2x scale factor
+
+ [Test]
+ public void NinePatchStretchStretchDefaultSize2x ()
+ {
+ var np = Image.FromResource ("ninep-ss.9.png");
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchStretchDefaultSize2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchStretchWiderHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-ss.9.png");
+ np = np.WithSize (np.Width * 3, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchStretchWiderHigher2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchStretchWider2x ()
+ {
+ var np = Image.FromResource ("ninep-ss.9.png");
+ np = np.WithSize (np.Width * 3, np.Height);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchStretchWider2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchStretchHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-ss.9.png");
+ np = np.WithSize (np.Width, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchStretchHigher2x.png", 2);
+ }
+
+
+ [Test]
+ public void NinePatchStretchTileDefaultSize2x ()
+ {
+ var np = Image.FromResource ("ninep-st.9.png");
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchTileDefaultSize2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchTileWiderHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-st.9.png");
+ np = np.WithSize (np.Width * 3, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchTileWiderHigher2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchTileWider2x ()
+ {
+ var np = Image.FromResource ("ninep-st.9.png");
+ np = np.WithSize (np.Width * 3, np.Height);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchTileWider2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchStretchTileHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-st.9.png");
+ np = np.WithSize (np.Width, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchStretchTileHigher2x.png", 2);
+ }
+
+
+ [Test]
+ public void NinePatchTileStretchDefaultSize2x ()
+ {
+ var np = Image.FromResource ("ninep-ts.9.png");
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileStretchDefaultSize2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileStretchWiderHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-ts.9.png");
+ np = np.WithSize (np.Width * 3, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileStretchWiderHigher2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileStretchWider2x ()
+ {
+ var np = Image.FromResource ("ninep-ts.9.png");
+ np = np.WithSize (np.Width * 3, np.Height);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileStretchWider2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileStretchHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-ts.9.png");
+ np = np.WithSize (np.Width, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileStretchHigher2x.png", 2);
+ }
+
+
+ [Test]
+ public void NinePatchTileTileDefaultSize2x ()
+ {
+ var np = Image.FromResource ("ninep-tt.9.png");
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileTileDefaultSize2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileTileWiderHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-tt.9.png");
+ np = np.WithSize (np.Width * 3, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileTileWiderHigher2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileTileWider2x ()
+ {
+ var np = Image.FromResource ("ninep-tt.9.png");
+ np = np.WithSize (np.Width * 3, np.Height);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileTileWider2x.png", 2);
+ }
+
+ [Test]
+ public void NinePatchTileTileHigher2x ()
+ {
+ var np = Image.FromResource ("ninep-tt.9.png");
+ np = np.WithSize (np.Width, np.Height * 3);
+ InitBlank ((int)np.Width, (int)np.Height);
+ context.DrawImage (np, 0, 0);
+ CheckImage ("NinePatchTileTileHigher2x.png", 2);
+ }
}
}
diff --git a/Testing/Tests/ReferenceImageManager.cs b/Testing/Tests/ReferenceImageManager.cs
index 548880d4..d17c05db 100644
--- a/Testing/Tests/ReferenceImageManager.cs
+++ b/Testing/Tests/ReferenceImageManager.cs
@@ -99,8 +99,9 @@ namespace Xwt
return null;
}
- public static void CheckImage (string refImageName, Image img)
+ public static void CheckImage (string refImageName, Image im)
{
+ BitmapImage img = im as BitmapImage ?? im.ToBitmap ();
Image coreRefImage = LoadReferenceImage (refImageName);
Image refImage = !RecheckAll ? LoadCustomReferenceImage (refImageName) : null;
@@ -109,8 +110,8 @@ namespace Xwt
if (refImage == null) {
ImageFailures.Add (new FailedImageInfo () {
- TestImage = img,
- ReferenceImage = img,
+ TestImage = img.WithSize (img.PixelWidth, img.PixelHeight),
+ ReferenceImage = img.WithSize (img.PixelWidth, img.PixelHeight),
Name = refImageName,
TargetDir = ProjectReferenceImageDir
});
@@ -135,8 +136,8 @@ namespace Xwt
if (!knownFailure) {
ImageFailures.Add (new FailedImageInfo () {
- TestImage = img,
- ReferenceImage = refImage,
+ TestImage = img.WithSize (img.PixelWidth, img.PixelHeight),
+ ReferenceImage = refImage.WithSize (img.PixelWidth, img.PixelHeight),
DiffImage = diff,
Name = refImageName,
TargetDir = ProjectCustomReferenceImageDir
@@ -149,13 +150,13 @@ namespace Xwt
public static Image DiffImages (Image img1, Image img2)
{
bool foundDifference = false;
- var bmp1 = img1.ToBitmap ();
- var bmp2 = img2.ToBitmap ();
- var res = new ImageBuilder ((int)Math.Min (bmp1.Size.Width, bmp2.Size.Width), (int) Math.Min (bmp1.Size.Height, bmp2.Size.Height));
+ var bmp1 = (img1 as BitmapImage) ?? img1.ToBitmap ();
+ var bmp2 = (img2 as BitmapImage) ?? img2.ToBitmap ();
+ var res = new ImageBuilder ((int)Math.Min (bmp1.PixelWidth, bmp2.PixelWidth), (int) Math.Min (bmp1.PixelHeight, bmp2.PixelHeight));
var bmpr = res.ToBitmap ();
res.Dispose ();
- for (int y=0; y<bmp1.Size.Height && y < bmp2.Size.Height; y++) {
- for (int x=0; x<bmp1.Size.Width && x<bmp2.Size.Width; x++) {
+ for (int y=0; y<bmp1.PixelHeight && y < bmp2.PixelHeight; y++) {
+ for (int x=0; x<bmp1.PixelWidth && x<bmp2.PixelWidth; x++) {
var p1 = bmp1.GetPixel (x, y);
var p2 = bmp2.GetPixel (x, y);
var col = Colors.White;
diff --git a/Testing/Tests/ninep-ss.9@2x.png b/Testing/Tests/ninep-ss.9@2x.png
new file mode 100644
index 00000000..049a51ef
--- /dev/null
+++ b/Testing/Tests/ninep-ss.9@2x.png
Binary files differ
diff --git a/Testing/Tests/ninep-st.9@2x.png b/Testing/Tests/ninep-st.9@2x.png
new file mode 100644
index 00000000..aacb21a6
--- /dev/null
+++ b/Testing/Tests/ninep-st.9@2x.png
Binary files differ
diff --git a/Testing/Tests/ninep-ts.9@2x.png b/Testing/Tests/ninep-ts.9@2x.png
new file mode 100644
index 00000000..a27a4dc0
--- /dev/null
+++ b/Testing/Tests/ninep-ts.9@2x.png
Binary files differ
diff --git a/Testing/Tests/ninep-tt.9@2x.png b/Testing/Tests/ninep-tt.9@2x.png
new file mode 100644
index 00000000..0d2aa345
--- /dev/null
+++ b/Testing/Tests/ninep-tt.9@2x.png
Binary files differ