Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

<!-- Skip Xcode version validation so minor Xcode updates don't break builds -->
<ValidateXcodeVersion>false</ValidateXcodeVersion>

<!-- Treat all warnings as errors -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- .NET 11 preview SDK flags net9.0 workloads as EOL -->
<CheckEolWorkloads>false</CheckEolWorkloads>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

</Project>
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools.WinApp" Version="0.3.1" />
<PackageVersion Include="Spectre.Console.Cli" Version="0.53.1" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.54.0" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.utility" Version="2.9.3" />
Expand Down
5 changes: 4 additions & 1 deletion sample/src/DeviceTestingKitApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- The MAUI app defines its own Program.Main; disable the auto-generated testing platform entry point -->
<GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>

<!-- Test pages intentionally use Source= bindings (e.g. x:Reference in DataTriggers) for demonstration purposes -->
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0025</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -79,4 +85,12 @@
</ItemGroup>
</Target>

<!-- Exclude runtimeconfig.json files from referenced test library projects that the platform SDK cannot classify -->
<Target Name="_ExcludeTestLibraryRuntimeConfigs" BeforeTargets="_ComputePublishPackage;_ComputeAppBundleContent;ComputeResolvedFilesToPublishList">
<ItemGroup>
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
Condition="$([System.String]::Copy('%(Filename)%(Extension)').EndsWith('.runtimeconfig.json')) and ($([System.String]::Copy('%(Filename)').StartsWith('DeviceTestingKitApp.Library.NUnitTests')) or $([System.String]::Copy('%(Filename)').StartsWith('DeviceTestingKitApp.MauiLibrary.XunitTests')))" />
</ItemGroup>
</Target>

</Project>
1 change: 0 additions & 1 deletion src/DeviceRunners.Cli/DeviceRunners.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

<ItemGroup>
<PackageReference Include="Spectre.Console.Cli" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" />
<PackageReference Include="AndroidSdk" />
<PackageReference Include="AppleDev" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<IsPackable>true</IsPackable>
<!-- CA2255: [ModuleInitializer] is intentionally used to auto-register the MAUI UI thread coordinator -->
<NoWarn>CA2255</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
<RootNamespace>DeviceRunners.VisualRunners</RootNamespace>
<Description>Core cross-platform types for DeviceRunners visual test runners (result channels, formatters, test events).</Description>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?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:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.CreditsPage"
x:DataType="vr:CreditsViewModel"
Title="Credits">

<WebView Navigating="OnNavigating">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?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:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.DiagnosticsPage"
x:DataType="vr:DiagnosticsViewModel"
Title="Diagnostics">

<ContentPage.ToolbarItems>
Expand Down
9 changes: 5 additions & 4 deletions src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?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:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.HomePage"
x:DataType="vr:HomeViewModel"
Title="Test Runner">

<Grid RowDefinitions="Auto,*,Auto,120" ColumnDefinitions="*,Auto"
Expand All @@ -20,15 +22,14 @@
<!-- assembly list -->
<CollectionView x:Name="assemblyList"
ItemsSource="{Binding TestAssemblies}"
SelectedItem="{Binding SelectedTestAssembly, Mode=TwoWay}"
SelectionMode="Single"
SelectionChangedCommand="{Binding NavigateToTestAssemblyCommand}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={Reference assemblyList}}"
AutomationId="TestAssembliesList"
Margin="-20,0" Grid.Row="1" Grid.ColumnSpan="2">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="vr:TestAssemblyViewModel">
<StackLayout Padding="20,10" Spacing="5">
<Label Text="{Binding DisplayName}" TextColor="{Binding TestResultStatus, Converter={StaticResource RunStatusToColorConverter}}" />
<Label Text="{Binding DisplayName}" TextColor="{Binding ResultStatus, Converter={StaticResource RunStatusToColorConverter}}" />
<StackLayout Orientation="Horizontal" Spacing="5">

<Label Text="✔" TextColor="{StaticResource SuccessfulTestsColor}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.TestAssemblyPage"
x:DataType="vr:TestAssemblyViewModel"
Title="{Binding DisplayName}">

