Skip to content

Commit

Permalink
feat: Add manual tests only filter to Samples app
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Feb 22, 2024
1 parent a51ab1b commit 1ed1e44
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public partial class SampleChooserViewModel : System.ComponentModel.INotifyPrope
private bool _contentAttachedToWindow;
private bool _useFluentStyles;
private bool _useDarkTheme;
private bool _manualTestsOnly;
private object _contentPhone = null;
private string _searchTerm = "";

Expand Down Expand Up @@ -134,6 +135,17 @@ public bool CategoryVisibility
}
}

public bool ManualTestsOnly
{
get => _manualTestsOnly;
set
{
_manualTestsOnly = value;
RaisePropertyChanged();
RefreshSamples();
}
}

public bool SampleVisibility
{
get => _sampleVisibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public SampleChooserViewModel(SampleChooserControl owner)
InitializeCommands();
ObserveChanges();

_categories = GetSamples();
RefreshSamples();

if (_log.IsEnabled(LogLevel.Information))
{
Expand Down Expand Up @@ -747,6 +747,11 @@ private static Assembly[] GetAllAssembies()
#endif
}

private void RefreshSamples()
{
Categories = GetSamples();
}

/// <summary>
/// This method retreives all the categories and sample contents associated with them throughout the app.
/// </summary>
Expand All @@ -756,7 +761,7 @@ private List<SampleChooserCategory> GetSamples()
var categories =
from type in _allSamples
let sampleAttribute = FindSampleAttribute(type.GetTypeInfo())
where sampleAttribute != null
where sampleAttribute != null && (!_manualTestsOnly || sampleAttribute.IsManualTest)
let content = GetContent(type.GetTypeInfo(), sampleAttribute)
from category in content.Categories
group content by category into contentByCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@

<!-- LIBRARY (Categories)-->
<Grid Style="{StaticResource BaseTitleGridContainerStyle}"
Height="80"
Visibility="{Binding CategoryVisibility, Converter={StaticResource TrueToVisible}}">

<Grid.ColumnDefinitions>
Expand All @@ -276,6 +277,11 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<!-- Runtime tests button -->
<Button Style="{StaticResource IconButtonStyle}"
VerticalAlignment="Center"
Expand All @@ -284,6 +290,8 @@
<u:PathControl Style="{StaticResource Icon_RuntimeTests}"
Margin="5,0" />
</Button>

<!-- Playground button -->
<Button Style="{StaticResource IconButtonStyle}"
Foreground="{StaticResource Color06Brush}"
Grid.Column="1"
Expand Down Expand Up @@ -320,6 +328,9 @@
<u:PathControl Style="{StaticResource Icon_RunAll}"
Margin="5,0" />
</Button>

<CheckBox Grid.Row="1" Grid.ColumnSpan="5" HorizontalAlignment="Center"
IsChecked="{Binding ManualTestsOnly, Mode=TwoWay}" Content="Manual tests only" />
</Grid>
<ContentControl ContentTemplate="{StaticResource CategoriesList}"
Grid.Row="1"
Expand Down

0 comments on commit 1ed1e44

Please sign in to comment.