-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d32017
commit b170fbb
Showing
6 changed files
with
163 additions
and
7 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ public enum IssueTracker | |
{ | ||
Github, | ||
Bugzilla, | ||
ManualTest, | ||
None | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Controls/samples/Controls.Sample.UITests/Issues/Issue18617.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,29 @@ | ||
<?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.Issue18617"> | ||
<VerticalStackLayout> | ||
<Label | ||
AutomationId="WaitForStubControl" | ||
Text="1. Press the 'On' button." /> | ||
<Label | ||
Text="2. The test fails if the 'On' button is still enabled or the 'Off' button is not enabled." /> | ||
<Label | ||
Text="3. Press the 'Off' button." /> | ||
<Label | ||
Text="4. The test fails if the 'Off' button is still enabled or the 'On' button is not enabled." /> | ||
<Label | ||
Text="5. Repeat the steps above 2 more times." /> | ||
<Button | ||
AutomationId="OnButton" | ||
Command="{Binding OnCommand}" | ||
Text="On" /> | ||
<Button | ||
AutomationId="OffButton" | ||
Command="{Binding OffCommand}" | ||
Text="Off" /> | ||
<Label | ||
AutomationId="StatusLabel" | ||
Text="{Binding Status}"/> | ||
</VerticalStackLayout> | ||
</ContentPage> |
48 changes: 48 additions & 0 deletions
48
src/Controls/samples/Controls.Sample.UITests/Issues/Issue18617.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,48 @@ | ||
using System.Windows.Input; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.ManualTest, "G5", "Button Command CanExecute can disable the control", PlatformAffected.All)] | ||
public partial class Issue18617 : ContentPage | ||
{ | ||
string _status; | ||
|
||
public Issue18617() | ||
{ | ||
InitializeComponent(); | ||
|
||
OnCommand = new Command(execute: HandleCommand, canExecute: () => !Toggle); | ||
OffCommand = new Command(execute: HandleCommand, canExecute: () => Toggle); | ||
|
||
BindingContext = this; | ||
} | ||
|
||
void HandleCommand() | ||
{ | ||
Toggle = !Toggle; | ||
Status = !Toggle ? "OnButton enabled OffButton disabled" : "OnButton disabled OffButton enabled"; | ||
|
||
((Command)OnCommand).ChangeCanExecute(); | ||
((Command)OffCommand).ChangeCanExecute(); | ||
} | ||
|
||
public bool Toggle { get; set; } = false; | ||
|
||
public ICommand OnCommand { get; set; } | ||
|
||
public ICommand OffCommand { get; set; } | ||
|
||
public string Status | ||
{ | ||
get { return _status; } | ||
set | ||
{ | ||
_status = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
} |
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,37 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue18617 : _IssuesUITest | ||
{ | ||
public Issue18617(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
public override string Issue => "Button Command CanExecute can disable the control"; | ||
|
||
[Test] | ||
public void CommandCanExecuteDisableButton() | ||
{ | ||
App.WaitForElement("WaitForStubControl"); | ||
|
||
// 1. Press the 'On' button. | ||
App.Click("OnButton"); | ||
|
||
// 2. The test fails if the 'On' button is still enabled or the 'Off' button is not enabled. | ||
var status1 = App.FindElement("StatusLabel").GetText(); | ||
Assert.AreEqual("OnButton disabled OffButton enabled", status1); | ||
|
||
// 3.Press the 'Off' button. | ||
App.Click("OffButton"); | ||
|
||
// 4. The test fails if the 'Off' button is still enabled or the 'On' button is not enabled. | ||
var status2 = App.FindElement("StatusLabel").GetText(); | ||
Assert.AreEqual("OnButton enabled OffButton disabled", status2); | ||
|
||
// NOTE: We do not verify snapshots because we already did it in G1. | ||
} | ||
} | ||
} |