forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced Stepper to Support Dynamic Increment Mapping (dotnet#24396)
* Fix Stepper doesn't change increment value when being bound to a double in MVVM context (Windows) * shipped file changes updated * shipped file changes included * changes added in unshipped file * platform condition removed * platform condition added in script file * shipped file extra changes removed * extra changes removed in unshipped.txt * empty lines removed * tizen shipped file changes reverted * new test case and snapshot added for android & iOS * WinUI snap added * old changes reverted new changes added * snap added for all platform * Added AppendToMapping pattern * Removed wrong namespace * Renamed class name * Updated testcase screenshot forMac * Update StepperUITests.cs * Revert "Update StepperUITests.cs" This reverts commit 70ff4bc. * Revert "Updated testcase screenshot forMac" This reverts commit 0aadff6. * Updated alignment in test case * Updated MapInterval * Updated test sample * Reverted test images * Revert "Reverted test images" This reverts commit 0ecfc54. * Removed test images * Added test_fails_on_catalyst tag in test sample --------- Co-authored-by: Dhivya-SF4094 <[email protected]>
- Loading branch information
1 parent
92f25df
commit a200973
Showing
5 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace Microsoft.Maui.Controls; | ||
public partial class Stepper | ||
{ | ||
internal static new void RemapForControls() | ||
{ | ||
StepperHandler.Mapper.AppendToMapping(nameof(Stepper.Increment), MapInterval); | ||
} | ||
|
||
internal static void MapInterval(IStepperHandler handler, IStepper stepper) | ||
{ | ||
handler.UpdateValue(nameof(IStepper.Interval)); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.HostApp/Issues/Issue20706.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue20706" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<ContentPage.BindingContext> | ||
<local:ViewModelClass/> | ||
</ContentPage.BindingContext> | ||
<ContentPage.Content> | ||
<VerticalStackLayout> | ||
<Stepper AutomationId="myStepper" | ||
x:Name="stepperValue" | ||
Maximum="1000" | ||
Increment="{Binding Increment}"/> | ||
<Entry AutomationId="entry" | ||
Text="{Binding Value,Source={x:Reference stepperValue}} "/> | ||
<Button AutomationId="incrementButton" | ||
Text="Change Increment Value" | ||
x:Name="button" | ||
Clicked="button_Clicked"/> | ||
</VerticalStackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
51 changes: 51 additions & 0 deletions
51
src/Controls/tests/TestCases.HostApp/Issues/Issue20706.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.ComponentModel; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 20706, "Stepper doesn't change increment value when being bound to a double in MVVM context (Windows)", PlatformAffected.UWP)] | ||
public partial class Issue20706 : ContentPage | ||
{ | ||
public Issue20706() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void button_Clicked(object sender, EventArgs e) | ||
{ | ||
stepperValue.Increment = 10; | ||
} | ||
} | ||
|
||
internal class ViewModelClass : INotifyPropertyChanged | ||
{ | ||
private double _increment; | ||
|
||
public double Increment | ||
{ | ||
get | ||
{ | ||
return _increment; | ||
} | ||
|
||
set | ||
{ | ||
_increment = value; | ||
OnPropertyChanged("Increment"); | ||
} | ||
} | ||
|
||
public ViewModelClass() | ||
{ | ||
Increment = 2; | ||
} | ||
private void OnPropertyChanged(string v) | ||
{ | ||
if (PropertyChanged != null) | ||
{ | ||
PropertyChanged(this, new PropertyChangedEventArgs(v)); | ||
} | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20706.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#if TEST_FAILS_ON_CATALYST // Stepper interaction is not implemented for catalyst | ||
using NUnit.Framework; | ||
using NUnit.Framework.Legacy; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue20706 : _IssuesUITest | ||
{ | ||
public override string Issue => "Stepper doesn't change increment value when being bound to a double in MVVM context (Windows)"; | ||
public Issue20706(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.Stepper)] | ||
public void ChangeIncrementValue() | ||
{ | ||
App.WaitForElement("entry"); | ||
// check the current value. | ||
var initialValue = App.FindElement("entry").GetText(); | ||
Assert.That("0", Is.EqualTo(initialValue)); | ||
|
||
// Increase the value. | ||
App.IncreaseStepper("myStepper"); | ||
|
||
// Verify that the value has been increased. | ||
var step1Value = App.FindElement("entry").GetText(); | ||
Assert.That("2", Is.EqualTo(step1Value)); | ||
|
||
// Change the Stepper increment value. | ||
App.Click("incrementButton"); | ||
|
||
// Increase the value. | ||
App.IncreaseStepper("myStepper"); | ||
var step2Value = App.FindElement("entry").GetText(); | ||
Assert.That("12", Is.EqualTo(step2Value)); | ||
|
||
// Decrease the value. | ||
App.DecreaseStepper("myStepper"); | ||
|
||
// Verify that the value has decreased. | ||
var step3Value = App.FindElement("entry").GetText(); | ||
Assert.That("2", Is.EqualTo(step3Value)); | ||
} | ||
} | ||
} | ||
#endif |