diff --git a/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj b/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj
index 251894e324..e8e69efdbc 100644
--- a/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj
+++ b/tests/Avalonia.Benchmarks/Avalonia.Benchmarks.csproj
@@ -12,6 +12,7 @@
+
diff --git a/tests/Avalonia.Benchmarks/Themes/FluentBenchmark.cs b/tests/Avalonia.Benchmarks/Themes/FluentBenchmark.cs
new file mode 100644
index 0000000000..3a05502371
--- /dev/null
+++ b/tests/Avalonia.Benchmarks/Themes/FluentBenchmark.cs
@@ -0,0 +1,74 @@
+using System;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using Avalonia.Markup.Xaml.Styling;
+using Avalonia.Platform;
+using Avalonia.Shared.PlatformSupport;
+using Avalonia.Styling;
+using Avalonia.UnitTests;
+using BenchmarkDotNet.Attributes;
+using Moq;
+
+namespace Avalonia.Benchmarks.Themes
+{
+ [MemoryDiagnoser]
+ public class FluentBenchmark
+ {
+ private readonly IDisposable _app;
+ private readonly TestRoot _root;
+
+ public FluentBenchmark()
+ {
+ _app = CreateApp();
+ _root = new TestRoot(true, null)
+ {
+ Renderer = new NullRenderer()
+ };
+
+ _root.LayoutManager.ExecuteInitialLayoutPass();
+ }
+
+ public void Dispose()
+ {
+ _app.Dispose();
+ }
+
+ [Benchmark]
+ public void RepeatButton()
+ {
+ var button = new RepeatButton();
+ _root.Child = button;
+ _root.LayoutManager.ExecuteLayoutPass();
+ }
+
+ private static IDisposable CreateApp()
+ {
+ var services = new TestServices(
+ assetLoader: new AssetLoader(),
+ globalClock: new MockGlobalClock(),
+ platform: new AppBuilder().RuntimePlatform,
+ renderInterface: new MockPlatformRenderInterface(),
+ standardCursorFactory: Mock.Of(),
+ styler: new Styler(),
+ theme: () => LoadFluentTheme(),
+ threadingInterface: new NullThreadingPlatform(),
+ fontManagerImpl: new MockFontManagerImpl(),
+ textShaperImpl: new MockTextShaperImpl(),
+ windowingPlatform: new MockWindowingPlatform());
+
+ return UnitTestApplication.Start(services);
+ }
+
+ private static Styles LoadFluentTheme()
+ {
+ AssetLoader.RegisterResUriParsers();
+ return new Styles
+ {
+ new StyleInclude(new Uri("avares://Avalonia.Benchmarks"))
+ {
+ Source = new Uri("avares://Avalonia.Themes.Fluent/Accents/FluentDark.xaml")
+ }
+ };
+ }
+ }
+}
diff --git a/tests/Avalonia.UnitTests/UnitTestApplication.cs b/tests/Avalonia.UnitTests/UnitTestApplication.cs
index e4a65f105d..4e3f1ad28a 100644
--- a/tests/Avalonia.UnitTests/UnitTestApplication.cs
+++ b/tests/Avalonia.UnitTests/UnitTestApplication.cs
@@ -25,6 +25,7 @@ namespace Avalonia.UnitTests
public UnitTestApplication(TestServices services)
{
_services = services ?? new TestServices();
+ AvaloniaLocator.CurrentMutable.BindToSelf(this);
RegisterServices();
}
@@ -36,7 +37,6 @@ namespace Avalonia.UnitTests
{
var scope = AvaloniaLocator.EnterScope();
var app = new UnitTestApplication(services);
- AvaloniaLocator.CurrentMutable.BindToSelf(app);
Dispatcher.UIThread.UpdateServices();
return Disposable.Create(() =>
{