Skip to content

Commit

Permalink
Added a UITest (#19380)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Feb 3, 2024
1 parent 765f3f9 commit 627ee31
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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.Issue19380"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<ContentPage.Resources>
<Style TargetType="Switch">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="OnColor" Value="Red" />
<Setter Property="ThumbColor" Value="Red" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="On">
<VisualState.Setters>
<Setter Property="OnColor" Value="Green" />
<Setter Property="ThumbColor" Value="White" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Off">
<VisualState.Setters>
<Setter Property="ThumbColor" Value="White" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>

</ContentPage.Resources>

<StackLayout>
<Label Text="Switch with OnColor and Thumb Color explicitly set"/>
<Switch AutomationId="switch1" OnColor="red" ThumbColor="Blue"/>
<Label Text="Switch with OnColor and Thumb Color controlled by the visual state manager"/>
<Switch AutomationId="switch2"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 19380, "Switch control ignores OnColor and ThumbColor", PlatformAffected.iOS | PlatformAffected.Android)]
public partial class Issue19380 : ContentPage
{
public Issue19380()
{
InitializeComponent();
}
}
}
28 changes: 28 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19380.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue19380 : _IssuesUITest
{
public override string Issue => "Switch control ignores OnColor and ThumbColor";

public Issue19380(TestDevice device) : base(device)
{
}

[Test]
public void ShouldOverrideThumbAndOnColorsFromResources()
{
_= App.WaitForElement("switch1");

App.Click("switch1");
App.Click("switch2");

// The first switch should have a blue thumb and a red track
// The second switch should have a white thumb an a green track
App.Screenshot();
}
}
}

0 comments on commit 627ee31

Please sign in to comment.