Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/Controls/src/Core/Stepper/Stepper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class Stepper : View, IElementConfiguration<Stepper>, IStepper
{
/// <summary>Bindable property for <see cref="Maximum"/>.</summary>
public static readonly BindableProperty MaximumProperty = BindableProperty.Create(nameof(Maximum), typeof(double), typeof(Stepper), 100.0,
validateValue: (bindable, value) => (double)value > ((Stepper)bindable).Minimum,
validateValue: (bindable, value) => (double)value >= ((Stepper)bindable).Minimum,
coerceValue: (bindable, value) =>
{
var stepper = (Stepper)bindable;
Expand All @@ -22,7 +22,7 @@ public partial class Stepper : View, IElementConfiguration<Stepper>, IStepper

/// <summary>Bindable property for <see cref="Minimum"/>.</summary>
public static readonly BindableProperty MinimumProperty = BindableProperty.Create(nameof(Minimum), typeof(double), typeof(Stepper), 0.0,
validateValue: (bindable, value) => (double)value < ((Stepper)bindable).Maximum,
validateValue: (bindable, value) => (double)value <= ((Stepper)bindable).Maximum,
coerceValue: (bindable, value) =>
{
var stepper = (Stepper)bindable;
Expand Down
52 changes: 52 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue28330.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 28330, "Stepper allows to increment when value equals to maximum", PlatformAffected.All)]
public class Issue28330 : TestContentPage
{
protected override void Init()
{
var layout = new StackLayout { };

Stepper Incrementstepper = new Stepper
{
AutomationId = "Incrementstepper",
HorizontalOptions = LayoutOptions.Center,
Increment = 1,
Minimum = 1,
Maximum = 1,
Value = 1
};

Label Incrementlabel = new Label
{
AutomationId = "Incrementlabel",
HorizontalOptions = LayoutOptions.Center,
FontSize = 32
};
Incrementlabel.SetBinding(Label.TextProperty, new Binding("Value", source: Incrementstepper));

Stepper Decrementstepper = new Stepper
{
AutomationId = "Decrementstepper",
HorizontalOptions = LayoutOptions.Center,
Increment = 1,
Maximum = 1,
Minimum = 1,
Value = 1
};

Label Decrementlabel = new Label
{
AutomationId = "Decrementlabel",
HorizontalOptions = LayoutOptions.Center,
FontSize = 32
};
Decrementlabel.SetBinding(Label.TextProperty, new Binding("Value", source: Decrementstepper));

layout.Children.Add(Incrementstepper);
layout.Children.Add(Incrementlabel);
layout.Children.Add(Decrementstepper);
layout.Children.Add(Decrementlabel);

Content = layout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue28330 : _IssuesUITest
{
public Issue28330(TestDevice device) : base(device)
{
}

public override string Issue => "Stepper allows to increment when value equals to maximum";

[Test]
[Category(UITestCategories.Stepper)]
public void Issue28330StepperIncrementShouldBeDisabled()
{
App.WaitForElement("Incrementlabel");
App.IncreaseStepper("Incrementstepper");
Assert.That(App.FindElement("Incrementlabel").GetText(), Is.EqualTo("1"));
App.DecreaseStepper("Decrementstepper");
Assert.That(App.FindElement("Decrementlabel").GetText(), Is.EqualTo("1"));
}
}
Loading