-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Test] Add SwitchConverter tests to the primitives component
Fix test header (failure in CI from last commit)
- Loading branch information
1 parent
4f8f858
commit cd19f55
Showing
4 changed files
with
171 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
53 changes: 53 additions & 0 deletions
53
components/Primitives/tests/SwitchPresenter/SwitchConverterBrushSample.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,53 @@ | ||
<Page x:Class="PrimitivesExperiment.Tests.SwitchConverterBrushSample" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:CommunityToolkit.WinUI.Controls" | ||
xmlns:converters="using:CommunityToolkit.WinUI.Converters" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:PrimitivesExperiment.Tests" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="using:CommunityToolkit.WinUI" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<!-- | ||
If you reference an enum directly in UWP, you need to use it somewhere for the XamlTypeInfo reference to be generated... | ||
--> | ||
<local:CheckStatus x:Key="MyChecks">Warning</local:CheckStatus> | ||
|
||
<!-- Make it easier for us to retrieve these to compare from test --> | ||
<StaticResource x:Key="SystemFillColorSuccessBrush" | ||
ResourceKey="SystemFillColorSuccessBrush" /> | ||
<StaticResource x:Key="SystemFillColorCautionBrush" | ||
ResourceKey="SystemFillColorCautionBrush" /> | ||
<StaticResource x:Key="SystemFillColorCriticalBrush" | ||
ResourceKey="SystemFillColorCriticalBrush" /> | ||
|
||
<!-- SwitchConverter lets you easily convert general values to resources --> | ||
<!-- Note: This is in the converters namespace --> | ||
<converters:SwitchConverter x:Key="StatusToColorSwitchConverter" | ||
TargetType="local:CheckStatus"> | ||
<!-- Note: These are reused from the controls namespace from SwitchPresenter --> | ||
<controls:Case Content="{ThemeResource SystemFillColorSuccessBrush}" | ||
Value="Success" /> | ||
<controls:Case Content="{ThemeResource SystemFillColorCautionBrush}" | ||
Value="Warning" /> | ||
<controls:Case Content="{ThemeResource SystemFillColorCriticalBrush}" | ||
Value="Error" /> | ||
</converters:SwitchConverter> | ||
</Page.Resources> | ||
|
||
<StackPanel Spacing="8"> | ||
<ComboBox x:Name="StatusPicker" | ||
Header="Pick a status" | ||
SelectedIndex="0"> | ||
<x:String>Success</x:String> | ||
<x:String>Warning</x:String> | ||
<x:String>Error</x:String> | ||
</ComboBox> | ||
<TextBlock x:Name="ResultBlock" | ||
FontWeight="SemiBold" | ||
Foreground="{x:Bind StatusPicker.SelectedItem, Converter={StaticResource StatusToColorSwitchConverter}, Mode=OneWay}" | ||
Text="{x:Bind StatusPicker.SelectedItem, Mode=OneWay}" /> | ||
</StackPanel> | ||
</Page> |
20 changes: 20 additions & 0 deletions
20
components/Primitives/tests/SwitchPresenter/SwitchConverterBrushSample.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,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace PrimitivesExperiment.Tests; | ||
|
||
public sealed partial class SwitchConverterBrushSample : Page | ||
{ | ||
public SwitchConverterBrushSample() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
|
||
public enum CheckStatus | ||
{ | ||
Error, | ||
Warning, | ||
Success, | ||
} |
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