Skip to content

Commit

Permalink
chore: fix shadows runtime tests (backport #812) (#815)
Browse files Browse the repository at this point in the history
Co-authored-by: agneszitte <agnes@platform.uno>
  • Loading branch information
mergify[bot] and agneszitte committed Sep 5, 2023
1 parent 14a2b77 commit 6669308
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions src/Uno.Toolkit.RuntimeTests/Tests/ShadowContainerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
using Windows.Storage;
using System.IO;
using System.Runtime.InteropServices.WindowsRuntime;



using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Media;
Expand All @@ -33,9 +30,9 @@ namespace Uno.Toolkit.RuntimeTests.Tests
{
[TestClass]
[RunsOnUIThread]
#if HAS_UNO_WINUI && !(NET6_0_OR_GREATER || NETSTANDARD2_0)
#if HAS_UNO_WINUI && !(NET6_0_OR_GREATER || NETSTANDARD2_0)
[Ignore("Disabled because Skia.Sharp doesn't support Xamarin+WinUI.")]
#endif
#endif
internal partial class ShadowContainerTests
{
[TestMethod]
Expand Down Expand Up @@ -77,6 +74,7 @@ public async Task Displays_Content()
await renderer.AssertColorAt(Colors.Green, 100, 300);
}

#if !(__ANDROID__ || __IOS__)
[TestMethod]
public async Task Displays_Content_With_Margin()
{
Expand Down Expand Up @@ -112,16 +110,15 @@ public async Task Displays_Content_With_Margin()
await renderer.AssertColorAt(Colors.Green, 75, 225);
}

#if !(__ANDROID__ || __IOS__)
[TestMethod]
[DataRow(10, 10, false)]
//[DataRow(10, 10, true)]
//[DataRow(-10, -10, false)]
//[DataRow(-10, -10, true)]
//[DataRow(-10, 10, true)]
//[DataRow(10, -10, true)]
//[DataRow(-10, 10, false)]
//[DataRow(10, -10, false)]
[DataRow(10, 10, true)]
[DataRow(-10, -10, false)]
[DataRow(-10, -10, true)]
[DataRow(-10, 10, true)]
[DataRow(10, -10, true)]
[DataRow(-10, 10, false)]
[DataRow(10, -10, false)]
public async Task Outer_Shadows(int offsetX, int offsetY, bool inner)
{
if (!ImageAssertHelper.IsScreenshotSupported())
Expand Down Expand Up @@ -159,27 +156,6 @@ public async Task Outer_Shadows(int offsetX, int offsetY, bool inner)
var xStart = offsetX < 0 ? (int)bounds.Left : (int)bounds.Right;
var yStart = offsetY < 0 ? (int)bounds.Top : (int)bounds.Bottom;


var pixels = await renderer!.GetPixelsAsync();
var dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

var c = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "image.png");
using (var fileStream = File.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "image.png")).AsRandomAccessStream())
{
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream);

encoder.SetPixelData(
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Ignore,
(uint)renderer.PixelWidth,
(uint)renderer.PixelHeight,
96, 96,
pixels.ToArray()
);

await encoder.FlushAsync();
}

await renderer.AssertColorAt(Colors.Green, 100, 100);
await renderer.AssertColorAt(Colors.Red, 210, 100);

Expand Down

0 comments on commit 6669308

Please sign in to comment.