-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7830 from workgroupengineering/features/Skia/Rend…
…erTargetBitmap feat: Support for RenderTargetBitmap, BitmapEncoder, SoftwareBitmap
- Loading branch information
Showing
60 changed files
with
2,239 additions
and
543 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
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
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
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
82 changes: 82 additions & 0 deletions
82
src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Imaging/RenderTargetBitmap_Tests.cs
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,82 @@ | ||
using System; | ||
using System.IO; | ||
using NUnit.Framework; | ||
using SamplesApp.UITests.Extensions; | ||
using SamplesApp.UITests.TestFramework; | ||
using Uno.UITest.Helpers.Queries; | ||
|
||
namespace SamplesApp.UITests.Windows_UI_Xaml_Media_Imaging | ||
{ | ||
[TestFixture] | ||
[ActivePlatforms(Platform.iOS | Platform.Android)] | ||
public partial class RenderTargetBitmap_Tests : SampleControlUITestBase | ||
{ | ||
private const int TestTimeout = 7 * 60 * 1000; | ||
[Test] | ||
[AutoRetry] | ||
[Timeout(TestTimeout)] | ||
public void When_Render_Border() | ||
=> Validate("Border"); | ||
|
||
public void Validate(string controlName, PixelTolerance? tolerance = null) | ||
{ | ||
Run("UITests.Windows_UI_Xaml_Media_Imaging.RenderTargetBitmaps", skipInitialScreenshot: true); | ||
|
||
var ctrl = new QueryEx(q => q.Marked("_renderTargetTestRoot")); | ||
|
||
var expectedDirectory = Path.Combine( | ||
TestContext.CurrentContext.TestDirectory, | ||
nameof(Windows_UI_Xaml_Media_Imaging) + "/RenderTargetBitmap_Tests_ExpectedResults"); | ||
var actualDirectory = Path.Combine( | ||
TestContext.CurrentContext.WorkDirectory, | ||
nameof(Windows_UI_Xaml_Media_Imaging), | ||
nameof(RenderTargetBitmap_Tests), | ||
controlName); | ||
|
||
tolerance = tolerance ?? (new PixelTolerance() | ||
.WithColor(132) // We are almost only trying to detect edges | ||
.WithOffset(3, 3, LocationToleranceKind.PerPixel) | ||
.Discrete(2)); | ||
|
||
ctrl.SetDependencyPropertyValue("RunTest", controlName); | ||
_app.WaitFor(() => !string.IsNullOrWhiteSpace(ctrl.GetDependencyPropertyValue<string>("TestResult")) | ||
, timeout: TimeSpan.FromMinutes(1)); | ||
|
||
var testResultsRaw = ctrl.GetDependencyPropertyValue<string>("TestResult"); | ||
|
||
var testResults = testResultsRaw.Split(';'); | ||
Assert.That(testResults.Length, Is.EqualTo(2)); | ||
|
||
var isSuccess = testResults[0] == "SUCCESS"; | ||
var data = Convert.FromBase64String(testResults[1]); | ||
|
||
Assert.IsNotEmpty(data, "Invalid data"); | ||
|
||
var target = Path | ||
.Combine(actualDirectory, controlName + (isSuccess ? ".png" : ".txt")) | ||
.GetNormalizedLongPath(); | ||
var targetFile = new FileInfo(target); | ||
|
||
targetFile.Directory.Create(); | ||
File.WriteAllBytes(target, data); | ||
SetOptions(targetFile, new ScreenshotOptions { IgnoreInSnapshotCompare = true }); | ||
TestContext.AddTestAttachment(target, controlName); | ||
|
||
if (!isSuccess) | ||
{ | ||
Assert.Fail($"No test result for {controlName}."); | ||
} | ||
|
||
var expected = new FileInfo(Path.Combine(expectedDirectory, $"{controlName}.png")); | ||
if (!expected.Exists) | ||
{ | ||
Assert.Fail($"Expected screenshot does not exists ({expected.FullName})"); | ||
} | ||
|
||
var scale = _app.GetDisplayScreenScaling(); | ||
ImageAssert.AreEqual(expected, ImageAssert.FirstQuadrant, | ||
targetFile, ImageAssert.FirstQuadrant, | ||
scale, tolerance.Value); | ||
} | ||
} | ||
} |
Binary file added
BIN
+651 Bytes
...ndows_UI_Xaml_Media_Imaging/RenderTargetBitmap_Tests_ExpectedResults/Border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
15 changes: 0 additions & 15 deletions
15
...lesApp.UnitTests.Shared/Controls/UITests/Presentation/SampleChooserViewMode.Properties.cs
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
Oops, something went wrong.