Skip to content

Commit

Permalink
test for 17354
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneDelcroix committed Sep 14, 2023
1 parent 2ec7a0e commit cbf7ef2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui17354.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui17354">
<Grid WidthRequest="500" ColumnDefinitions="*" x:Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=Red, Light=White}"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<Label Text="I'm a grid. Hover over me to change background color"/>
</Grid>
</ContentPage>
47 changes: 47 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui17354.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls.Core.UnitTests;
using Microsoft.Maui.Controls.Shapes;
using Microsoft.Maui.Devices;
using Microsoft.Maui.Graphics;
using NUnit.Framework;

namespace Microsoft.Maui.Controls.Xaml.UnitTests;

public partial class Maui17354 : ContentPage
{

public Maui17354() => InitializeComponent();

public Maui17354(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}

[TestFixture]
class Test
{
[SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo());
[TearDown] public void TearDown() => AppInfo.SetCurrent(null);

[Test]
public void VSMandAppTheme([Values(false, true)] bool useCompiledXaml)
{
var page = new Maui17354(useCompiledXaml);
var grid = page.grid;

Assert.That(grid.BackgroundColor, Is.EqualTo(Colors.Transparent));

Assert.True(VisualStateManager.GoToState(grid, "PointerOver"));
Assert.That(grid.BackgroundColor, Is.EqualTo(Colors.White));

Assert.True(VisualStateManager.GoToState(grid, "Normal"));
Assert.That(grid.BackgroundColor, Is.EqualTo(Colors.Transparent));


}
}
}

0 comments on commit cbf7ef2

Please sign in to comment.