mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-26 01:49:12 +01:00
test: the choice between window surfaces and the processor is covered
The choice moves out of Program, which no test runs, into WindowSurfaces, where both branches are tested. Sonar's quality gate failed on the coverage of the new code.
This commit is contained in:
@@ -21,11 +21,13 @@ public class WindowSurfacesTests
|
||||
Assert.Contains(Win32RenderingMode.AngleEgl, WindowSurfaces.Win32Options.RenderingMode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_options_go_to_the_same_builder()
|
||||
[Theory]
|
||||
[InlineData(false)]
|
||||
[InlineData(true)]
|
||||
public void The_options_go_to_the_same_builder_with_or_without_the_processor(bool softwareRender)
|
||||
{
|
||||
var builder = AppBuilder.Configure<Avalonia.Application>();
|
||||
|
||||
Assert.Same(builder, WindowSurfaces.ApplyTo(builder));
|
||||
Assert.Same(builder, WindowSurfaces.ApplyTo(builder, softwareRender));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace StarterNG.Infrastructure;
|
||||
/// visual was left empty on many starts: the main window, or a dialog opened later,
|
||||
/// stayed black while the others drew, and came back only now and then. Composition is
|
||||
/// there for see-through windows and backdrops, and the starter has none.
|
||||
/// <see cref="SoftwareRender"/> goes after this and brings its own options.
|
||||
/// </summary>
|
||||
public static class WindowSurfaces
|
||||
{
|
||||
@@ -17,5 +16,10 @@ public static class WindowSurfaces
|
||||
CompositionMode = new[] { Win32CompositionMode.RedirectionSurface }
|
||||
};
|
||||
|
||||
public static AppBuilder ApplyTo(AppBuilder builder) => builder.With(Win32Options);
|
||||
/// <summary>
|
||||
/// The options a platform reads are the last given, so the processor, when asked
|
||||
/// for, draws with <see cref="SoftwareRender"/>'s own and these are left out.
|
||||
/// </summary>
|
||||
public static AppBuilder ApplyTo(AppBuilder builder, bool softwareRender) =>
|
||||
softwareRender ? SoftwareRender.ApplyTo(builder) : builder.With(Win32Options);
|
||||
}
|
||||
|
||||
@@ -73,17 +73,13 @@ static class Program
|
||||
};
|
||||
}
|
||||
|
||||
private static AppBuilder WithWindowSurfaces(this AppBuilder builder) =>
|
||||
WindowSurfaces.ApplyTo(builder);
|
||||
|
||||
// Without the switch the graphics card draws, into the window surfaces.
|
||||
private static AppBuilder WithSoftwareRenderIfAsked(this AppBuilder builder) =>
|
||||
_softwareRender ? SoftwareRender.ApplyTo(builder) : builder;
|
||||
WindowSurfaces.ApplyTo(builder, _softwareRender);
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.WithWindowSurfaces()
|
||||
// After the surfaces: the later options of a platform are the ones it reads.
|
||||
.WithSoftwareRenderIfAsked()
|
||||
.WithInterFont()
|
||||
.WithDiagnosticsLogging()
|
||||
|
||||
Reference in New Issue
Block a user