-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/8.0.1xx-sr9] [C] fix specificity comparison (#24908)
* test for #24849 * failing test * [C] OR EQUAL ! - fixes #24849 --------- Co-authored-by: Stephane Delcroix <[email protected]>
- Loading branch information
1 parent
a249a31
commit adcbc7d
Showing
5 changed files
with
121 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/Xaml.UnitTests/AppResources/Style24849.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,26 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Style24849"> | ||
<Color x:Key="PrimaryButtonTextColor">White</Color> | ||
<Color x:Key="PrimaryButtonDisabledTextColor">#3c3c3b</Color> | ||
<Style TargetType="Button"> | ||
<Setter Property="TextColor" Value="{DynamicResource PrimaryButtonTextColor}" /> | ||
<Setter Property="VisualStateManager.VisualStateGroups"> | ||
<VisualStateGroupList> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Property="TextColor" Value="{DynamicResource PrimaryButtonTextColor}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Disabled"> | ||
<VisualState.Setters> | ||
<Setter Property="TextColor" Value="{DynamicResource PrimaryButtonDisabledTextColor}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateGroupList> | ||
</Setter> | ||
</Style> | ||
</ResourceDictionary> |
16 changes: 16 additions & 0 deletions
16
src/Controls/tests/Xaml.UnitTests/AppResources/Style24849.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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests | ||
{ | ||
public partial class Style24849 : ResourceDictionary | ||
{ | ||
public Style24849() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
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,7 @@ | ||
<?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.Maui24849"> | ||
<Button x:Name="button" IsEnabled="False" /> | ||
</ContentPage> |
71 changes: 71 additions & 0 deletions
71
src/Controls/tests/Xaml.UnitTests/Issues/Maui24849.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,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
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.Dispatching; | ||
|
||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests; | ||
|
||
public partial class Maui24849 : ContentPage | ||
{ | ||
public Maui24849() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui24849(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
MockDeviceInfo mockDeviceInfo; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DeviceInfo.SetCurrent(mockDeviceInfo = new MockDeviceInfo()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
|
||
[TearDown] public void TearDown() | ||
{ | ||
AppInfo.SetCurrent(null); | ||
DeviceInfo.SetCurrent(null); | ||
} | ||
|
||
[Test] | ||
public void VSGReturnsToNormal([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var app = new MockApplication(); | ||
app.Resources.Add(new Style24849()); | ||
var page = new Maui24849(useCompiledXaml); | ||
|
||
app.MainPage = page; | ||
|
||
Assert.That(page.button.IsEnabled, Is.False); | ||
Assert.That(page.button.TextColor, Is.EqualTo(Color.FromHex("#3c3c3b"))); | ||
|
||
page.button.IsEnabled = true; | ||
Assert.That(page.button.IsEnabled, Is.True); | ||
Assert.That(page.button.TextColor, Is.EqualTo(Colors.White)); | ||
|
||
page.button.IsEnabled = false; | ||
Assert.That(page.button.IsEnabled, Is.False); | ||
Assert.That(page.button.TextColor, Is.EqualTo(Color.FromHex("#3c3c3b"))); | ||
} | ||
} | ||
} |