diff --git a/src/Controls/tests/DeviceTests/ControlsHandlerTestBase.cs b/src/Controls/tests/DeviceTests/ControlsHandlerTestBase.cs index 92fc4f135a9e..244b090577f7 100644 --- a/src/Controls/tests/DeviceTests/ControlsHandlerTestBase.cs +++ b/src/Controls/tests/DeviceTests/ControlsHandlerTestBase.cs @@ -393,5 +393,8 @@ protected IToolbar GetToolbar(IElementHandler handler) .SingleOrDefault(x => x.Toolbar != null) ?.Toolbar; } + + protected Task ValidateHasColor(IView view, Color color, Action action = null) => + ValidateHasColor(view, color, typeof(THandler), action); } } diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs new file mode 100644 index 000000000000..a16a541f54ff --- /dev/null +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Maui.Graphics; +using Microsoft.Maui.Handlers; +using Microsoft.Maui.Platform; + +namespace Microsoft.Maui.DeviceTests +{ + public partial class BoxViewTests + { + MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewViewHandler) => + boxViewViewHandler.PlatformView; + } +} \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs new file mode 100644 index 000000000000..d27d3027ac5f --- /dev/null +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Maui.Graphics.Win2D; +using Microsoft.Maui.Handlers; + +namespace Microsoft.Maui.DeviceTests +{ + public partial class BoxViewTests + { + W2DGraphicsView GetNativeBoxView(ShapeViewHandler boxViewHandler) => + boxViewHandler.PlatformView; + } +} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs similarity index 52% rename from src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.cs rename to src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index 8e822706d23e..9c3e392fc726 100644 --- a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -1,30 +1,32 @@ using System.Threading.Tasks; -using Microsoft.Maui.DeviceTests.Stubs; +using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; +using Microsoft.Maui.Hosting; using Xunit; + namespace Microsoft.Maui.DeviceTests { [Category(TestCategory.BoxView)] - public partial class BoxViewHandlerTests : CoreHandlerTestBase + public partial class BoxViewTests : ControlsHandlerTestBase { [Theory(DisplayName = "BoxView Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BoxViewInitializesCorrectly(uint color) { var expected = Color.FromUint(color); - var boxView = new BoxViewStub() + var boxView = new BoxView() { Color = expected, - Height = 100, - Width = 200 + HeightRequest = 100, + WidthRequest = 200 }; - await ValidateHasColor(boxView, expected); + await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs new file mode 100644 index 000000000000..62ca5e6e41e9 --- /dev/null +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Maui.Graphics; +using Microsoft.Maui.Handlers; +using Microsoft.Maui.Platform; + +namespace Microsoft.Maui.DeviceTests +{ + public partial class BoxViewTests + { + MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewHandler) => + boxViewHandler.PlatformView; + } +} \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs index d1d1830cc11d..900c1889399c 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs @@ -13,16 +13,5 @@ public partial class CheckBoxTests { AppCompatCheckBox GetNativeCheckBox(CheckBoxHandler checkBoxHandler) => checkBoxHandler.PlatformView; - - Task ValidateHasColor(ICheckBox checkBox, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var handler = CreateHandler(checkBox); - var nativeSwitch = GetNativeCheckBox(handler); - action?.Invoke(); - nativeSwitch.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs index 5b679ff51c1d..2a038c567052 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs @@ -10,16 +10,5 @@ public partial class CheckBoxTests { CheckBox GetNativeCheckBox(CheckBoxHandler checkBoxHandler) => checkBoxHandler.PlatformView; - - Task ValidateHasColor(ICheckBox checkBox, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var handler = CreateHandler(checkBox); - var nativeSwitch = GetNativeCheckBox(handler); - action?.Invoke(); - nativeSwitch.AssertContainsColor(color); - }); - } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs index f3a9785308a8..499810af7f26 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; +using Microsoft.Maui.Handlers; using Xunit; namespace Microsoft.Maui.DeviceTests @@ -23,7 +24,7 @@ public async Task UpdatingCheckBoxBackgroundColorUpdatesBackground(string colorS checkBox.BackgroundColor = color; - await ValidateHasColor(checkBox, color); + await ValidateHasColor(checkBox, color); } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs index 2d9c813c22ec..112ca8b29faa 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs @@ -12,16 +12,5 @@ public partial class CheckBoxTests { MauiCheckBox GetNativeCheckBox(CheckBoxHandler checkBoxHandler) => checkBoxHandler.PlatformView; - - Task ValidateHasColor(ICheckBox checkBox, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var handler = CreateHandler(checkBox); - var nativeSwitch = GetNativeCheckBox(handler); - action?.Invoke(); - nativeSwitch.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Frame/FrameTests.cs b/src/Controls/tests/DeviceTests/Elements/Frame/FrameTests.cs index 2e09103dbec8..d5131671ee31 100644 --- a/src/Controls/tests/DeviceTests/Elements/Frame/FrameTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Frame/FrameTests.cs @@ -43,8 +43,8 @@ public async Task BasicFrameTest() }; var labelFrame = - await InvokeOnMainThreadAsync(() => - frame.ToPlatform(MauiContext).AttachAndRun(async () => + await InvokeOnMainThreadAsync(async () => + await frame.ToPlatform(MauiContext).AttachAndRun(async () => { (frame as IView).Measure(300, 300); (frame as IView).Arrange(new Graphics.Rect(0, 0, 300, 300)); diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs index a452edf41e6a..666c82f76c09 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs @@ -35,7 +35,7 @@ public async Task FormattedStringSpanTextHasCorrectColorWhenChanges() formattedLabel.TextColor = expected; - await ValidateHasColor(formattedLabel, expected); + await ValidateHasColor(formattedLabel, expected); } TextView GetPlatformLabel(LabelHandler labelHandler) => @@ -46,15 +46,5 @@ TextUtils.TruncateAt GetPlatformLineBreakMode(LabelHandler labelHandler) => int GetPlatformMaxLines(LabelHandler labelHandler) => GetPlatformLabel(labelHandler).MaxLines; - - Task ValidateHasColor(Label label, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(async () => - { - var labelHandler = CreateHandler(label); - action?.Invoke(); - await labelHandler.PlatformView.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs index 53cd794a886c..28072eaf4e80 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.cs @@ -266,7 +266,7 @@ await InvokeOnMainThreadAsync(async () => var normalHandler = CreateHandler(normalLabel); var normalBitmap = await normalHandler.PlatformView.ToBitmap(); - await normalBitmap.AssertEqual(formattedBitmap); + await normalBitmap.AssertEqualAsync(formattedBitmap); }); } @@ -306,7 +306,7 @@ await InvokeOnMainThreadAsync(async () => var updatedBitmap = await updatedHandler.PlatformView.ToBitmap(); - await updatedBitmap.AssertEqual(initialBitmap); + await updatedBitmap.AssertEqualAsync(initialBitmap); }); static FormattedString GetFormattedString() => @@ -363,7 +363,7 @@ await InvokeOnMainThreadAsync(async () => var normalHandler = CreateHandler(normalLabel); var normalBitmap = await normalHandler.PlatformView.ToBitmap(); - await normalBitmap.AssertEqual(formattedBitmap); + await normalBitmap.AssertEqualAsync(formattedBitmap); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs b/src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs index 76e5ffda0a0e..5e475c952ee2 100644 --- a/src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs @@ -130,7 +130,7 @@ await InvokeOnMainThreadAsync(async () => return updatingHandler.PlatformView.ToBitmap(); }); - await initialBitmap.AssertEqual(updatingBitmap); + await initialBitmap.AssertEqualAsync(updatingBitmap); }); static void CreateLayout(Type layoutType, out Layout layout, out Label label) diff --git a/src/Controls/tests/DeviceTests/TestCategory.cs b/src/Controls/tests/DeviceTests/TestCategory.cs index 5ec97753a6ed..bb8093af0d36 100644 --- a/src/Controls/tests/DeviceTests/TestCategory.cs +++ b/src/Controls/tests/DeviceTests/TestCategory.cs @@ -5,6 +5,7 @@ public static class TestCategory public const string Accessibility = "Accessibility"; public const string Application = "Application"; public const string Behavior = "Behavior"; + public const string BoxView = "BoxView"; public const string Button = "Button"; public const string CheckBox = "CheckBox"; public const string Compatibility = "Compatibility"; diff --git a/src/Core/src/Platform/Android/MauiTextView.cs b/src/Core/src/Platform/Android/MauiTextView.cs index 2cdfaa26e4f8..22883c668b6a 100644 --- a/src/Core/src/Platform/Android/MauiTextView.cs +++ b/src/Core/src/Platform/Android/MauiTextView.cs @@ -8,7 +8,11 @@ public class MauiTextView : AppCompatTextView { public MauiTextView(Context context) : base(context) { + this.ViewAttachedToWindow += MauiTextView_ViewAttachedToWindow; + } + private void MauiTextView_ViewAttachedToWindow(object? sender, ViewAttachedToWindowEventArgs e) + { } internal event EventHandler? LayoutChanged; diff --git a/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBase.cs b/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBase.cs index 90ed3c40565c..de7e6fef9435 100644 --- a/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBase.cs +++ b/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBase.cs @@ -139,11 +139,29 @@ protected TCustomHandler CreateHandler(IElement elemen #if PLATFORM protected IPlatformViewHandler CreateHandler(IElement view, Type handlerType) { + if (view.Handler is IPlatformViewHandler t) + return t; + var handler = (IPlatformViewHandler)Activator.CreateInstance(handlerType); InitializeViewHandler(view, handler, MauiContext); return handler; } + + protected Task ValidateHasColor(IView view, Color color, Type handlerType, Action action = null) + { +#if !TIZEN + return InvokeOnMainThreadAsync(async () => + { + var plaformView = CreateHandler(view, handlerType).ToPlatform(); + action?.Invoke(); + await plaformView.AssertContainsColor(color); + }); +#else + throw new NotImplementedException(); +#endif + } + #endif public void Dispose() diff --git a/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBaseOfT.cs b/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBaseOfT.cs index aeec9f36be31..381a0b05029a 100644 --- a/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBaseOfT.cs +++ b/src/Core/tests/DeviceTests.Shared/HandlerTests/HandlerTestBaseOfT.cs @@ -157,6 +157,9 @@ async protected Task ValidateUnrelatedPropertyUnaffected( Assert.Equal(initialNativeVal, newNativeVal); } + + protected Task ValidateHasColor(IView view, Color color, Action action = null) => + ValidateHasColor(view, color, typeof(THandler), action); } } #endif \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Android.cs index 2bdd59c97ba8..479adb8a95d6 100644 --- a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Android.cs @@ -17,16 +17,6 @@ ProgressBar GetNativeActivityIndicator(ActivityIndicatorHandler activityIndicato bool GetNativeIsRunning(ActivityIndicatorHandler activityIndicatorHandler) => GetNativeActivityIndicator(activityIndicatorHandler).Visibility == ViewStates.Visible; - Task ValidateHasColor(IActivityIndicator activityIndicator, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeActivityIndicator = GetNativeActivityIndicator(CreateHandler(activityIndicator)); - action?.Invoke(); - nativeActivityIndicator.AssertContainsColor(color); - }); - } - [Theory(DisplayName = "Visibility is set correctly")] [InlineData(Visibility.Visible)] [InlineData(Visibility.Collapsed)] diff --git a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Windows.cs index 86b67b6eb638..0f9043211ea5 100644 --- a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.Windows.cs @@ -13,15 +13,5 @@ ProgressRing GetNativeActivityIndicator(ActivityIndicatorHandler activityIndicat bool GetNativeIsRunning(ActivityIndicatorHandler activityIndicatorHandler) => GetNativeActivityIndicator(activityIndicatorHandler).IsActive; - - Task ValidateHasColor(IActivityIndicator activityIndicator, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeActivityIndicator = GetNativeActivityIndicator(CreateHandler(activityIndicator)); - action?.Invoke(); - nativeActivityIndicator.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.cs index 64b0996aa495..2fc7d0979991 100644 --- a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.cs @@ -22,7 +22,8 @@ public async Task IsRunningInitializesCorrectly(bool isRunning) await ValidatePropertyInitValue(activityIndicator, () => activityIndicator.IsRunning, GetNativeIsRunning, activityIndicator.IsRunning); } - [Fact(DisplayName = "Background Updates Correctly")] + [Fact(DisplayName = "Background Updates Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] public async Task BackgroundUpdatesCorrectly() { var activityIndicator = new ActivityIndicatorStub() diff --git a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.iOS.cs index 41e65852f134..0a9f1429e5a6 100644 --- a/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/ActivityIndicator/ActivityIndicatorHandlerTests.iOS.cs @@ -14,15 +14,5 @@ UIActivityIndicatorView GetNativeActivityIndicator(ActivityIndicatorHandler acti bool GetNativeIsRunning(ActivityIndicatorHandler activityIndicatorHandler) => GetNativeActivityIndicator(activityIndicatorHandler).IsAnimating; - - Task ValidateHasColor(IActivityIndicator activityIndicator, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeActivityIndicator = GetNativeActivityIndicator(CreateHandler(activityIndicator)); - action?.Invoke(); - nativeActivityIndicator.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Android.cs index 93b530892535..32d9896deb05 100644 --- a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Android.cs @@ -8,9 +8,9 @@ namespace Microsoft.Maui.DeviceTests public partial class BorderHandlerTests { [Theory(DisplayName = "Border render without Stroke")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BorderRenderWithoutStroke(uint color) { var expected = Color.FromUint(color); @@ -29,10 +29,11 @@ public async Task BorderRenderWithoutStroke(uint color) await ValidateHasColor(border, expected); } - [Theory(DisplayName = "Background Updates Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [Theory(DisplayName = "Background Updates Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BackgroundUpdatesCorrectly(uint color) { var expected = Color.FromUint(color); @@ -53,15 +54,5 @@ public async Task BackgroundUpdatesCorrectly(uint color) ContentViewGroup GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; - - Task ValidateHasColor(IBorderView border, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBorder = GetNativeBorder(CreateHandler(border)); - action?.Invoke(); - nativeBorder.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Windows.cs index 3e88012ef193..b49f66f8d391 100644 --- a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.Windows.cs @@ -7,15 +7,5 @@ public partial class BorderHandlerTests { ContentPanel GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; - - Task ValidateHasColor(IBorderView border, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBorder = GetNativeBorder(CreateHandler(border)); - action?.Invoke(); - nativeBorder.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.cs index 542411170656..111481f6aaf5 100644 --- a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.cs @@ -10,9 +10,9 @@ namespace Microsoft.Maui.DeviceTests public partial class BorderHandlerTests : CoreHandlerTestBase { [Theory(DisplayName = "Background Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BackgroundInitializesCorrectly(uint color) { var expected = Color.FromUint(color); @@ -32,9 +32,9 @@ public async Task BackgroundInitializesCorrectly(uint color) } [Theory(DisplayName = "Stroke Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task StrokeInitializesCorrectly(uint color) { var expected = Color.FromUint(color); diff --git a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.iOS.cs index 6c1f40aa0101..debbef71e6cb 100644 --- a/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Border/BorderHandlerTests.iOS.cs @@ -9,15 +9,5 @@ public partial class BorderHandlerTests { ContentView GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; - - Task ValidateHasColor(IBorderView border, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBorder = GetNativeBorder(CreateHandler(border)); - action?.Invoke(); - nativeBorder.AssertContainsColor(color); - }); - } } } diff --git a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Android.cs deleted file mode 100644 index dc9c0fd581f4..000000000000 --- a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Android.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Maui.Graphics; -using Microsoft.Maui.Handlers; - -namespace Microsoft.Maui.DeviceTests -{ - public partial class BoxViewHandlerTests - { - MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewViewHandler) => - boxViewViewHandler.PlatformView; - - Task ValidateHasColor(IShapeView boxView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBoxView = GetNativeBoxView(CreateHandler(boxView)); - action?.Invoke(); - nativeBoxView.AssertContainsColor(color); - }); - } - } -} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Windows.cs deleted file mode 100644 index 3f4fef2c5b0c..000000000000 --- a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.Windows.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Maui.Graphics.Win2D; - -namespace Microsoft.Maui.DeviceTests -{ - public partial class BoxViewHandlerTests - { - W2DGraphicsView GetNativeBoxView(ShapeViewHandler boxViewHandler) => - boxViewHandler.PlatformView; - - Task ValidateHasColor(IShapeView boxView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBoxView = GetNativeBoxView(CreateHandler(boxView)); - action?.Invoke(); - nativeBoxView.AssertContainsColor(color); - }); - } - } -} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.iOS.cs deleted file mode 100644 index 99cd1e0dc6c4..000000000000 --- a/src/Core/tests/DeviceTests/Handlers/BoxView/BoxViewHandlerTests.iOS.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Maui.Graphics; -using Microsoft.Maui.Handlers; - -namespace Microsoft.Maui.DeviceTests -{ - public partial class BoxViewHandlerTests - { - MauiShapeView GetNativeBoxView(ShapeViewHandler boxViewHandler) => - boxViewHandler.PlatformView; - - Task ValidateHasColor(IShapeView boxView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeBoxView = GetNativeBoxView(CreateHandler(boxView)); - action?.Invoke(); - nativeBoxView.AssertContainsColor(color); - }); - } - } -} \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Button/ButtonHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Button/ButtonHandlerTests.Android.cs index 206e1d1a83a1..2c63fd439fda 100644 --- a/src/Core/tests/DeviceTests/Handlers/Button/ButtonHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Button/ButtonHandlerTests.Android.cs @@ -157,15 +157,5 @@ bool ImageSourceLoaded(ButtonHandler buttonHandler) TextUtils.TruncateAt GetNativeLineBreakMode(ButtonHandler buttonHandler) => GetNativeButton(buttonHandler).Ellipsize; - - Task ValidateHasColor(IButton button, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformButton = GetNativeButton(CreateHandler(button)); - action?.Invoke(); - platformButton.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.Android.cs index 6a4e75006a03..d4c54a7359ca 100644 --- a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.Android.cs @@ -16,15 +16,5 @@ bool GetNativeIsChecked(CheckBoxHandler checkBoxHandler) => Task ValidateColor(ICheckBox checkBoxStub, Color color, Action action = null) => ValidateHasColor(checkBoxStub, color, action); - - Task ValidateHasColor(ICheckBox checkBoxStub, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSwitch = GetNativeCheckBox(CreateHandler(checkBoxStub)); - action?.Invoke(); - nativeSwitch.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.cs index 33f432ee6a3b..0e395d2cb2ec 100644 --- a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.cs @@ -35,8 +35,8 @@ public async Task ForegroundInitializesCorrectly() } [Theory(DisplayName = "Foreground Updates Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF0000FF)] public async Task ForegroundUpdatesCorrectly(uint color) { var checkBoxStub = new CheckBoxStub @@ -45,10 +45,14 @@ public async Task ForegroundUpdatesCorrectly(uint color) IsChecked = true }; - var expected = Color.FromUint(color); - checkBoxStub.Foreground = new SolidPaint(expected); - - await ValidateColor(checkBoxStub, expected); + await InvokeOnMainThreadAsync(async () => + { + var handler = CreateHandler(checkBoxStub); + var expected = Color.FromUint(color); + checkBoxStub.Foreground = new SolidPaint(expected); + handler.UpdateValue(nameof(checkBoxStub.Foreground)); + await ValidateColor(checkBoxStub, expected); + }); } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs index bbfadeb05aab..67188c0e33fd 100644 --- a/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Editor/EditorHandlerTests.cs @@ -93,8 +93,8 @@ public async Task NullPlaceholderColorDoesntCrash() } [Theory(DisplayName = "PlaceholderColor Updates Correctly")] - [InlineData(0xFF0000, 0x0000FF)] - [InlineData(0x0000FF, 0xFF0000)] + [InlineData(0xFFFF0000, 0xFF0000FF)] + [InlineData(0xFF0000FF, 0xFFFF0000)] public async Task PlaceholderColorUpdatesCorrectly(uint setValue, uint unsetValue) { var editor = new EditorStub diff --git a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs index 97045f148093..262bb3ee2f79 100644 --- a/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Entry/EntryHandlerTests.cs @@ -102,8 +102,8 @@ await ValidatePropertyUpdatesValue( } [Theory(DisplayName = "TextColor Updates Correctly")] - [InlineData(0xFF0000, 0x0000FF)] - [InlineData(0x0000FF, 0xFF0000)] + [InlineData(0xFFFF0000, 0xFF0000FF)] + [InlineData(0xFF0000FF, 0xFFFF0000)] public async Task TextColorUpdatesCorrectly(uint setValue, uint unsetValue) { var entry = new EntryStub(); diff --git a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Android.cs index 6876de93fdd5..bf7190781ff2 100644 --- a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Android.cs @@ -10,15 +10,5 @@ public partial class GraphicsViewHandlerTests { PlatformGraphicsView GetPlatformGraphicsView(GraphicsViewHandler graphicsViewHandler) => graphicsViewHandler.PlatformView; - - Task ValidateHasColor(IGraphicsView graphicsView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var PlatformGraphicsView = GetPlatformGraphicsView(CreateHandler(graphicsView)); - action?.Invoke(); - PlatformGraphicsView.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Windows.cs index a3d139b7cdad..9d5ab10ce2ca 100644 --- a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.Windows.cs @@ -7,15 +7,5 @@ public partial class GraphicsViewHandlerTests { PlatformTouchGraphicsView GetPlatformGraphicsView(GraphicsViewHandler graphicsViewHandler) => graphicsViewHandler.PlatformView; - - Task ValidateHasColor(IGraphicsView graphicsView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var PlatformGraphicsView = GetPlatformGraphicsView(CreateHandler(graphicsView)); - action?.Invoke(); - PlatformGraphicsView.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.cs index 444c0b26362c..b0ef7d996016 100644 --- a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.cs @@ -10,9 +10,9 @@ namespace Microsoft.Maui.DeviceTests public partial class GraphicsViewHandlerTests : CoreHandlerTestBase { [Theory(DisplayName = "GraphicsView Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task GraphicsViewInitializesCorrectly(uint color) { var expected = Color.FromUint(color); diff --git a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.iOS.cs index 6876de93fdd5..bf7190781ff2 100644 --- a/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/GraphicsView/GraphicsViewHandlerTests.iOS.cs @@ -10,15 +10,5 @@ public partial class GraphicsViewHandlerTests { PlatformGraphicsView GetPlatformGraphicsView(GraphicsViewHandler graphicsViewHandler) => graphicsViewHandler.PlatformView; - - Task ValidateHasColor(IGraphicsView graphicsView, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var PlatformGraphicsView = GetPlatformGraphicsView(CreateHandler(graphicsView)); - action?.Invoke(); - PlatformGraphicsView.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Image/ImageHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Image/ImageHandlerTests.Android.cs index c2dc80a2cb69..f2ab13513112 100644 --- a/src/Core/tests/DeviceTests/Handlers/Image/ImageHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Image/ImageHandlerTests.Android.cs @@ -64,7 +64,7 @@ await handler.PlatformView.AttachAndRun(async () => { var result = await service.LoadDrawableAsync(imageSource, handler.PlatformView); - await handler.PlatformView.AssertColorAtCenter(expectedColor.ToPlatform()); + await handler.PlatformView.AssertColorAtCenterAsync(expectedColor.ToPlatform()); }); }); } diff --git a/src/Core/tests/DeviceTests/Handlers/ImageButton/ImageButtonHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/ImageButton/ImageButtonHandlerTests.Android.cs index a12eaf6a8a6b..8d6fc82c0597 100644 --- a/src/Core/tests/DeviceTests/Handlers/ImageButton/ImageButtonHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/ImageButton/ImageButtonHandlerTests.Android.cs @@ -6,7 +6,8 @@ namespace Microsoft.Maui.DeviceTests { public partial class ImageButtonHandlerTests { - [Fact(DisplayName = "Clip ImageButton with Background works Correctly")] + [Fact(DisplayName = "Clip ImageButton with Background works Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] public async Task ClipImageButtonWithBackgroundWorks() { Color expected = Colors.Yellow; @@ -44,16 +45,6 @@ Thickness GetNativePadding(ImageButtonHandler imageButtonHandler) shapeableImageView.ContentPaddingBottom); } - Task ValidateHasColor(IImageButton imageButton, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformImageButton = GetPlatformImageButton(CreateHandler(imageButton)); - action?.Invoke(); - platformImageButton.AssertContainsColor(color); - }); - } - bool ImageSourceLoaded(ImageButtonHandler imageButtonHandler) => imageButtonHandler.PlatformView.Drawable != null; } diff --git a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Android.cs index 7dd140fcfccc..2f38c8a60799 100644 --- a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Android.cs @@ -124,15 +124,5 @@ PaintFlags GetNativeTextDecorations(LabelHandler labelHandler) => float GetNativeLineHeight(LabelHandler labelHandler) => GetPlatformLabel(labelHandler).LineSpacingMultiplier; - - Task ValidateHasColor(ILabel label, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformLabel = GetPlatformLabel(CreateHandler(label)); - action?.Invoke(); - platformLabel.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs index 90fce281b1f4..e6b495c22a38 100644 --- a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.Windows.cs @@ -27,15 +27,5 @@ Color GetNativeTextColor(LabelHandler labelHandler) UI.Xaml.TextAlignment GetNativeHorizontalTextAlignment(LabelHandler labelHandler) => GetPlatformLabel(labelHandler).TextAlignment; - - Task ValidateHasColor(ILabel label, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformLabel = GetPlatformLabel(CreateHandler(label)); - action?.Invoke(); - platformLabel.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.iOS.cs index 6cb5dfe022e1..a84680ee70f0 100644 --- a/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Label/LabelHandlerTests.iOS.cs @@ -219,15 +219,5 @@ double GetNativeLineHeight(LabelHandler labelHandler) return paragraphStyle.LineHeightMultiple; } - - Task ValidateHasColor(ILabel label, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformLabel = GetPlatformLabel(CreateHandler(label)); - action?.Invoke(); - platformLabel.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.Android.cs index c031658e6d11..2f996497c66d 100644 --- a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.Android.cs @@ -13,27 +13,6 @@ namespace Microsoft.Maui.DeviceTests.Handlers.Layout { public partial class LayoutHandlerTests { - [Fact(DisplayName = "Shadow Initializes Correctly")] - public async Task ShadowInitializesCorrectly() - { - var xPlatShadow = new ShadowStub - { - Offset = new Point(10, 10), - Opacity = 1.0f, - Radius = 2.0f - }; - - var layout = new LayoutStub - { - Height = 50, - Width = 50 - }; - - layout.Shadow = xPlatShadow; - - await ValidateHasColor(layout, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); - } - double GetNativeChildCount(IElementHandler layoutHandler) { return GetNativeChildCount(layoutHandler.PlatformView as LayoutViewGroup); @@ -61,16 +40,6 @@ LayoutViewGroup GetNativeLayout(LayoutHandler layoutHandler) return layoutHandler.PlatformView; } - Task ValidateHasColor(ILayout layout, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeLayout = GetNativeLayout(CreateHandler(layout)); - action?.Invoke(); - nativeLayout.AssertContainsColor(color); - }); - } - string GetNativeText(AView view) { return (view as TextView).Text; diff --git a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.cs index a6e4701c2b81..b28072c3ed92 100644 --- a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.cs @@ -9,6 +9,28 @@ namespace Microsoft.Maui.DeviceTests.Handlers.Layout [Category(TestCategory.Layout)] public partial class LayoutHandlerTests : CoreHandlerTestBase { + [Fact(DisplayName = "Shadow Initializes Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] + public async Task ShadowInitializesCorrectly() + { + var xPlatShadow = new ShadowStub + { + Offset = new Point(10, 10), + Opacity = 1.0f, + Radius = 2.0f + }; + + var layout = new LayoutStub + { + Height = 50, + Width = 50 + }; + + layout.Shadow = xPlatShadow; + + await ValidateHasColor(layout, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); + } + [Fact(DisplayName = "Empty layout")] public async Task EmptyLayout() { diff --git a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.iOS.cs index 13931bb2901f..3e80f2b057e2 100644 --- a/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Layout/LayoutHandlerTests.iOS.cs @@ -15,27 +15,6 @@ namespace Microsoft.Maui.DeviceTests.Handlers.Layout { public partial class LayoutHandlerTests { - [Fact(DisplayName = "Shadow Initializes Correctly")] - public async Task ShadowInitializesCorrectly() - { - var xPlatShadow = new ShadowStub - { - Offset = new Point(10, 10), - Opacity = 1.0f, - Radius = 2.0f - }; - - var layout = new LayoutStub - { - Height = 50, - Width = 50 - }; - - layout.Shadow = xPlatShadow; - - await ValidateHasColor(layout, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); - } - LayoutView GetNativeLayout(LayoutHandler layoutHandler) { return layoutHandler.PlatformView; @@ -56,16 +35,6 @@ IReadOnlyList GetNativeChildren(LayoutHandler layoutHandler) return layoutHandler.PlatformView.Subviews; } - Task ValidateHasColor(ILayout layout, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeLayout = GetNativeLayout(CreateHandler(layout)); - action?.Invoke(); - nativeLayout.AssertContainsColor(color); - }); - } - string GetNativeText(UIView view) { return (view as UILabel).Text; diff --git a/src/Core/tests/DeviceTests/Handlers/ProgressBar/ProgressBarHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/ProgressBar/ProgressBarHandlerTests.Android.cs index 58d993814159..ac2b3c90ea9d 100644 --- a/src/Core/tests/DeviceTests/Handlers/ProgressBar/ProgressBarHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/ProgressBar/ProgressBarHandlerTests.Android.cs @@ -16,15 +16,5 @@ double GetNativeProgress(ProgressBarHandler progressBarHandler) => Task ValidateNativeProgressColor(IProgress progressBar, Color color, Action action = null) => ValidateHasColor(progressBar, color, action); - - Task ValidateHasColor(IProgress progressBar, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformProgressBar = GetNativeProgressBar(CreateHandler(progressBar)); - action?.Invoke(); - platformProgressBar.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs index 164db4dd33a4..42ad177ceec8 100644 --- a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs @@ -215,16 +215,6 @@ Android.Views.TextAlignment GetNativeTextAlignment(SearchBarHandler searchBarHan return editText.TextAlignment; } - Task ValidateHasColor(ISearchBar searchBar, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSearchBar = GetNativeSearchBar(CreateHandler(searchBar)); - action?.Invoke(); - nativeSearchBar.AssertContainsColor(color); - }); - } - bool GetNativeIsReadOnly(SearchBarHandler searchBarHandler) { var searchView = GetNativeSearchBar(searchBarHandler); diff --git a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Windows.cs index b308760914b1..b5d113d047c2 100644 --- a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Windows.cs @@ -27,16 +27,6 @@ Color GetNativeTextColor(SearchBarHandler searchBarHandler) string GetNativePlaceholder(SearchBarHandler searchBarHandler) => GetNativeSearchBar(searchBarHandler).PlaceholderText; - Task ValidateHasColor(ISearchBar searchBar, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSearchBar = GetNativeSearchBar(CreateHandler(searchBar)); - action?.Invoke(); - nativeSearchBar.AssertContainsColor(color); - }); - } - double GetInputFieldHeight(SearchBarHandler searchBarHandler) { return GetNativeSearchBar(searchBarHandler).ActualHeight; diff --git a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.cs index 9d0131efe451..dad49dda92db 100644 --- a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.cs @@ -9,10 +9,14 @@ namespace Microsoft.Maui.DeviceTests [Category(TestCategory.SearchBar)] public partial class SearchBarHandlerTests : CoreHandlerTestBase { - [Theory(DisplayName = "Background Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [Theory(DisplayName = "Background Initializes Correctly" +#if IOS + , Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948" +#endif + )] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BackgroundInitializesCorrectly(uint color) { var expected = Color.FromUint(color); @@ -116,7 +120,8 @@ public async Task MaxLengthInitializesCorrectly(int maxLength) Assert.Equal(expectedText, platformText); } - [Fact(DisplayName = "CancelButtonColor Initialize Correctly")] + [Fact(DisplayName = "CancelButtonColor Initialize Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] public async Task CancelButtonColorInitializeCorrectly() { var searchBar = new SearchBarStub() diff --git a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.iOS.cs index c46550f50c90..51cf435cb205 100644 --- a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.iOS.cs @@ -11,10 +11,12 @@ namespace Microsoft.Maui.DeviceTests { public partial class SearchBarHandlerTests { - [Theory(DisplayName = "Gradient Background Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [Theory(DisplayName = "Gradient Background Initializes Correctly", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948" + )] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task GradientBackgroundInitializesCorrectly(uint color) { var expected = Color.FromUint(color); @@ -215,15 +217,5 @@ bool GetNativeIsReadOnly(SearchBarHandler searchBarHandler) return !uiSearchBar.UserInteractionEnabled; } - - Task ValidateHasColor(ISearchBar searchBar, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSearchBar = GetNativeSearchBar(CreateHandler(searchBar)); - action?.Invoke(); - nativeSearchBar.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.Android.cs index 80525fb3279c..74b31f0f7006 100644 --- a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.Android.cs @@ -8,27 +8,6 @@ namespace Microsoft.Maui.DeviceTests { public partial class ShapeViewHandlerTests { - [Fact(DisplayName = "Shadow Initializes Correctly on Shapes")] - public async Task ShadowInitializesCorrectly() - { - var xPlatShadow = new ShadowStub - { - Offset = new Point(10, 10), - Opacity = 1.0f, - Radius = 2.0f - }; - - var rectangle = new RectangleStub - { - Height = 50, - Width = 50 - }; - - rectangle.Shadow = xPlatShadow; - - await ValidateHasColor(rectangle, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); - } - MauiShapeView GetPlatformShapeView(ShapeViewHandler shapeViewHandler) => shapeViewHandler.PlatformView; @@ -39,15 +18,5 @@ Task ValidateNativeFill(IShapeView shapeView, Color color) return GetPlatformShapeView(CreateHandler(shapeView)).AssertContainsColor(color); }); } - - Task ValidateHasColor(IView shape, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeShape = GetPlatformShapeView(CreateHandler(shape)); - action?.Invoke(); - nativeShape.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.cs b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.cs index 4b16d664952d..1e364ecc1d8b 100644 --- a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.cs +++ b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.cs @@ -9,10 +9,32 @@ namespace Microsoft.Maui.DeviceTests [Category(TestCategory.ShapeView)] public partial class ShapeViewHandlerTests : CoreHandlerTestBase { + [Fact(DisplayName = "Shadow Initializes Correctly on Shapes", + Skip = "This test is currently invalid https://github.com/dotnet/maui/issues/11948")] + public async Task ShadowInitializesCorrectly() + { + var xPlatShadow = new ShadowStub + { + Offset = new Point(10, 10), + Opacity = 1.0f, + Radius = 2.0f + }; + + var rectangle = new RectangleStub + { + Height = 50, + Width = 50 + }; + + rectangle.Shadow = xPlatShadow; + + await ValidateHasColor(rectangle, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); + } + [Theory(DisplayName = "Shape Background Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task BackgroundInitializesCorrectly(uint color) { var expected = Color.FromUint(color); @@ -119,9 +141,9 @@ public async Task PolygonInitializesCorrectly() } [Theory(DisplayName = "Polyline Background Initializes Correctly")] - [InlineData(0xFF0000)] - [InlineData(0x00FF00)] - [InlineData(0x0000FF)] + [InlineData(0xFFFF0000)] + [InlineData(0xFF00FF00)] + [InlineData(0xFF0000FF)] public async Task PolylineBackgroundInitializesCorrectly(uint color) { var expected = Color.FromUint(color); diff --git a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.iOS.cs index 80525fb3279c..74b31f0f7006 100644 --- a/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/ShapeView/ShapeViewHandlerTests.iOS.cs @@ -8,27 +8,6 @@ namespace Microsoft.Maui.DeviceTests { public partial class ShapeViewHandlerTests { - [Fact(DisplayName = "Shadow Initializes Correctly on Shapes")] - public async Task ShadowInitializesCorrectly() - { - var xPlatShadow = new ShadowStub - { - Offset = new Point(10, 10), - Opacity = 1.0f, - Radius = 2.0f - }; - - var rectangle = new RectangleStub - { - Height = 50, - Width = 50 - }; - - rectangle.Shadow = xPlatShadow; - - await ValidateHasColor(rectangle, Colors.Red, () => xPlatShadow.Paint = new SolidPaint(Colors.Red)); - } - MauiShapeView GetPlatformShapeView(ShapeViewHandler shapeViewHandler) => shapeViewHandler.PlatformView; @@ -39,15 +18,5 @@ Task ValidateNativeFill(IShapeView shapeView, Color color) return GetPlatformShapeView(CreateHandler(shapeView)).AssertContainsColor(color); }); } - - Task ValidateHasColor(IView shape, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeShape = GetPlatformShapeView(CreateHandler(shape)); - action?.Invoke(); - nativeShape.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Android.cs index 6569cbaf3776..4da53c4b9eac 100644 --- a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Android.cs @@ -65,15 +65,5 @@ bool GetNativeIsEnabled(StepperHandler stepperHandler) return minimumButton.Enabled && maximumButton.Enabled; } - - Task ValidateHasColor(IStepper stepper, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformStepper = GetNativeStepper(CreateHandler(stepper)); - action?.Invoke(); - platformStepper.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Windows.cs index 688f135929f7..fe1fc66e103d 100644 --- a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.Windows.cs @@ -16,15 +16,5 @@ double GetNativeMaximum(StepperHandler stepperHandler) => double GetNativeMinimum(StepperHandler stepperHandler) => GetNativeStepper(stepperHandler).Minimum; - - Task ValidateHasColor(IStepper stepper, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformStepper = GetNativeStepper(CreateHandler(stepper)); - action?.Invoke(); - platformStepper.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.iOS.cs index 1ab22a9b3098..593742a27b9e 100644 --- a/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/Stepper/StepperHandlerTests.iOS.cs @@ -20,15 +20,5 @@ double GetNativeMaximum(StepperHandler stepperHandler) => double GetNativeMinimum(StepperHandler stepperHandler) => GetNativeStepper(stepperHandler).MinimumValue; - - Task ValidateHasColor(IStepper stepper, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var platformStepper = GetNativeStepper(CreateHandler(stepper)); - action?.Invoke(); - platformStepper.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Android.cs index f68511465298..2575a44c321c 100644 --- a/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Android.cs @@ -23,15 +23,5 @@ Task ValidateTrackColor(ISwitch switchStub, Color color, Action action = null) = Task ValidateThumbColor(ISwitch switchStub, Color color, Action action = null) => ValidateHasColor(switchStub, color, action); - - Task ValidateHasColor(ISwitch switchStub, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSwitch = GetNativeSwitch(CreateHandler(switchStub)); - action?.Invoke(); - return nativeSwitch.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Windows.cs b/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Windows.cs index 3dadcb464991..5da30f8e58f8 100644 --- a/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Windows.cs +++ b/src/Core/tests/DeviceTests/Handlers/Switch/SwitchHandlerTests.Windows.cs @@ -21,15 +21,5 @@ Task ValidateTrackColor(ISwitch switchStub, Color color, Action action = null) = Task ValidateThumbColor(ISwitch switchStub, Color color, Action action = null) => ValidateHasColor(switchStub, color, action); - - Task ValidateHasColor(ISwitch switchStub, Color color, Action action = null) - { - return InvokeOnMainThreadAsync(() => - { - var nativeSwitch = GetNativeSwitch(CreateHandler(switchStub)); - action?.Invoke(); - return nativeSwitch.AssertContainsColor(color); - }); - } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Stubs/BoxViewStub.cs b/src/Core/tests/DeviceTests/Stubs/BoxViewStub.cs deleted file mode 100644 index af7e14d1ac33..000000000000 --- a/src/Core/tests/DeviceTests/Stubs/BoxViewStub.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Maui.Graphics; - -namespace Microsoft.Maui.DeviceTests.Stubs -{ - public class BoxViewStub : StubBase, IShapeView - { - public Color Color { get; set; } - - public CornerRadius CornerRadius { get; set; } - - public IShape Shape { get; set; } - - public PathAspect Aspect { get; set; } - - public Paint Fill { get; set; } - - public Paint Stroke { get; set; } - - public double StrokeThickness { get; set; } - - public LineCap StrokeLineCap { get; set; } - - public LineJoin StrokeLineJoin { get; set; } - - public float[] StrokeDashPattern { get; set; } - - public float StrokeMiterLimit { get; set; } - - public float StrokeDashOffset { get; set; } - } -} diff --git a/src/TestUtils/src/DeviceTests.Runners/VisualRunner/Pages/TestResultPage.xaml b/src/TestUtils/src/DeviceTests.Runners/VisualRunner/Pages/TestResultPage.xaml index 49f520173483..8c5d8b949de0 100644 --- a/src/TestUtils/src/DeviceTests.Runners/VisualRunner/Pages/TestResultPage.xaml +++ b/src/TestUtils/src/DeviceTests.Runners/VisualRunner/Pages/TestResultPage.xaml @@ -16,9 +16,9 @@ +