<Grid RowDefinitions="Auto,Auto,*" ColumnDefinitions="*,Auto,Auto"
Expand Down Expand Up @@ -46,13 +47,12 @@
<!-- assembly list -->
<CollectionView x:Name="testsList"
ItemsSource="{Binding TestCases}"
SelectedItem="{Binding SelectedTestCase, Mode=TwoWay}"
SelectionMode="Single"
SelectionChangedCommand="{Binding NavigateToResultCommand}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={Reference testsList}}"
AutomationId="TestCasesList"
Margin="-20,0" Grid.Row="2" Grid.ColumnSpan="3">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="vr:TestCaseViewModel">
<StackLayout Padding="20,10" Spacing="5">
<Label Text="{Binding DisplayName}" />
<Label Text="{Binding Message}" TextColor="{Binding ResultStatus, Converter={StaticResource RunStatusToColorConverter}}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?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:vr="clr-namespace:DeviceRunners.VisualRunners;assembly=DeviceRunners.VisualRunners"
xmlns:local="using:DeviceRunners.VisualRunners.Maui"
x:Class="DeviceRunners.VisualRunners.Maui.Pages.TestResultPage"
x:DataType="vr:TestResultViewModel"
Title="Test Result">

<ScrollView>
Expand Down
6 changes: 3 additions & 3 deletions src/DeviceRunners.VisualRunners.Maui/App/VisualRunnerApp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
<Setter Property="Background" Value="#CCFFFFFF" />
<Setter Property="InputTransparent" Value="False" />
<Setter Property="ControlTemplate">
<DataTemplate>
<ControlTemplate x:DataType="ContentView">
<Grid>
<StackLayout VerticalOptions="Center" HorizontalOptions="Center" Spacing="20">
<Label Text="Working..." />
<ActivityIndicator IsRunning="{Binding Source={RelativeSource AncestorType={x:Type ContentView}}, Path=IsVisible}" />
<ActivityIndicator IsRunning="{TemplateBinding IsVisible}" />
</StackLayout>
</Grid>
</DataTemplate>
</ControlTemplate>
</Setter>
</Style>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:pages="clr-namespace:DeviceRunners.VisualRunners.Maui.Pages">

<Shell.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="BaseShellItem">
<Grid ColumnDefinitions="0.2*,0.8*">
<Image Source="{Binding FlyoutIcon}"
Margin="5"
Expand Down
10 changes: 8 additions & 2 deletions src/DeviceRunners.VisualRunners.Xunit/XunitTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ void RunTests(XunitTestAssemblyInfo assemblyInfo, IList<IDisposable> pendingLock

var deviceExecSink = new DeviceExecutionSink(xunitTestCases, _resultChannelManager);

IExecutionSink resultsSink = new DelegatingExecutionSummarySink(deviceExecSink, () => cancellationToken.IsCancellationRequested);
var sinkOptions = new ExecutionSinkOptions
{
CancelThunk = () => cancellationToken.IsCancellationRequested,
};

if (longRunningSeconds > 0)
{
Expand All @@ -127,9 +130,12 @@ void RunTests(XunitTestAssemblyInfo assemblyInfo, IList<IDisposable> pendingLock
assemblyInfo.AssemblyFileName,
executionOptions.GetDiagnosticMessagesOrDefault());

resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagSink);
sinkOptions.LongRunningTestTime = TimeSpan.FromSeconds(longRunningSeconds);
sinkOptions.DiagnosticMessageSink = MessageSinkAdapter.Wrap(diagSink);
}

using var resultsSink = new ExecutionSink(deviceExecSink, sinkOptions);

var assm = new XunitProjectAssembly { AssemblyFilename = assemblyInfo.AssemblyFileName };
deviceExecSink.OnMessage(new TestAssemblyExecutionStarting(assm, executionOptions));

Expand Down
5 changes: 3 additions & 2 deletions src/DeviceRunners.VisualRunners/Utils/FileSystemUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class FileSystemUtils
// Android: We can only check the assets folder
try
{
return Application.Context.Assets.Open(filename);
var assets = Application.Context.Assets ?? throw new InvalidOperationException("Android AssetManager is not available.");
return assets.Open(filename);
}
catch (Java.IO.FileNotFoundException)
{
Expand Down Expand Up @@ -91,7 +92,7 @@ public static string GetAssemblyFileName(Assembly assm)
return Path.Combine(root, filename);
#elif ANDROID
// this is required to exist (although not actually used) so we create a dummy file
var root = Android.App.Application.Context.CacheDir.AbsolutePath;
var root = Android.App.Application.Context.CacheDir?.AbsolutePath ?? throw new InvalidOperationException("Android CacheDir is not available.");
var path = Path.Combine(root, filename);
if (!File.Exists(path))
File.Create(path).Close();
Expand Down
30 changes: 15 additions & 15 deletions src/DeviceRunners.VisualRunners/Utils/FilteredCollectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public TFilterArg FilterArgument
get { return filterArgument; }
set
{
if (filterArgument.Equals(value))
if (EqualityComparer<TFilterArg>.Default.Equals(filterArgument, value))
{
return;
}
Expand All @@ -58,7 +58,7 @@ public void Dispose()
filteredList.Clear();
}

int IList.Add(object value)
int IList.Add(object? value)
{
throw new NotSupportedException();
}
Expand All @@ -68,24 +68,24 @@ void IList.Clear()
throw new NotSupportedException();
}

