Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d46967d
Added the CornerRadius and IsEnabled property for DeviceTest
nivetha-nagalingam Feb 24, 2025
effe652
IsEnabled property for Device tests
nivetha-nagalingam Feb 25, 2025
42fa6a5
Addressed the feedbacks
nivetha-nagalingam Feb 25, 2025
9186eea
Update BoxViewTests.cs
Feb 27, 2025
63658a6
modified code changes
Feb 27, 2025
acb082f
resolved windows build error
Feb 28, 2025
c684def
Update RadioButtonTests.Windows.cs
Feb 28, 2025
34937aa
Update CheckBoxTests.iOS.cs
Feb 28, 2025
fc50820
removed unwanted namespace
Feb 28, 2025
cc34dd7
Update CheckBoxTests.cs
Mar 7, 2025
2bb015b
Update SwipeViewTests.Android.cs
Mar 7, 2025
4fcd793
Update BoxViewTests.Android.cs
Mar 7, 2025
fff5fdf
Resolved build error in windows
Mar 10, 2025
b28dad9
Update RadioButtonTests.Windows.cs
Mar 10, 2025
705dc30
Added the CornerRadius and IsEnabled property for DeviceTest
nivetha-nagalingam Feb 24, 2025
bdf9b75
IsEnabled property for Device tests
nivetha-nagalingam Feb 25, 2025
ca9ef6b
Addressed the feedbacks
nivetha-nagalingam Feb 25, 2025
9dba64f
Update BoxViewTests.cs
Feb 27, 2025
921448b
modified code changes
Feb 27, 2025
f8d13ad
resolved windows build error
Feb 28, 2025
4f6c584
Update RadioButtonTests.Windows.cs
Feb 28, 2025
1ee071a
Update CheckBoxTests.iOS.cs
Feb 28, 2025
6cb730a
removed unwanted namespace
Feb 28, 2025
1a30db7
Update CheckBoxTests.cs
Mar 7, 2025
d5ca4b1
Update SwipeViewTests.Android.cs
Mar 7, 2025
83f89b1
Resolved build error in windows
Mar 10, 2025
2d2f7c9
Update RadioButtonTests.Windows.cs
Mar 10, 2025
6539dbc
Update CheckBoxTests.Android.cs
Mar 21, 2025
f2f44aa
Resolved conflict errors
Mar 21, 2025
f816bb4
Merge branch 'enabled-UnitTest-To-DeviceTest-1' of https://github.com…
Mar 21, 2025
9ddf1bb
Update BoxViewTests.Android.cs
Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
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;


namespace Microsoft.Maui.DeviceTests
{
public partial class BoxViewTests
Expand Down Expand Up @@ -96,5 +98,24 @@ public async Task RotationConsistent()
var platformRotation = await InvokeOnMainThreadAsync(() => platformBoxView.Rotation);
Assert.Equal(expected, platformRotation);
}
}

