From d46967da230c9a0b1a1229bb15fdc3cfef592f4b Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Mon, 24 Feb 2025 11:30:57 +0530 Subject: [PATCH 01/30] Added the CornerRadius and IsEnabled property for DeviceTest --- .../Elements/BoxView/BoxViewTests.Android.cs | 41 ++++++++++++++++++- .../Elements/BoxView/BoxViewTests.cs | 22 +++++----- .../Elements/BoxView/BoxViewTests.iOS.cs | 22 ++++++++++ .../Elements/Button/ButtonTests.iOS.cs | 25 +++++++++++ .../Elements/CheckBox/CheckBoxTests.cs | 16 ++++++++ .../Elements/RadioButton/RadioButtonTests.cs | 37 +++++++++++++++++ 6 files changed, 151 insertions(+), 12 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index e087b12bb3fc..ed44194a035d 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -1,9 +1,13 @@ using System; using System.Threading.Tasks; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; - +using System.ComponentModel; +using Xunit; +using Microsoft.Maui.Controls; +using System.Diagnostics; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests @@ -19,5 +23,40 @@ Task GetPlatformOpacity(ShapeViewHandler handler) return nativeView.Alpha; }); } + + Task GetPlatformCornerRadius(BoxViewHandler boxViewHandler) + { + return InvokeOnMainThreadAsync(() => + { + var platformView = GetNativeBoxView(boxViewHandler); + if (platformView.Background is Android.Graphics.Drawables.GradientDrawable gradientDrawable) + { + return (int)gradientDrawable.CornerRadius; + } + return 0; + }); + } + + + + [Fact] + [Description("The CornerRadius of a BoxView should match with native CornerRadius")] + public async Task BoxViewCornerRadius() + { + var boxView = new BoxView + { + Color = Colors.Red, + CornerRadius = 15 + }; + var expectedValue = boxView.CornerRadius; + + var handler = await CreateHandlerAsync(boxView); + + await InvokeOnMainThreadAsync(async () => + { + var platformCornerRadius = await GetPlatformCornerRadius(handler); + Assert.Equal(expectedValue, platformCornerRadius); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index e6a20ffb1bcb..03ad3b468991 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -6,7 +6,8 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; - +using System.ComponentModel; +using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -32,19 +33,18 @@ public async Task BoxViewInitializesCorrectly(uint color) } [Fact] - [Description("The BackgroundColor of a BoxView should match with native background color")] - public async Task BoxViewBackgroundColorConsistent() + [Description("The Background of a Button should match with native Background")] + public async Task BoxViewBackground() { - var expected = Colors.AliceBlue; - - var boxView = new BoxView() + var boxView = new BoxView { - BackgroundColor = expected, - HeightRequest = 100, - WidthRequest = 200 + HeightRequest = 100, + WidthRequest = 200, + Background = Brush.Red }; - - await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); + var expected = (boxView.Background as SolidColorBrush)?.Color; + + await ValidateHasColor(boxView, expected, typeof(BoxViewHandler)); } [Fact] diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs index 67c5fbc701a5..068fbb5523f0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -2,11 +2,13 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -55,5 +57,25 @@ await AttachAndRun(boxView, async handler => Assert.NotNull(graphicsView); }); } + + [Fact] + [Description("The Cornerradius of a Button should match with native CornerRadius")] + public async Task BoxViewCornerRadius() + { + var boxView = new BoxView + { + HeightRequest = 100, + WidthRequest = 200, + CornerRadius = new CornerRadius(15) + }; + var expected = boxView.CornerRadius; + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + var cornerRadius = (float)nativeView.Layer.CornerRadius; + await InvokeOnMainThreadAsync( () => + { + Assert.Equal(expected, cornerRadius); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index 61e7b3bbfaba..56956d86520f 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -6,6 +6,7 @@ using Microsoft.Maui.Handlers; using UIKit; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -22,6 +23,11 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; + Task GetPlatformCornerRadius(ButtonHandler buttonHandler) + { + return InvokeOnMainThreadAsync(() => (int)GetPlatformButton(buttonHandler).Layer.CornerRadius); + } + [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() { @@ -78,5 +84,24 @@ await InvokeOnMainThreadAsync(async () => Assert.True(button.Width < gridWidth, $"Button shouldn't occupy entire layout width. Expected: {gridWidth}<, was {button.Width}"); Assert.True(button.Height < gridHeight, $"Button shouldn't occupy entire layout height. Expected: {gridHeight}<, was {button.Height}"); } + + [Fact] + [Description("The Cornerradius of a Button should match with native CornerRadius")] + public async Task ButtonCornerRadius() + { + var button = new Button + { + CornerRadius = 15, + }; + var expectedValue = button.CornerRadius; + + var handler = await CreateHandlerAsync(button); + + await InvokeOnMainThreadAsync( async () => + { + var platformCornerRadius = await GetPlatformCornerRadius(handler); + Assert.Equal(expectedValue, platformCornerRadius); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs index be8021a5bc6c..72e1f172c9d3 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs @@ -62,5 +62,21 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index 00631e998766..4b41439496bf 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -53,6 +53,43 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, valuesSecond.PlatformViewValue); }); } + + [Fact] + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadius = (float)nativeView.CornerRadius.TopLeft; + Assert.Equal(expected, cornerRadius); + }); + } + + [Fact] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + public async Task RadioButtonIsEnabled() + { + var radioButton = new RadioButton + { + IsEnabled = false + } + var expectedValue = radioButton.IsEnabled; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + #endif } } \ No newline at end of file From effe65272d3d4a6b4885e26cb635458470ceec5e Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Tue, 25 Feb 2025 10:30:01 +0530 Subject: [PATCH 02/30] IsEnabled property for Device tests --- .../Elements/Border/BorderTests.cs | 20 ++++++++++ .../Elements/BoxView/BoxViewTests.Android.cs | 38 +++++++++--------- .../Elements/BoxView/BoxViewTests.Windows.cs | 19 +++++++++ .../Elements/BoxView/BoxViewTests.iOS.cs | 20 ---------- .../Elements/Editor/EditorTests.Android.cs | 21 ++++++++++ .../DeviceTests/Elements/Entry/EntryTests.cs | 1 + .../Elements/Label/LabelTests.Android.cs | 20 ++++++++++ .../RadioButton/RadioButtonTests.Windows.cs | 39 +++++++++++++++++-- .../Elements/RadioButton/RadioButtonTests.cs | 38 +----------------- .../SearchBar/SearchBarTests.Android.cs | 23 +++++++++++ .../SwipeView/SwipeViewTests.Android.cs | 18 +++++++++ 11 files changed, 177 insertions(+), 80 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index 4e3d9cb10525..8429f6637d56 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -8,6 +8,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -283,5 +284,24 @@ public async Task BorderAndStrokeIsCorrectSize() Assert.Equal(180, redBlob.Width, 2d); Assert.Equal(80, redBlob.Height, 2d); } + +#if WINDOWS + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBorderIsEnabledProperty() + { + var border = new Border(); + border.IsEnabled = true; + var expectedValue = border.IsEnabled; + + var handler = await CreateHandlerAsync(border); + var nativeView = GetNativeBorder(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } +#endif } } diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index ed44194a035d..74aa0215e3df 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -8,6 +8,7 @@ using Xunit; using Microsoft.Maui.Controls; using System.Diagnostics; +using Android.Graphics.Drawables; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests @@ -37,26 +38,23 @@ Task GetPlatformCornerRadius(BoxViewHandler boxViewHandler) }); } - - - [Fact] - [Description("The CornerRadius of a BoxView should match with native CornerRadius")] - public async Task BoxViewCornerRadius() - { - var boxView = new BoxView - { - Color = Colors.Red, - CornerRadius = 15 - }; - var expectedValue = boxView.CornerRadius; - - var handler = await CreateHandlerAsync(boxView); + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBoxViewIsEnabledProperty() + { + var boxView = new BoxView + { + IsEnabled = false + }; + var expectedValue = boxView.IsEnabled; - await InvokeOnMainThreadAsync(async () => - { - var platformCornerRadius = await GetPlatformCornerRadius(handler); - Assert.Equal(expectedValue, platformCornerRadius); - }); - } + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ 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 index 994e01829fd3..1a6a0ad5627e 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -19,5 +19,24 @@ Task GetPlatformOpacity(ShapeViewHandler handler) return (float)nativeView.Opacity; }); } + + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task BoxViewIsEnabled() + { + var boxView = new BoxView + { + IsEnabled = false + }; + var expectedValue = boxView.IsEnabled; + + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ 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 index 068fbb5523f0..03b82402a1b0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -57,25 +57,5 @@ await AttachAndRun(boxView, async handler => Assert.NotNull(graphicsView); }); } - - [Fact] - [Description("The Cornerradius of a Button should match with native CornerRadius")] - public async Task BoxViewCornerRadius() - { - var boxView = new BoxView - { - HeightRequest = 100, - WidthRequest = 200, - CornerRadius = new CornerRadius(15) - }; - var expected = boxView.CornerRadius; - var handler = await CreateHandlerAsync(boxView); - var nativeView = GetNativeBoxView(handler); - var cornerRadius = (float)nativeView.Layer.CornerRadius; - await InvokeOnMainThreadAsync( () => - { - Assert.Equal(expected, cornerRadius); - }); - } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs index b4fe33fd2a21..8146fef834f0 100644 --- a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs @@ -3,6 +3,7 @@ using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -66,5 +67,25 @@ public async Task CursorPositionPreservedWhenTextTransformPresent() Assert.Equal(2, editor.CursorPosition); } + + [Fact] + [Description("The IsEnabled property of a Editor should match with native IsEnabled")] + public async Task VerifyEditorIsEnabledProperty() + { + var editor = new Editor + { + IsEnabled = false + }; + var expectedValue = editor.IsEnabled; + + var handler = await CreateHandlerAsync(editor); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs index 8e62d81c37ed..cadf8081f1bb 100644 --- a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs @@ -8,6 +8,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs index d750c7e21143..ad9e4043719a 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs @@ -11,6 +11,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -88,6 +89,25 @@ await InvokeOnMainThreadAsync((System.Action)(() => })); } + [Fact] + [Description("The IsEnabled property of a Label should match with native IsEnabled")] + public async Task VerifyLabelIsEnabledProperty() + { + var label = new Label + { + IsEnabled = false + }; + var expectedValue = label.IsEnabled; + + var handler = await CreateHandlerAsync(label); + var nativeView = GetPlatformLabel(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + TextView GetPlatformLabel(LabelHandler labelHandler) => labelHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index 3cc783bb4286..2544f7dc2f02 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -23,14 +23,47 @@ public async Task VerifyRadioButtonOpacityProperty() Opacity = 0.35f }; var expectedValue = radioButton.Opacity; - - var handler = await CreateHandlerAsync(radioButton); var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => - { + { var nativeOpacityValue = (float)nativeView.Opacity; Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadius = (float)nativeView.CornerRadius.TopLeft; + Assert.Equal(expected, cornerRadius); + }); + } + + [Fact] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + public async Task VerifyRadioButtonIsEnabledProperty() + { + var radioButton = new RadioButton + { + IsEnabled = false + }; + var expectedValue = radioButton.IsEnabled; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index 4b41439496bf..c2394c0c92c5 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -4,6 +4,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -53,43 +54,6 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, valuesSecond.PlatformViewValue); }); } - - [Fact] - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] - public async Task RadioButtonCornerRadius() - { - var radioButton = new RadioButton(); - radioButton.CornerRadius = 15; - var expectedValue = radioButton.CornerRadius; - - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeRadioButton(handler); - await InvokeOnMainThreadAsync(() => - { - var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expected, cornerRadius); - }); - } - - [Fact] - [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] - public async Task RadioButtonIsEnabled() - { - var radioButton = new RadioButton - { - IsEnabled = false - } - var expectedValue = radioButton.IsEnabled; - - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeCheckBox(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } - #endif } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs index 63fe3c327277..a54c1cf94481 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs @@ -4,6 +4,9 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using SearchView = AndroidX.AppCompat.Widget.SearchView; +using System.ComponentModel; +using Xunit; +using Microsoft.Maui.Controls; namespace Microsoft.Maui.DeviceTests { @@ -39,5 +42,25 @@ Task GetPlatformOpacity(SearchBarHandler searchBarHandler) return nativeView.Alpha; }); } + + [Fact] + [Description("The IsEnabled of a SearchBar should match with native IsEnabled")] + public async Task VerifySearchBarIsEnabledProperty() + { + var searchBar = new SearchBar + { + IsEnabled = false + }; + var expectedValue = searchBar.IsEnabled; + + var handler = await CreateHandlerAsync(searchBar); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs index de8afa21e8ec..4f266e97f7c7 100644 --- a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs @@ -98,5 +98,23 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Description("The IsEnabled of a SwipeView should match with native IsEnabled")] + public async Task VerifySwipeViewIsEnabledProperty() + { + var swipeView = new SwipeView + { + IsEnabled = false + }; + var expectedValue = swipeView.IsEnabled; + + var handler = await CreateHandlerAsync(swipeView); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file From 42fa6a57c5778e54d1be7967be5f63758e660c8a Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Tue, 25 Feb 2025 15:09:14 +0530 Subject: [PATCH 03/30] Addressed the feedbacks --- .../Elements/Border/BorderTests.Windows.cs | 17 +++++++++++++++++ .../Elements/Border/BorderTests.cs | 19 ------------------- .../Elements/BoxView/BoxViewTests.Android.cs | 2 -- .../Elements/BoxView/BoxViewTests.Windows.cs | 2 ++ .../Elements/BoxView/BoxViewTests.iOS.cs | 2 -- .../Elements/Button/ButtonTests.iOS.cs | 11 +++-------- .../Elements/RadioButton/RadioButtonTests.cs | 1 - 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index 82b35e999e42..8666300ddca4 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -60,6 +60,23 @@ await AttachAndRun(border, (handler) => await AssertColorAtPoint(border, expected, typeof(BorderHandler), cornerRadius, cornerRadius); } + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBorderIsEnabledProperty() + { + var border = new Border(); + border.IsEnabled = true; + var expectedValue = border.IsEnabled; + + var handler = await CreateHandlerAsync(border); + var nativeView = GetNativeBorder(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + ContentPanel GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index 8429f6637d56..ccf427f65985 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -284,24 +284,5 @@ public async Task BorderAndStrokeIsCorrectSize() Assert.Equal(180, redBlob.Width, 2d); Assert.Equal(80, redBlob.Height, 2d); } - -#if WINDOWS - [Fact] - [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] - public async Task VerifyBorderIsEnabledProperty() - { - var border = new Border(); - border.IsEnabled = true; - var expectedValue = border.IsEnabled; - - var handler = await CreateHandlerAsync(border); - var nativeView = GetNativeBorder(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } -#endif } } diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 74aa0215e3df..3eb45310f6b9 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -7,8 +7,6 @@ using System.ComponentModel; using Xunit; using Microsoft.Maui.Controls; -using System.Diagnostics; -using Android.Graphics.Drawables; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs index 1a6a0ad5627e..f324c47de4c0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -3,6 +3,8 @@ using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Graphics.Win2D; using Microsoft.Maui.Handlers; +using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs index 03b82402a1b0..67c5fbc701a5 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -2,13 +2,11 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.Maui.Controls; -using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index 56956d86520f..a5dfb2058a07 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -22,11 +22,6 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; - - Task GetPlatformCornerRadius(ButtonHandler buttonHandler) - { - return InvokeOnMainThreadAsync(() => (int)GetPlatformButton(buttonHandler).Layer.CornerRadius); - } [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() @@ -96,10 +91,10 @@ public async Task ButtonCornerRadius() var expectedValue = button.CornerRadius; var handler = await CreateHandlerAsync(button); - - await InvokeOnMainThreadAsync( async () => + var nativeView = GetPlatformButton(handler); + await InvokeOnMainThreadAsync( () => { - var platformCornerRadius = await GetPlatformCornerRadius(handler); + var platformCornerRadius = nativeView.Layer.CornerRadius; Assert.Equal(expectedValue, platformCornerRadius); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index c2394c0c92c5..00631e998766 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -4,7 +4,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { From 9186eea10363ad39541193b65de093b66616be73 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:10:21 +0530 Subject: [PATCH 04/30] Update BoxViewTests.cs --- .../Elements/BoxView/BoxViewTests.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index 03ad3b468991..d01d41bc6c32 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -6,7 +6,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests @@ -32,6 +31,22 @@ public async Task BoxViewInitializesCorrectly(uint color) await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); } + [Fact] + [Description("The BackgroundColor of a BoxView should match with native background color")] + public async Task BoxViewBackgroundColorConsistent() + { + var expected = Colors.AliceBlue; + + var boxView = new BoxView() + { + BackgroundColor = expected, + HeightRequest = 100, + WidthRequest = 200 + }; + + await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); + } + [Fact] [Description("The Background of a Button should match with native Background")] public async Task BoxViewBackground() From 63658a66400be399e85468f44d15113288238fef Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:22:51 +0530 Subject: [PATCH 05/30] modified code changes --- .../DeviceTests/Elements/Border/BorderTests.Windows.cs | 2 +- .../tests/DeviceTests/Elements/Border/BorderTests.cs | 1 - .../DeviceTests/Elements/BoxView/BoxViewTests.Android.cs | 1 + .../tests/DeviceTests/Elements/BoxView/BoxViewTests.cs | 6 +++--- .../tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index 8666300ddca4..c0799ce25602 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -61,7 +61,7 @@ await AttachAndRun(border, (handler) => } [Fact] - [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + [Description("The IsEnabled property of a Border should match with native IsEnabled")] public async Task VerifyBorderIsEnabledProperty() { var border = new Border(); diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index ccf427f65985..4e3d9cb10525 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -8,7 +8,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 3eb45310f6b9..8bd82fbc8132 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using Xunit; using Microsoft.Maui.Controls; + namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index d01d41bc6c32..a38a76ce308e 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -4,9 +4,9 @@ using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -48,8 +48,8 @@ public async Task BoxViewBackgroundColorConsistent() } [Fact] - [Description("The Background of a Button should match with native Background")] - public async Task BoxViewBackground() + [Description("The Background of a BoxView should match with native Background")] + public async Task BoxViewBackgroundConsistent() { var boxView = new BoxView { diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index a5dfb2058a07..fd22ef8b01cc 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -1,12 +1,12 @@ #nullable enable using System; +using System.ComponentModel; using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using UIKit; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -81,7 +81,7 @@ await InvokeOnMainThreadAsync(async () => } [Fact] - [Description("The Cornerradius of a Button should match with native CornerRadius")] + [Description("The CornerRadius of a Button should match with native CornerRadius")] public async Task ButtonCornerRadius() { var button = new Button From acb082f75fc87dba8d19008a470ac693e32b850f Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Fri, 28 Feb 2025 13:07:17 +0530 Subject: [PATCH 06/30] resolved windows build error --- .../Elements/Border/BorderTests.Windows.cs | 20 ++--------------- .../Elements/BoxView/BoxViewTests.Windows.cs | 4 +++- .../Elements/Button/ButtonTests.iOS.cs | 6 ++--- .../CheckBox/CheckBoxTests.Android.cs | 16 ++++++++++++++ .../CheckBox/CheckBoxTests.Windows.cs | 17 ++++++++++++++ .../Elements/CheckBox/CheckBoxTests.iOS.cs | 16 ++++++++++++++ .../DeviceTests/Elements/Entry/EntryTests.cs | 1 - .../RadioButton/RadioButtonTests.Windows.cs | 8 ++++--- .../SearchBar/SearchBarTests.Windows.cs | 22 +++++++++++++++++++ 9 files changed, 84 insertions(+), 26 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index c0799ce25602..e9519d104278 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel; +using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Graphics; @@ -60,23 +61,6 @@ await AttachAndRun(border, (handler) => await AssertColorAtPoint(border, expected, typeof(BorderHandler), cornerRadius, cornerRadius); } - [Fact] - [Description("The IsEnabled property of a Border should match with native IsEnabled")] - public async Task VerifyBorderIsEnabledProperty() - { - var border = new Border(); - border.IsEnabled = true; - var expectedValue = border.IsEnabled; - - var handler = await CreateHandlerAsync(border); - var nativeView = GetNativeBorder(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } - ContentPanel GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs index f324c47de4c0..dd5a7109d101 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -5,6 +5,8 @@ using Microsoft.Maui.Handlers; using Xunit; using System.ComponentModel; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -36,7 +38,7 @@ public async Task BoxViewIsEnabled() var nativeView = GetNativeBoxView(handler); await InvokeOnMainThreadAsync(() => { - var isEnabled = nativeView.Enabled; + var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index fd22ef8b01cc..b2876d702b4b 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -22,7 +22,7 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; - + [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() { @@ -92,10 +92,10 @@ public async Task ButtonCornerRadius() var handler = await CreateHandlerAsync(button); var nativeView = GetPlatformButton(handler); - await InvokeOnMainThreadAsync( () => + await InvokeOnMainThreadAsync(() => { var platformCornerRadius = nativeView.Layer.CornerRadius; - Assert.Equal(expectedValue, platformCornerRadius); + Assert.Equal(expectedValue, platformCornerRadius); }); } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs index dd8faaa342a8..ef9eaf43546a 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs @@ -22,5 +22,21 @@ Task GetPlatformOpacity(CheckBoxHandler CheckBoxHandler) return nativeView.Alpha; }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ 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 e291d1855621..184bcff334f0 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs @@ -3,6 +3,7 @@ using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.UI.Xaml.Controls; +using Xunit; namespace Microsoft.Maui.DeviceTests { @@ -19,5 +20,21 @@ Task GetPlatformOpacity(CheckBoxHandler checkBoxHandler) return (float)nativeView.Opacity; }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new Microsoft.Maui.Controls.CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.IsEnabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs index 879dcfbab6e8..a329c87de577 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs @@ -21,5 +21,21 @@ Task GetPlatformOpacity(CheckBoxHandler checkBoxHandler) return (float)nativeView.Alpha; }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs index cadf8081f1bb..8e62d81c37ed 100644 --- a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs @@ -8,7 +8,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index 2544f7dc2f02..ba26b1f57b89 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -1,4 +1,6 @@ -using Microsoft.Maui.Handlers; +using Microsoft.Maui.Handlers; +using System.ComponentModel; +using System.Threading.Tasks; using Xunit; using System.ComponentModel; using System.Threading.Tasks; @@ -43,7 +45,7 @@ public async Task RadioButtonCornerRadius() await InvokeOnMainThreadAsync(() => { var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expected, cornerRadius); + Assert.Equal(expectedValue, cornerRadius); }); } @@ -61,7 +63,7 @@ public async Task VerifyRadioButtonIsEnabledProperty() var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { - var isEnabled = nativeView.Enabled; + var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs index 7542558cf8bd..e0469603db6d 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs @@ -1,8 +1,11 @@ #nullable enable +using System.ComponentModel; using System.Threading.Tasks; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Microsoft.UI.Xaml.Controls; +using Xunit; namespace Microsoft.Maui.DeviceTests { @@ -52,5 +55,24 @@ Task GetPlatformOpacity(SearchBarHandler searchBarHandler) return (float)nativeView.Opacity; }); } + + [Fact] + [Description("The IsEnabled of a SearchBar should match with native IsEnabled")] + public async Task VerifySearchBarIsEnabledProperty() + { + var searchBar = new SearchBar + { + IsEnabled = false + }; + var expectedValue = searchBar.IsEnabled; + + var handler = await CreateHandlerAsync(searchBar); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.IsEnabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } From c684defc44fedbd1e9c631dca028cbd4bffc5946 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Fri, 28 Feb 2025 13:23:10 +0530 Subject: [PATCH 07/30] Update RadioButtonTests.Windows.cs --- .../Elements/RadioButton/RadioButtonTests.Windows.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index ba26b1f57b89..d563c361fa7b 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -44,9 +44,15 @@ public async Task RadioButtonCornerRadius() var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { - var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expectedValue, cornerRadius); - }); + var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; + var cornerRadiusTopRight = (float)nativeView.CornerRadius.TopRight; + var cornerRadiusBottomLeft = (float)nativeView.CornerRadius.BottomLeft; + var cornerRadiusBottomRight = (float)nativeView.CornerRadius.BottomRight; + Assert.Equal(expectedValue, cornerRadiusTopLeft); + Assert.Equal(expectedValue, cornerRadiusTopRight); + Assert.Equal(expectedValue, cornerRadiusBottomLeft); + Assert.Equal(expectedValue, cornerRadiusBottomRight); + }); } [Fact] From 34937aa42843ce457b47d5f5f678d656cf3ea8e0 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:05:04 +0530 Subject: [PATCH 08/30] Update CheckBoxTests.iOS.cs --- .../tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs index a329c87de577..5b7f05d9ac74 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Microsoft.Maui.Graphics; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; From fc5082009623efed4f3c7340983cf1f9adf599a7 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:14:53 +0530 Subject: [PATCH 09/30] removed unwanted namespace --- .../tests/DeviceTests/Elements/Border/BorderTests.Windows.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index e9519d104278..82b35e999e42 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -1,5 +1,4 @@ -using System.ComponentModel; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Graphics; From cc34dd7302e35ccc62250d0b6d90a1e564b2fec4 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:01:07 +0530 Subject: [PATCH 10/30] Update CheckBoxTests.cs --- .../Elements/CheckBox/CheckBoxTests.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs index 72e1f172c9d3..be8021a5bc6c 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs @@ -62,21 +62,5 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } - - [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] - public async Task CheckBoxIsEnabled() - { - var checkBox = new CheckBox(); - checkBox.IsEnabled = false; - var expectedValue = checkBox.IsEnabled; - - var handler = await CreateHandlerAsync(checkBox); - var nativeView = GetNativeCheckBox(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } } } \ No newline at end of file From 2bb015b0ac5a809758cdaaba97208aec84951df4 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:07:03 +0530 Subject: [PATCH 11/30] Update SwipeViewTests.Android.cs --- .../DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs index 4f266e97f7c7..df0f61347f6d 100644 --- a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs @@ -98,7 +98,8 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - + + [Fact] [Description("The IsEnabled of a SwipeView should match with native IsEnabled")] public async Task VerifySwipeViewIsEnabledProperty() { From 4fcd7938d3ca4761903432a7d4d9428783bdaed5 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:12:30 +0530 Subject: [PATCH 12/30] Update BoxViewTests.Android.cs --- .../Elements/BoxView/BoxViewTests.Android.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 8bd82fbc8132..7f0480dc64df 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -23,20 +23,7 @@ Task GetPlatformOpacity(ShapeViewHandler handler) return nativeView.Alpha; }); } - - Task GetPlatformCornerRadius(BoxViewHandler boxViewHandler) - { - return InvokeOnMainThreadAsync(() => - { - var platformView = GetNativeBoxView(boxViewHandler); - if (platformView.Background is Android.Graphics.Drawables.GradientDrawable gradientDrawable) - { - return (int)gradientDrawable.CornerRadius; - } - return 0; - }); - } - + [Fact] [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] public async Task VerifyBoxViewIsEnabledProperty() From fff5fdfd168e81faa9432175522e162e6d824b87 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Mon, 10 Mar 2025 18:33:35 +0530 Subject: [PATCH 13/30] Resolved build error in windows --- .../Elements/RadioButton/RadioButtonTests.Windows.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index d563c361fa7b..bc0abfedccfb 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -1,8 +1,6 @@ using Microsoft.Maui.Handlers; using System.ComponentModel; -using System.Threading.Tasks; using Xunit; -using System.ComponentModel; using System.Threading.Tasks; using Microsoft.Maui.Controls; @@ -24,6 +22,7 @@ public async Task VerifyRadioButtonOpacityProperty() { Opacity = 0.35f }; + var handler = await CreateHandlerAsync(radioButton); var expectedValue = radioButton.Opacity; var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => @@ -32,8 +31,9 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + + [Fact] + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] public async Task RadioButtonCornerRadius() { var radioButton = new RadioButton(); @@ -54,7 +54,7 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, cornerRadiusBottomRight); }); } - + [Fact] [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] public async Task VerifyRadioButtonIsEnabledProperty() From b28dad90230f163e188580703861e5b9012e999c Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:35:34 +0530 Subject: [PATCH 14/30] Update RadioButtonTests.Windows.cs --- .../RadioButton/RadioButtonTests.Windows.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index bc0abfedccfb..3cff10145acb 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -22,8 +22,9 @@ public async Task VerifyRadioButtonOpacityProperty() { Opacity = 0.35f }; - var handler = await CreateHandlerAsync(radioButton); var expectedValue = radioButton.Opacity; + + var handler = await CreateHandlerAsync(radioButton); var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { @@ -31,20 +32,20 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - + [Fact] - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] - public async Task RadioButtonCornerRadius() - { - var radioButton = new RadioButton(); - radioButton.CornerRadius = 15; - var expectedValue = radioButton.CornerRadius; + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeRadioButton(handler); - await InvokeOnMainThreadAsync(() => - { - var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; var cornerRadiusTopRight = (float)nativeView.CornerRadius.TopRight; var cornerRadiusBottomLeft = (float)nativeView.CornerRadius.BottomLeft; var cornerRadiusBottomRight = (float)nativeView.CornerRadius.BottomRight; @@ -53,10 +54,10 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, cornerRadiusBottomLeft); Assert.Equal(expectedValue, cornerRadiusBottomRight); }); - } - + } + [Fact] - [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] public async Task VerifyRadioButtonIsEnabledProperty() { var radioButton = new RadioButton @@ -71,7 +72,7 @@ await InvokeOnMainThreadAsync(() => { var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); - }); + }); } } } From 705dc30d431ec2e43f7817055c76be179ec49426 Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Mon, 24 Feb 2025 11:30:57 +0530 Subject: [PATCH 15/30] Added the CornerRadius and IsEnabled property for DeviceTest --- .../Elements/BoxView/BoxViewTests.Android.cs | 41 +++++++++++++++++-- .../Elements/BoxView/BoxViewTests.cs | 22 +++++----- .../Elements/BoxView/BoxViewTests.iOS.cs | 22 ++++++++++ .../Elements/Button/ButtonTests.iOS.cs | 25 +++++++++++ .../Elements/CheckBox/CheckBoxTests.cs | 16 ++++++++ .../Elements/RadioButton/RadioButtonTests.cs | 37 +++++++++++++++++ 6 files changed, 149 insertions(+), 14 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 380112c44db0..8c80aae33558 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -1,12 +1,14 @@ using System; using System.ComponentModel; using System.Threading.Tasks; -using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; +using System.ComponentModel; using Xunit; - +using Microsoft.Maui.Controls; +using System.Diagnostics; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests @@ -96,5 +98,38 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation); Assert.Equal(expected, platformRotation); } - } + + Task GetPlatformCornerRadius(BoxViewHandler boxViewHandler) + { + return InvokeOnMainThreadAsync(() => + { + var platformView = GetNativeBoxView(boxViewHandler); + if (platformView.Background is Android.Graphics.Drawables.GradientDrawable gradientDrawable) + { + return (int)gradientDrawable.CornerRadius; + } + return 0; + }); + } + + [Fact] + [Description("The CornerRadius of a BoxView should match with native CornerRadius")] + public async Task BoxViewCornerRadius() + { + var boxView = new BoxView + { + Color = Colors.Red, + CornerRadius = 15 + }; + var expectedValue = boxView.CornerRadius; + + var handler = await CreateHandlerAsync(boxView); + + await InvokeOnMainThreadAsync(async () => + { + var platformCornerRadius = await GetPlatformCornerRadius(handler); + Assert.Equal(expectedValue, platformCornerRadius); + }); + } + } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index e6a20ffb1bcb..03ad3b468991 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -6,7 +6,8 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; - +using System.ComponentModel; +using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -32,19 +33,18 @@ public async Task BoxViewInitializesCorrectly(uint color) } [Fact] - [Description("The BackgroundColor of a BoxView should match with native background color")] - public async Task BoxViewBackgroundColorConsistent() + [Description("The Background of a Button should match with native Background")] + public async Task BoxViewBackground() { - var expected = Colors.AliceBlue; - - var boxView = new BoxView() + var boxView = new BoxView { - BackgroundColor = expected, - HeightRequest = 100, - WidthRequest = 200 + HeightRequest = 100, + WidthRequest = 200, + Background = Brush.Red }; - - await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); + var expected = (boxView.Background as SolidColorBrush)?.Color; + + await ValidateHasColor(boxView, expected, typeof(BoxViewHandler)); } [Fact] diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs index 67c5fbc701a5..068fbb5523f0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -2,11 +2,13 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -55,5 +57,25 @@ await AttachAndRun(boxView, async handler => Assert.NotNull(graphicsView); }); } + + [Fact] + [Description("The Cornerradius of a Button should match with native CornerRadius")] + public async Task BoxViewCornerRadius() + { + var boxView = new BoxView + { + HeightRequest = 100, + WidthRequest = 200, + CornerRadius = new CornerRadius(15) + }; + var expected = boxView.CornerRadius; + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + var cornerRadius = (float)nativeView.Layer.CornerRadius; + await InvokeOnMainThreadAsync( () => + { + Assert.Equal(expected, cornerRadius); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index 61e7b3bbfaba..56956d86520f 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -6,6 +6,7 @@ using Microsoft.Maui.Handlers; using UIKit; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -22,6 +23,11 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; + Task GetPlatformCornerRadius(ButtonHandler buttonHandler) + { + return InvokeOnMainThreadAsync(() => (int)GetPlatformButton(buttonHandler).Layer.CornerRadius); + } + [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() { @@ -78,5 +84,24 @@ await InvokeOnMainThreadAsync(async () => Assert.True(button.Width < gridWidth, $"Button shouldn't occupy entire layout width. Expected: {gridWidth}<, was {button.Width}"); Assert.True(button.Height < gridHeight, $"Button shouldn't occupy entire layout height. Expected: {gridHeight}<, was {button.Height}"); } + + [Fact] + [Description("The Cornerradius of a Button should match with native CornerRadius")] + public async Task ButtonCornerRadius() + { + var button = new Button + { + CornerRadius = 15, + }; + var expectedValue = button.CornerRadius; + + var handler = await CreateHandlerAsync(button); + + await InvokeOnMainThreadAsync( async () => + { + var platformCornerRadius = await GetPlatformCornerRadius(handler); + Assert.Equal(expectedValue, platformCornerRadius); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs index be8021a5bc6c..72e1f172c9d3 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs @@ -62,5 +62,21 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index 00631e998766..4b41439496bf 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -53,6 +53,43 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, valuesSecond.PlatformViewValue); }); } + + [Fact] + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadius = (float)nativeView.CornerRadius.TopLeft; + Assert.Equal(expected, cornerRadius); + }); + } + + [Fact] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + public async Task RadioButtonIsEnabled() + { + var radioButton = new RadioButton + { + IsEnabled = false + } + var expectedValue = radioButton.IsEnabled; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + #endif } } \ No newline at end of file From bdf9b75cdfb84711ee7073c2614113e835d60d9f Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Tue, 25 Feb 2025 10:30:01 +0530 Subject: [PATCH 16/30] IsEnabled property for Device tests --- .../Elements/Border/BorderTests.cs | 20 ++++++++++ .../Elements/BoxView/BoxViewTests.Android.cs | 20 ++++++++++ .../Elements/BoxView/BoxViewTests.Windows.cs | 19 +++++++++ .../Elements/BoxView/BoxViewTests.iOS.cs | 20 ---------- .../Elements/Editor/EditorTests.Android.cs | 21 ++++++++++ .../DeviceTests/Elements/Entry/EntryTests.cs | 1 + .../Elements/Label/LabelTests.Android.cs | 21 ++++++++++ .../RadioButton/RadioButtonTests.Windows.cs | 39 +++++++++++++++++-- .../Elements/RadioButton/RadioButtonTests.cs | 38 +----------------- .../SearchBar/SearchBarTests.Android.cs | 23 +++++++++++ .../SwipeView/SwipeViewTests.Android.cs | 18 +++++++++ 11 files changed, 180 insertions(+), 60 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index 1c981f97c74b..eda588a59408 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -9,6 +9,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -313,5 +314,24 @@ public async Task BorderAndStrokeIsCorrectSize() Assert.Equal(180, redBlob.Width, 2d); Assert.Equal(80, redBlob.Height, 2d); } + +#if WINDOWS + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBorderIsEnabledProperty() + { + var border = new Border(); + border.IsEnabled = true; + var expectedValue = border.IsEnabled; + + var handler = await CreateHandlerAsync(border); + var nativeView = GetNativeBorder(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } +#endif } } diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 8c80aae33558..59c7e3d8c366 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -9,6 +9,7 @@ using Xunit; using Microsoft.Maui.Controls; using System.Diagnostics; +using Android.Graphics.Drawables; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests @@ -131,5 +132,24 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, platformCornerRadius); }); } + + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBoxViewIsEnabledProperty() + { + var boxView = new BoxView + { + IsEnabled = false + }; + var expectedValue = boxView.IsEnabled; + + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ 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 index 994e01829fd3..1a6a0ad5627e 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -19,5 +19,24 @@ Task GetPlatformOpacity(ShapeViewHandler handler) return (float)nativeView.Opacity; }); } + + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task BoxViewIsEnabled() + { + var boxView = new BoxView + { + IsEnabled = false + }; + var expectedValue = boxView.IsEnabled; + + var handler = await CreateHandlerAsync(boxView); + var nativeView = GetNativeBoxView(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ 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 index 068fbb5523f0..03b82402a1b0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -57,25 +57,5 @@ await AttachAndRun(boxView, async handler => Assert.NotNull(graphicsView); }); } - - [Fact] - [Description("The Cornerradius of a Button should match with native CornerRadius")] - public async Task BoxViewCornerRadius() - { - var boxView = new BoxView - { - HeightRequest = 100, - WidthRequest = 200, - CornerRadius = new CornerRadius(15) - }; - var expected = boxView.CornerRadius; - var handler = await CreateHandlerAsync(boxView); - var nativeView = GetNativeBoxView(handler); - var cornerRadius = (float)nativeView.Layer.CornerRadius; - await InvokeOnMainThreadAsync( () => - { - Assert.Equal(expected, cornerRadius); - }); - } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs index 375544dbd9b1..ab6128cd31ca 100644 --- a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs @@ -4,6 +4,7 @@ using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -141,5 +142,25 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => PlatformEditor.Rotation); Assert.Equal(expected, platformRotation); } + + [Fact] + [Description("The IsEnabled property of a Editor should match with native IsEnabled")] + public async Task VerifyEditorIsEnabledProperty() + { + var editor = new Editor + { + IsEnabled = false + }; + var expectedValue = editor.IsEnabled; + + var handler = await CreateHandlerAsync(editor); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs index 8e62d81c37ed..cadf8081f1bb 100644 --- a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs @@ -8,6 +8,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs index ca3b626cbf79..4eaa68253bed 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs @@ -12,6 +12,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -162,6 +163,26 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => platformLabel.Rotation); Assert.Equal(expected, platformRotation); } + + [Fact] + [Description("The IsEnabled property of a Label should match with native IsEnabled")] + public async Task VerifyLabelIsEnabledProperty() + { + var label = new Label + { + IsEnabled = false + }; + var expectedValue = label.IsEnabled; + + var handler = await CreateHandlerAsync(label); + var nativeView = GetPlatformLabel(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + TextView GetPlatformLabel(LabelHandler labelHandler) => labelHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index 3cc783bb4286..2544f7dc2f02 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -23,14 +23,47 @@ public async Task VerifyRadioButtonOpacityProperty() Opacity = 0.35f }; var expectedValue = radioButton.Opacity; - - var handler = await CreateHandlerAsync(radioButton); var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => - { + { var nativeOpacityValue = (float)nativeView.Opacity; Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadius = (float)nativeView.CornerRadius.TopLeft; + Assert.Equal(expected, cornerRadius); + }); + } + + [Fact] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + public async Task VerifyRadioButtonIsEnabledProperty() + { + var radioButton = new RadioButton + { + IsEnabled = false + }; + var expectedValue = radioButton.IsEnabled; + + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index 4b41439496bf..c2394c0c92c5 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -4,6 +4,7 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -53,43 +54,6 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, valuesSecond.PlatformViewValue); }); } - - [Fact] - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] - public async Task RadioButtonCornerRadius() - { - var radioButton = new RadioButton(); - radioButton.CornerRadius = 15; - var expectedValue = radioButton.CornerRadius; - - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeRadioButton(handler); - await InvokeOnMainThreadAsync(() => - { - var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expected, cornerRadius); - }); - } - - [Fact] - [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] - public async Task RadioButtonIsEnabled() - { - var radioButton = new RadioButton - { - IsEnabled = false - } - var expectedValue = radioButton.IsEnabled; - - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeCheckBox(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } - #endif } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs index c290f9bd76f7..1f03d187ce4e 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs @@ -7,6 +7,9 @@ using Microsoft.Maui.Platform; using Xunit; using SearchView = AndroidX.AppCompat.Widget.SearchView; +using System.ComponentModel; +using Xunit; +using Microsoft.Maui.Controls; namespace Microsoft.Maui.DeviceTests { @@ -116,5 +119,25 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => platformSearchBar.Rotation); Assert.Equal(expected, platformRotation); } + + [Fact] + [Description("The IsEnabled of a SearchBar should match with native IsEnabled")] + public async Task VerifySearchBarIsEnabledProperty() + { + var searchBar = new SearchBar + { + IsEnabled = false + }; + var expectedValue = searchBar.IsEnabled; + + var handler = await CreateHandlerAsync(searchBar); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs index f0a4a635bc78..3699988c1263 100644 --- a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs @@ -170,5 +170,23 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } + + [Description("The IsEnabled of a SwipeView should match with native IsEnabled")] + public async Task VerifySwipeViewIsEnabledProperty() + { + var swipeView = new SwipeView + { + IsEnabled = false + }; + var expectedValue = swipeView.IsEnabled; + + var handler = await CreateHandlerAsync(swipeView); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file From ca9ef6b8d091c7a1a07526cce6ed3b1c44200b96 Mon Sep 17 00:00:00 2001 From: nivetha-nagalingam Date: Tue, 25 Feb 2025 15:09:14 +0530 Subject: [PATCH 17/30] Addressed the feedbacks --- .../Elements/Border/BorderTests.Windows.cs | 17 +++++++++++++++++ .../Elements/Border/BorderTests.cs | 19 ------------------- .../Elements/BoxView/BoxViewTests.Android.cs | 2 -- .../Elements/BoxView/BoxViewTests.Windows.cs | 2 ++ .../Elements/BoxView/BoxViewTests.iOS.cs | 2 -- .../Elements/Button/ButtonTests.iOS.cs | 11 +++-------- .../Elements/RadioButton/RadioButtonTests.cs | 1 - 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index 82b35e999e42..8666300ddca4 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -60,6 +60,23 @@ await AttachAndRun(border, (handler) => await AssertColorAtPoint(border, expected, typeof(BorderHandler), cornerRadius, cornerRadius); } + [Fact] + [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + public async Task VerifyBorderIsEnabledProperty() + { + var border = new Border(); + border.IsEnabled = true; + var expectedValue = border.IsEnabled; + + var handler = await CreateHandlerAsync(border); + var nativeView = GetNativeBorder(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + ContentPanel GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index eda588a59408..1853dceacedb 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -314,24 +314,5 @@ public async Task BorderAndStrokeIsCorrectSize() Assert.Equal(180, redBlob.Width, 2d); Assert.Equal(80, redBlob.Height, 2d); } - -#if WINDOWS - [Fact] - [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] - public async Task VerifyBorderIsEnabledProperty() - { - var border = new Border(); - border.IsEnabled = true; - var expectedValue = border.IsEnabled; - - var handler = await CreateHandlerAsync(border); - var nativeView = GetNativeBorder(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } -#endif } } diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index 59c7e3d8c366..f47d814d662f 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -8,8 +8,6 @@ using System.ComponentModel; using Xunit; using Microsoft.Maui.Controls; -using System.Diagnostics; -using Android.Graphics.Drawables; namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs index 1a6a0ad5627e..f324c47de4c0 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -3,6 +3,8 @@ using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Graphics.Win2D; using Microsoft.Maui.Handlers; +using Xunit; +using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs index 03b82402a1b0..67c5fbc701a5 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.iOS.cs @@ -2,13 +2,11 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.Maui.Controls; -using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics.Platform; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index 56956d86520f..a5dfb2058a07 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -22,11 +22,6 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; - - Task GetPlatformCornerRadius(ButtonHandler buttonHandler) - { - return InvokeOnMainThreadAsync(() => (int)GetPlatformButton(buttonHandler).Layer.CornerRadius); - } [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() @@ -96,10 +91,10 @@ public async Task ButtonCornerRadius() var expectedValue = button.CornerRadius; var handler = await CreateHandlerAsync(button); - - await InvokeOnMainThreadAsync( async () => + var nativeView = GetPlatformButton(handler); + await InvokeOnMainThreadAsync( () => { - var platformCornerRadius = await GetPlatformCornerRadius(handler); + var platformCornerRadius = nativeView.Layer.CornerRadius; Assert.Equal(expectedValue, platformCornerRadius); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs index c2394c0c92c5..00631e998766 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.cs @@ -4,7 +4,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { From 9dba64fa8983295153da53122927debedc4113c3 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:10:21 +0530 Subject: [PATCH 18/30] Update BoxViewTests.cs --- .../Elements/BoxView/BoxViewTests.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index 03ad3b468991..d01d41bc6c32 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -6,7 +6,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests @@ -32,6 +31,22 @@ public async Task BoxViewInitializesCorrectly(uint color) await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); } + [Fact] + [Description("The BackgroundColor of a BoxView should match with native background color")] + public async Task BoxViewBackgroundColorConsistent() + { + var expected = Colors.AliceBlue; + + var boxView = new BoxView() + { + BackgroundColor = expected, + HeightRequest = 100, + WidthRequest = 200 + }; + + await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler)); + } + [Fact] [Description("The Background of a Button should match with native Background")] public async Task BoxViewBackground() From 921448b3bfe280b3a703f58e40fb13dfc6370e0a Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Thu, 27 Feb 2025 19:22:51 +0530 Subject: [PATCH 19/30] modified code changes --- .../DeviceTests/Elements/Border/BorderTests.Windows.cs | 2 +- .../tests/DeviceTests/Elements/Border/BorderTests.cs | 1 - .../DeviceTests/Elements/BoxView/BoxViewTests.Android.cs | 1 + .../tests/DeviceTests/Elements/BoxView/BoxViewTests.cs | 6 +++--- .../tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index 8666300ddca4..c0799ce25602 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -61,7 +61,7 @@ await AttachAndRun(border, (handler) => } [Fact] - [Description("The IsEnabled property of a BoxView should match with native IsEnabled")] + [Description("The IsEnabled property of a Border should match with native IsEnabled")] public async Task VerifyBorderIsEnabledProperty() { var border = new Border(); diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs index 1853dceacedb..1c981f97c74b 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.cs @@ -9,7 +9,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index f47d814d662f..f49c97e50b27 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -8,6 +8,7 @@ using System.ComponentModel; using Xunit; using Microsoft.Maui.Controls; + namespace Microsoft.Maui.DeviceTests { public partial class BoxViewTests diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs index d01d41bc6c32..a38a76ce308e 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs @@ -4,9 +4,9 @@ using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; +using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -48,8 +48,8 @@ public async Task BoxViewBackgroundColorConsistent() } [Fact] - [Description("The Background of a Button should match with native Background")] - public async Task BoxViewBackground() + [Description("The Background of a BoxView should match with native Background")] + public async Task BoxViewBackgroundConsistent() { var boxView = new BoxView { diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index a5dfb2058a07..fd22ef8b01cc 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -1,12 +1,12 @@ #nullable enable using System; +using System.ComponentModel; using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using UIKit; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -81,7 +81,7 @@ await InvokeOnMainThreadAsync(async () => } [Fact] - [Description("The Cornerradius of a Button should match with native CornerRadius")] + [Description("The CornerRadius of a Button should match with native CornerRadius")] public async Task ButtonCornerRadius() { var button = new Button From f8d13adeaafc92b8ae4aee568f8c2a9cc0cfa797 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Fri, 28 Feb 2025 13:07:17 +0530 Subject: [PATCH 20/30] resolved windows build error --- .../Elements/Border/BorderTests.Windows.cs | 20 ++--------------- .../Elements/BoxView/BoxViewTests.Windows.cs | 4 +++- .../Elements/Button/ButtonTests.iOS.cs | 6 ++--- .../CheckBox/CheckBoxTests.Android.cs | 17 ++++++++++++++ .../CheckBox/CheckBoxTests.Windows.cs | 17 ++++++++++++++ .../Elements/CheckBox/CheckBoxTests.iOS.cs | 16 ++++++++++++++ .../DeviceTests/Elements/Entry/EntryTests.cs | 1 - .../RadioButton/RadioButtonTests.Windows.cs | 8 ++++--- .../SearchBar/SearchBarTests.Windows.cs | 22 +++++++++++++++++++ 9 files changed, 85 insertions(+), 26 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index c0799ce25602..e9519d104278 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.ComponentModel; +using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Graphics; @@ -60,23 +61,6 @@ await AttachAndRun(border, (handler) => await AssertColorAtPoint(border, expected, typeof(BorderHandler), cornerRadius, cornerRadius); } - [Fact] - [Description("The IsEnabled property of a Border should match with native IsEnabled")] - public async Task VerifyBorderIsEnabledProperty() - { - var border = new Border(); - border.IsEnabled = true; - var expectedValue = border.IsEnabled; - - var handler = await CreateHandlerAsync(border); - var nativeView = GetNativeBorder(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } - ContentPanel GetNativeBorder(BorderHandler borderHandler) => borderHandler.PlatformView; diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs index f324c47de4c0..dd5a7109d101 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Windows.cs @@ -5,6 +5,8 @@ using Microsoft.Maui.Handlers; using Xunit; using System.ComponentModel; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Handlers; namespace Microsoft.Maui.DeviceTests { @@ -36,7 +38,7 @@ public async Task BoxViewIsEnabled() var nativeView = GetNativeBoxView(handler); await InvokeOnMainThreadAsync(() => { - var isEnabled = nativeView.Enabled; + var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs index fd22ef8b01cc..b2876d702b4b 100644 --- a/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs @@ -22,7 +22,7 @@ Task GetPlatformText(ButtonHandler buttonHandler) UILineBreakMode GetPlatformLineBreakMode(ButtonHandler buttonHandler) => GetPlatformButton(buttonHandler).TitleLabel.LineBreakMode; - + [Fact("Clicked works after GC")] public async Task ClickedWorksAfterGC() { @@ -92,10 +92,10 @@ public async Task ButtonCornerRadius() var handler = await CreateHandlerAsync(button); var nativeView = GetPlatformButton(handler); - await InvokeOnMainThreadAsync( () => + await InvokeOnMainThreadAsync(() => { var platformCornerRadius = nativeView.Layer.CornerRadius; - Assert.Equal(expectedValue, platformCornerRadius); + Assert.Equal(expectedValue, platformCornerRadius); }); } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs index 35346b08777e..03164bff8aa7 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs @@ -98,4 +98,21 @@ public async Task RotationConsistent() Assert.Equal(expected, platformRotation); } } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } + } } \ 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 e291d1855621..184bcff334f0 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Windows.cs @@ -3,6 +3,7 @@ using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.UI.Xaml.Controls; +using Xunit; namespace Microsoft.Maui.DeviceTests { @@ -19,5 +20,21 @@ Task GetPlatformOpacity(CheckBoxHandler checkBoxHandler) return (float)nativeView.Opacity; }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new Microsoft.Maui.Controls.CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.IsEnabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs index 879dcfbab6e8..a329c87de577 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs @@ -21,5 +21,21 @@ Task GetPlatformOpacity(CheckBoxHandler checkBoxHandler) return (float)nativeView.Alpha; }); } + + [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] + public async Task CheckBoxIsEnabled() + { + var checkBox = new CheckBox(); + checkBox.IsEnabled = false; + var expectedValue = checkBox.IsEnabled; + + var handler = await CreateHandlerAsync(checkBox); + var nativeView = GetNativeCheckBox(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.Enabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } \ No newline at end of file diff --git a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs index cadf8081f1bb..8e62d81c37ed 100644 --- a/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Entry/EntryTests.cs @@ -8,7 +8,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Hosting; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index 2544f7dc2f02..ba26b1f57b89 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -1,4 +1,6 @@ -using Microsoft.Maui.Handlers; +using Microsoft.Maui.Handlers; +using System.ComponentModel; +using System.Threading.Tasks; using Xunit; using System.ComponentModel; using System.Threading.Tasks; @@ -43,7 +45,7 @@ public async Task RadioButtonCornerRadius() await InvokeOnMainThreadAsync(() => { var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expected, cornerRadius); + Assert.Equal(expectedValue, cornerRadius); }); } @@ -61,7 +63,7 @@ public async Task VerifyRadioButtonIsEnabledProperty() var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { - var isEnabled = nativeView.Enabled; + var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); }); } diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs index 7542558cf8bd..e0469603db6d 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Windows.cs @@ -1,8 +1,11 @@ #nullable enable +using System.ComponentModel; using System.Threading.Tasks; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Microsoft.UI.Xaml.Controls; +using Xunit; namespace Microsoft.Maui.DeviceTests { @@ -52,5 +55,24 @@ Task GetPlatformOpacity(SearchBarHandler searchBarHandler) return (float)nativeView.Opacity; }); } + + [Fact] + [Description("The IsEnabled of a SearchBar should match with native IsEnabled")] + public async Task VerifySearchBarIsEnabledProperty() + { + var searchBar = new SearchBar + { + IsEnabled = false + }; + var expectedValue = searchBar.IsEnabled; + + var handler = await CreateHandlerAsync(searchBar); + var nativeView = GetPlatformControl(handler); + await InvokeOnMainThreadAsync(() => + { + var isEnabled = nativeView.IsEnabled; + Assert.Equal(expectedValue, isEnabled); + }); + } } } From 4f6c584f6b956ca2142395af67253591202ecbeb Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Fri, 28 Feb 2025 13:23:10 +0530 Subject: [PATCH 21/30] Update RadioButtonTests.Windows.cs --- .../Elements/RadioButton/RadioButtonTests.Windows.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index ba26b1f57b89..d563c361fa7b 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -44,9 +44,15 @@ public async Task RadioButtonCornerRadius() var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { - var cornerRadius = (float)nativeView.CornerRadius.TopLeft; - Assert.Equal(expectedValue, cornerRadius); - }); + var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; + var cornerRadiusTopRight = (float)nativeView.CornerRadius.TopRight; + var cornerRadiusBottomLeft = (float)nativeView.CornerRadius.BottomLeft; + var cornerRadiusBottomRight = (float)nativeView.CornerRadius.BottomRight; + Assert.Equal(expectedValue, cornerRadiusTopLeft); + Assert.Equal(expectedValue, cornerRadiusTopRight); + Assert.Equal(expectedValue, cornerRadiusBottomLeft); + Assert.Equal(expectedValue, cornerRadiusBottomRight); + }); } [Fact] From 1ee071a7141636f4e39806216961937e936f9e94 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:05:04 +0530 Subject: [PATCH 22/30] Update CheckBoxTests.iOS.cs --- .../tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs index a329c87de577..5b7f05d9ac74 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.iOS.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Microsoft.Maui.Graphics; +using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; From 6cb730a05c59f4c4588e461ddc687fd88f5e9720 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:14:53 +0530 Subject: [PATCH 23/30] removed unwanted namespace --- .../tests/DeviceTests/Elements/Border/BorderTests.Windows.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs index e9519d104278..82b35e999e42 100644 --- a/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Border/BorderTests.Windows.cs @@ -1,5 +1,4 @@ -using System.ComponentModel; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Shapes; using Microsoft.Maui.Graphics; From 1a30db7d30c8128b896f51f934a3b2074ee8a42b Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:01:07 +0530 Subject: [PATCH 24/30] Update CheckBoxTests.cs --- .../Elements/CheckBox/CheckBoxTests.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs index 72e1f172c9d3..be8021a5bc6c 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.cs @@ -62,21 +62,5 @@ await InvokeOnMainThreadAsync(async () => Assert.Equal(expectedValue, nativeOpacityValue); }); } - - [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] - public async Task CheckBoxIsEnabled() - { - var checkBox = new CheckBox(); - checkBox.IsEnabled = false; - var expectedValue = checkBox.IsEnabled; - - var handler = await CreateHandlerAsync(checkBox); - var nativeView = GetNativeCheckBox(handler); - await InvokeOnMainThreadAsync(() => - { - var isEnabled = nativeView.Enabled; - Assert.Equal(expectedValue, isEnabled); - }); - } } } \ No newline at end of file From d5ca4b1b8c2723f24d81488ec9a7d667d3924554 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:07:03 +0530 Subject: [PATCH 25/30] Update SwipeViewTests.Android.cs --- .../DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs index 3699988c1263..7c667e992d99 100644 --- a/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SwipeView/SwipeViewTests.Android.cs @@ -170,7 +170,8 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - + + [Fact] [Description("The IsEnabled of a SwipeView should match with native IsEnabled")] public async Task VerifySwipeViewIsEnabledProperty() { From 83f89b1b61b9d5a2764ce68c7a9bec402123980a Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal Date: Mon, 10 Mar 2025 18:33:35 +0530 Subject: [PATCH 26/30] Resolved build error in windows --- .../Elements/RadioButton/RadioButtonTests.Windows.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index d563c361fa7b..bc0abfedccfb 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -1,8 +1,6 @@ using Microsoft.Maui.Handlers; using System.ComponentModel; -using System.Threading.Tasks; using Xunit; -using System.ComponentModel; using System.Threading.Tasks; using Microsoft.Maui.Controls; @@ -24,6 +22,7 @@ public async Task VerifyRadioButtonOpacityProperty() { Opacity = 0.35f }; + var handler = await CreateHandlerAsync(radioButton); var expectedValue = radioButton.Opacity; var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => @@ -32,8 +31,9 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + + [Fact] + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] public async Task RadioButtonCornerRadius() { var radioButton = new RadioButton(); @@ -54,7 +54,7 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, cornerRadiusBottomRight); }); } - + [Fact] [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] public async Task VerifyRadioButtonIsEnabledProperty() From 2d2f7c95b0626bdf3e3653baa52ba03d52250192 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:35:34 +0530 Subject: [PATCH 27/30] Update RadioButtonTests.Windows.cs --- .../RadioButton/RadioButtonTests.Windows.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs index bc0abfedccfb..3cff10145acb 100644 --- a/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/RadioButton/RadioButtonTests.Windows.cs @@ -22,8 +22,9 @@ public async Task VerifyRadioButtonOpacityProperty() { Opacity = 0.35f }; - var handler = await CreateHandlerAsync(radioButton); var expectedValue = radioButton.Opacity; + + var handler = await CreateHandlerAsync(radioButton); var nativeView = GetNativeRadioButton(handler); await InvokeOnMainThreadAsync(() => { @@ -31,20 +32,20 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, nativeOpacityValue); }); } - + [Fact] - [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] - public async Task RadioButtonCornerRadius() - { - var radioButton = new RadioButton(); - radioButton.CornerRadius = 15; - var expectedValue = radioButton.CornerRadius; + [Description("The CornerRadius of a RadioButton should match with native CornerRadius")] + public async Task RadioButtonCornerRadius() + { + var radioButton = new RadioButton(); + radioButton.CornerRadius = 15; + var expectedValue = radioButton.CornerRadius; - var handler = await CreateHandlerAsync(radioButton); - var nativeView = GetNativeRadioButton(handler); - await InvokeOnMainThreadAsync(() => - { - var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; + var handler = await CreateHandlerAsync(radioButton); + var nativeView = GetNativeRadioButton(handler); + await InvokeOnMainThreadAsync(() => + { + var cornerRadiusTopLeft = (float)nativeView.CornerRadius.TopLeft; var cornerRadiusTopRight = (float)nativeView.CornerRadius.TopRight; var cornerRadiusBottomLeft = (float)nativeView.CornerRadius.BottomLeft; var cornerRadiusBottomRight = (float)nativeView.CornerRadius.BottomRight; @@ -53,10 +54,10 @@ await InvokeOnMainThreadAsync(() => Assert.Equal(expectedValue, cornerRadiusBottomLeft); Assert.Equal(expectedValue, cornerRadiusBottomRight); }); - } - + } + [Fact] - [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] + [Description("The IsEnabled of a RadioButton should match with native IsEnabled")] public async Task VerifyRadioButtonIsEnabledProperty() { var radioButton = new RadioButton @@ -71,7 +72,7 @@ await InvokeOnMainThreadAsync(() => { var isEnabled = nativeView.IsEnabled; Assert.Equal(expectedValue, isEnabled); - }); + }); } } } From 6539dbc2baa4d2bc8b7241443d60c0281ad06d23 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 21 Mar 2025 20:38:29 +0530 Subject: [PATCH 28/30] Update CheckBoxTests.Android.cs --- .../tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs index 03164bff8aa7..35b297a977ed 100644 --- a/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/CheckBox/CheckBoxTests.Android.cs @@ -97,7 +97,6 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => PlatformCheckBox.Rotation); Assert.Equal(expected, platformRotation); } - } [Fact("The IsEnabled of a CheckBox should match with native IsEnabled")] public async Task CheckBoxIsEnabled() From f2f44aa65ce175dc971b8fad40dc263133956ee0 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 21 Mar 2025 20:46:34 +0530 Subject: [PATCH 29/30] Resolved conflict errors --- .../tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs | 1 - .../tests/DeviceTests/Elements/Editor/EditorTests.Android.cs | 1 - .../tests/DeviceTests/Elements/Label/LabelTests.Android.cs | 3 +-- .../DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs | 3 --- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index f49c97e50b27..b47e52c8b1db 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -5,7 +5,6 @@ using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; -using System.ComponentModel; using Xunit; using Microsoft.Maui.Controls; diff --git a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs index ab6128cd31ca..5a312b3e164f 100644 --- a/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Editor/EditorTests.Android.cs @@ -4,7 +4,6 @@ using Microsoft.Maui.Controls; using Microsoft.Maui.Handlers; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { diff --git a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs index 4eaa68253bed..9f9184f42e87 100644 --- a/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/Label/LabelTests.Android.cs @@ -12,7 +12,6 @@ using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; -using System.ComponentModel; namespace Microsoft.Maui.DeviceTests { @@ -163,7 +162,7 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => platformLabel.Rotation); Assert.Equal(expected, platformRotation); } - + [Fact] [Description("The IsEnabled property of a Label should match with native IsEnabled")] public async Task VerifyLabelIsEnabledProperty() diff --git a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs index 1f03d187ce4e..40bc90bad84d 100644 --- a/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/SearchBar/SearchBarTests.Android.cs @@ -7,9 +7,6 @@ using Microsoft.Maui.Platform; using Xunit; using SearchView = AndroidX.AppCompat.Widget.SearchView; -using System.ComponentModel; -using Xunit; -using Microsoft.Maui.Controls; namespace Microsoft.Maui.DeviceTests { From 9ddf1bbed6447b833d25a5cce690592683c8de88 Mon Sep 17 00:00:00 2001 From: Anandhan Rajagopal <97146406+anandhan-rajagopal@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:01:12 +0530 Subject: [PATCH 30/30] Update BoxViewTests.Android.cs --- .../Elements/BoxView/BoxViewTests.Android.cs | 36 ++----------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs index b47e52c8b1db..11733455f689 100644 --- a/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs +++ b/src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs @@ -1,12 +1,13 @@ using System; using System.ComponentModel; using System.Threading.Tasks; +using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Handlers; using Microsoft.Maui.Graphics; using Microsoft.Maui.Handlers; using Microsoft.Maui.Platform; using Xunit; -using Microsoft.Maui.Controls; + namespace Microsoft.Maui.DeviceTests { @@ -97,39 +98,6 @@ public async Task RotationConsistent() var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation); Assert.Equal(expected, platformRotation); } - - Task GetPlatformCornerRadius(BoxViewHandler boxViewHandler) - { - return InvokeOnMainThreadAsync(() => - { - var platformView = GetNativeBoxView(boxViewHandler); - if (platformView.Background is Android.Graphics.Drawables.GradientDrawable gradientDrawable) - { - return (int)gradientDrawable.CornerRadius; - } - return 0; - }); - } - - [Fact] - [Description("The CornerRadius of a BoxView should match with native CornerRadius")] - public async Task BoxViewCornerRadius() - { - var boxView = new BoxView - { - Color = Colors.Red, - CornerRadius = 15 - }; - var expectedValue = boxView.CornerRadius; - - var handler = await CreateHandlerAsync(boxView); - - await InvokeOnMainThreadAsync(async () => - { - var platformCornerRadius = await GetPlatformCornerRadius(handler); - Assert.Equal(expectedValue, platformCornerRadius); - }); - } [Fact] [Description("The IsEnabled property of a BoxView should match with native IsEnabled")]