diff --git a/tests/Perspex.Benchmarks/Controls/Initialization.cs b/tests/Perspex.Benchmarks/Controls/Initialization.cs deleted file mode 100644 index 2ce4ad9b43..0000000000 --- a/tests/Perspex.Benchmarks/Controls/Initialization.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) The Perspex Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -using System; -using System.Linq; -using BenchmarkDotNet.Attributes; -using Perspex.Controls; -using Perspex.Layout; -using Perspex.UnitTests; -using Perspex.VisualTree; - -namespace Perspex.Benchmarks.Controls -{ - public class Initialization - { - [Benchmark] - public void Add_And_Style_TextBox() - { - using (UnitTestApplication.Start(TestServices.StyledWindow)) - { - var window = new Window - { - Content = new TextBox(), - }; - - LayoutManager.Instance.ExecuteInitialLayoutPass(window); - - if (((TextBox)window.Content).GetVisualChildren().Count() != 1) - { - throw new Exception("Control not styled."); - } - } - } - } -} diff --git a/tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj b/tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj index 909bc8de82..253a26cfa1 100644 --- a/tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj +++ b/tests/Perspex.Benchmarks/Perspex.Benchmarks.csproj @@ -65,7 +65,7 @@ - + diff --git a/tests/Perspex.Benchmarks/Program.cs b/tests/Perspex.Benchmarks/Program.cs index 04575f8ed0..536e2ba7d3 100644 --- a/tests/Perspex.Benchmarks/Program.cs +++ b/tests/Perspex.Benchmarks/Program.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; -using Perspex.Benchmarks.Controls; namespace Perspex.Benchmarks { diff --git a/tests/Perspex.Benchmarks/Styling/ApplyStyling.cs b/tests/Perspex.Benchmarks/Styling/ApplyStyling.cs new file mode 100644 index 0000000000..b013a69c0d --- /dev/null +++ b/tests/Perspex.Benchmarks/Styling/ApplyStyling.cs @@ -0,0 +1,55 @@ +// Copyright (c) The Perspex Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using System.Linq; +using BenchmarkDotNet.Attributes; +using Perspex.Controls; +using Perspex.UnitTests; +using Perspex.VisualTree; + +namespace Perspex.Benchmarks.Styling +{ + public class ApplyStyling : IDisposable + { + private IDisposable _app; + private Window _window; + + public ApplyStyling() + { + _app = UnitTestApplication.Start(TestServices.StyledWindow); + + TextBox textBox; + + _window = new Window + { + Content = textBox = new TextBox(), + }; + + _window.ApplyTemplate(); + textBox.ApplyTemplate(); + + var border = (Border)textBox.GetVisualChildren().Single(); + + if (border.BorderThickness != 2) + { + throw new Exception("Styles not applied."); + } + + _window.Content = null; + } + + public void Dispose() + { + _app.Dispose(); + } + + [Benchmark] + public void Add_And_Style_TextBox() + { + var textBox = new TextBox(); + _window.Content = textBox; + textBox.ApplyTemplate(); + } + } +}