[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<BoxViewHandler>(boxView);
var nativeView = GetNativeBoxView(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using Microsoft.Maui.Graphics.Platform;
using Microsoft.Maui.Graphics.Win2D;
using Microsoft.Maui.Handlers;
using Xunit;
using System.ComponentModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers;

namespace Microsoft.Maui.DeviceTests
{
Expand All @@ -19,5 +23,24 @@ Task<float> 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<BoxViewHandler>(boxView);
var nativeView = GetNativeBoxView(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.IsEnabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
17 changes: 16 additions & 1 deletion src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Controls.Handlers;
using Microsoft.Maui.Hosting;
using Xunit;


namespace Microsoft.Maui.DeviceTests
{
[Category(TestCategory.BoxView)]
Expand Down Expand Up @@ -47,6 +47,21 @@ public async Task BoxViewBackgroundColorConsistent()
await ValidateHasColor(boxView, expected, typeof(ShapeViewHandler));
}

[Fact]
[Description("The Background of a BoxView should match with native Background")]
public async Task BoxViewBackgroundConsistent()
{
var boxView = new BoxView
{
HeightRequest = 100,
WidthRequest = 200,
Background = Brush.Red
};
var expected = (boxView.Background as SolidColorBrush)?.Color;

await ValidateHasColor(boxView, expected, typeof(BoxViewHandler));
}

[Fact]
[Description("The Opacity property of a BoxView should match with native Opacity")]
public async Task VerifyBoxViewOpacityProperty()
Expand Down
20 changes: 20 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable
using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
Expand Down Expand Up @@ -78,5 +79,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<ButtonHandler>(button);
var nativeView = GetPlatformButton(handler);
await InvokeOnMainThreadAsync(() =>
{
var platformCornerRadius = nativeView.Layer.CornerRadius;
Assert.Equal(expectedValue, platformCornerRadius);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,21 @@ 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()
{
var checkBox = new CheckBox();
checkBox.IsEnabled = false;
var expectedValue = checkBox.IsEnabled;

var handler = await CreateHandlerAsync<CheckBoxHandler>(checkBox);
var nativeView = GetNativeCheckBox(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Handlers;
using Microsoft.UI.Xaml.Controls;
using Xunit;

namespace Microsoft.Maui.DeviceTests
{
Expand All @@ -19,5 +20,21 @@ Task<float> 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<CheckBoxHandler>(checkBox);
var nativeView = GetNativeCheckBox(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.IsEnabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,5 +22,21 @@ Task<float> 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<CheckBoxHandler>(checkBox);
var nativeView = GetNativeCheckBox(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,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<EditorHandler>(editor);
var nativeView = GetPlatformControl(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;

Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,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<LabelHandler>(label);
var nativeView = GetPlatformLabel(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;
Assert.Equal(expectedValue, isEnabled);
});
}

TextView GetPlatformLabel(LabelHandler labelHandler) =>
labelHandler.PlatformView;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Maui.Handlers;
using Xunit;
using Microsoft.Maui.Handlers;
using System.ComponentModel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a merge issue. Appears two times.

C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(5,7): error CS0105: The using directive for 'System.ComponentModel' appeared previously in this namespace [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(6,7): error CS0105: The using directive for 'System.Threading.Tasks' appeared previously in this namespace [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(28,42): error CS0103: The name 'handler' does not exist in the current context [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.19041.0]
C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(5,7): error CS0105: The using directive for 'System.ComponentModel' appeared previously in this namespace [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(6,7): error CS0105: The using directive for 'System.Threading.Tasks' appeared previously in this namespace [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.20348.0]
C:\a\_work\1\s\src\Controls\tests\DeviceTests\Elements\RadioButton\RadioButtonTests.Windows.cs(28,42): error CS0103: The name 'handler' does not exist in the current context [C:\a\_work\1\s\src\Controls\tests\DeviceTests\Controls.DeviceTests.csproj::TargetFramework=net9.0-windows10.0.20348.0]
    6 Error(s)

Could you fix the build errors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsuarezruiz, Resolved the build errors and committed the changes

using Xunit;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;

Expand All @@ -27,10 +27,52 @@ public async Task VerifyRadioButtonOpacityProperty()
var handler = await CreateHandlerAsync<RadioButtonHandler>(radioButton);
var nativeView = GetNativeRadioButton(handler);
await InvokeOnMainThreadAsync(() =>
{
{
var nativeOpacityValue = (float)nativeView.Opacity;
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;

var handler = await CreateHandlerAsync<RadioButtonHandler>(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;
Assert.Equal(expectedValue, cornerRadiusTopLeft);
Assert.Equal(expectedValue, cornerRadiusTopRight);
Assert.Equal(expectedValue, cornerRadiusBottomLeft);
Assert.Equal(expectedValue, cornerRadiusBottomRight);
});
}

[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<RadioButtonHandler>(radioButton);
var nativeView = GetNativeRadioButton(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.IsEnabled;
Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,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<SearchBarHandler>(searchBar);
var nativeView = GetPlatformControl(handler);
await InvokeOnMainThreadAsync(() =>
{
var isEnabled = nativeView.Enabled;

Assert.Equal(expectedValue, isEnabled);
});
}
}
}
Loading