diff --git a/src/SamplesApp/SamplesApp.UITests/Toolkit/UnoSamples_Tests.Elevation.cs b/src/SamplesApp/SamplesApp.UITests/Toolkit/UnoSamples_Tests.Elevation.cs new file mode 100644 index 000000000000..f8ef00cb0776 --- /dev/null +++ b/src/SamplesApp/SamplesApp.UITests/Toolkit/UnoSamples_Tests.Elevation.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using Uno.UITest.Helpers; +using Uno.UITest.Helpers.Queries; +using SamplesApp.UITests.TestFramework; + +namespace SamplesApp.UITests.Toolkit +{ + + [TestFixture] + partial class UnoSamples_Tests : SampleControlUITestBase + { + + [Test] + [ActivePlatforms(Platform.Android, Platform.iOS)] + public void Elevation_Validation() + { + Run("UITests.Shared.Toolkit.Elevation"); + + _app.WaitForElement(_app.Marked("TurnElevation_ON_Button")); + + var turnElevation_ON_Button = _app.Marked("TurnElevation_ON_Button"); + + // Take ScreenShot with no elevation + var screenshot_NoElevation = _app.Screenshot("Elevation - No Elevation"); + + turnElevation_ON_Button.Tap(); + + // Take ScreenShot of with elevation + var screenshot_WithElevation = _app.Screenshot("Elevation - With Elevation"); + + Bitmap img1 = new Bitmap(screenshot_NoElevation.ToString()); + Bitmap img2 = new Bitmap(screenshot_WithElevation.ToString()); + + float diffPercentage = 0; + float diff = 0; + + if (img1.Size != img2.Size) + { + throw new Exception("Images are of different sizes"); + } + else + { + for (int x = 0; x < img1.Width; x++) + { + for (int y = 0; y < img1.Height; y++) + { + Color img1P = img1.GetPixel(x, y); + Color img2P = img2.GetPixel(x, y); + + diff += Math.Abs(img1P.R - img2P.R); + diff += Math.Abs(img1P.G - img2P.G); + diff += Math.Abs(img1P.B - img2P.B); + } + } + + diffPercentage = 100 * (diff / 255) / (img1.Width * img1.Height * 3); + if (diffPercentage < 0.5) + { + Assert.Fail("Images are the same"); + } + } + } + } +} diff --git a/src/SamplesApp/UITests.Shared/Toolkit/Elevation.xaml b/src/SamplesApp/UITests.Shared/Toolkit/Elevation.xaml index b51bdfb281e9..2ff973605b03 100644 --- a/src/SamplesApp/UITests.Shared/Toolkit/Elevation.xaml +++ b/src/SamplesApp/UITests.Shared/Toolkit/Elevation.xaml @@ -13,11 +13,10 @@ + Margin="10" /> - + - + Margin="5" /> +