bool IList.Contains(object value)
bool IList.Contains(object? value)
{
return Contains((T)value);
return Contains((T)value!);
}

int IList.IndexOf(object value)
int IList.IndexOf(object? value)
{
return IndexOf((T)value);
return IndexOf((T)value!);
}

void IList.Insert(int index, object value)
void IList.Insert(int index, object? value)
{
throw new NotSupportedException();
}

bool IList.IsFixedSize => false;

void IList.Remove(object value)
void IList.Remove(object? value)
{
throw new NotSupportedException();
}
Expand All @@ -95,7 +95,7 @@ void IList.RemoveAt(int index)
throw new NotSupportedException();
}

object IList.this[int index]
object? IList.this[int index]
{
get { return this[index]; }
set { throw new NotSupportedException(); }
Expand Down Expand Up @@ -197,26 +197,26 @@ void DataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventAr
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (T item in e.NewItems)
foreach (T item in e.NewItems!)
{
OnAdded(item);
}

break;
case NotifyCollectionChangedAction.Remove:
foreach (T item in e.OldItems)
foreach (T item in e.OldItems!)
{
OnRemoved(item);
}

break;
case NotifyCollectionChangedAction.Replace:
foreach (T item in e.OldItems)
foreach (T item in e.OldItems!)
{
OnRemoved(item);
}

foreach (T item in e.NewItems)
foreach (T item in e.NewItems!)
{
OnAdded(item);
}
Expand All @@ -227,9 +227,9 @@ void DataSource_CollectionChanged(object? sender, NotifyCollectionChangedEventAr
}
}

void DataSource_ItemChanged(object sender, PropertyChangedEventArgs e)
void DataSource_ItemChanged(object? sender, PropertyChangedEventArgs e)
{
var item = (T)sender;
var item = (T)sender!;
var index = filteredList.IndexOf(item);
if (filter(item, FilterArgument))
{
Expand Down
25 changes: 15 additions & 10 deletions src/DeviceRunners.VisualRunners/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class HomeViewModel : AbstractBaseViewModel

bool _isLoaded;
bool _isBusy;
TestAssemblyViewModel? _selectedTestAssembly;

public HomeViewModel(
IVisualTestRunnerConfiguration options,
Expand All @@ -36,7 +37,6 @@ public HomeViewModel(
Diagnostics = diagnosticsViewModel;

RunEverythingCommand = new Command(RunEverythingExecute, () => !_isBusy);
NavigateToTestAssemblyCommand = new Command<TestAssemblyViewModel?>(NavigateToTestAssemblyExecute);
}

public DiagnosticsViewModel? Diagnostics { get; }
Expand All @@ -45,7 +45,20 @@ public HomeViewModel(

public ICommand RunEverythingCommand { get; }

public ICommand NavigateToTestAssemblyCommand { get; }
public TestAssemblyViewModel? SelectedTestAssembly
{
get => _selectedTestAssembly;
set
{
if (Set(ref _selectedTestAssembly, value) && value is not null)
{
TestAssemblySelected?.Invoke(this, value);
// Clear selection so re-entering the page doesn't re-navigate
_selectedTestAssembly = null;
RaisePropertyChanged(nameof(SelectedTestAssembly));
}
}
}

public event EventHandler<TestAssemblyViewModel>? TestAssemblySelected;

Expand Down Expand Up @@ -127,12 +140,4 @@ async void RunEverythingExecute()
{
await RunEverythingAsync();
}

void NavigateToTestAssemblyExecute(TestAssemblyViewModel? vm)
{
if (vm is null)
return;

TestAssemblySelected?.Invoke(this, vm);
}
}
Loading
Loading