diff --git a/ILSpy.Tests/Docking/MultiRowTabStripTests.cs b/ILSpy.Tests/Docking/MultiRowTabStripTests.cs new file mode 100644 index 000000000..e19da8a49 --- /dev/null +++ b/ILSpy.Tests/Docking/MultiRowTabStripTests.cs @@ -0,0 +1,78 @@ +// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Linq; +using System.Threading.Tasks; + +using Avalonia.Controls; +using Avalonia.Headless.NUnit; +using Avalonia.Threading; +using Avalonia.VisualTree; + +using AwesomeAssertions; + +using Dock.Avalonia.Controls; + +using ILSpy.AppEnv; +using ILSpy.TextView; +using ILSpy.ViewModels; +using ILSpy.Views; + +using NUnit.Framework; + +namespace ICSharpCode.ILSpy.Tests.Docking; + +/// +/// PROTOTYPE check: with MultiRowTabStripBehavior enabled (App.axaml), many document tabs flow onto +/// multiple rows (a WrapPanel) instead of a single scrolling row. +/// +[TestFixture] +public class MultiRowTabStripTests +{ + [AvaloniaTest] + public async Task Many_Document_Tabs_Wrap_To_Multiple_Rows() + { + var window = AppComposition.Current.GetExport(); + window.Show(); + var vm = (MainWindowViewModel)window.DataContext!; + await vm.AssemblyTreeModel.WaitForAssembliesAsync(minimumCount: 1); + + for (int i = 0; i < 40; i++) + vm.DockWorkspace.OpenNewTab(new DecompilerTabPageModel { Title = $"Tab number {i:00}" }); + + for (int i = 0; i < 12; i++) + { + Dispatcher.UIThread.RunJobs(); + window.UpdateLayout(); + await Task.Delay(20); + } + + var strip = window.GetVisualDescendants().OfType().FirstOrDefault(); + strip.Should().NotBeNull("the document tab strip must be realised"); + + strip!.GetVisualDescendants().OfType().Should().NotBeEmpty( + "the behaviour must swap the strip's ItemsPanel to a WrapPanel"); + + var rows = strip.GetVisualDescendants().OfType() + .Where(it => it.Bounds.Width > 0) + .Select(it => System.Math.Round(it.Bounds.Y)) + .Distinct().ToList(); + + rows.Count.Should().BeGreaterThan(1, "40 tabs must wrap onto more than one row"); + } +} diff --git a/ILSpy/App.axaml b/ILSpy/App.axaml index addac8231..b015ea473 100644 --- a/ILSpy/App.axaml +++ b/ILSpy/App.axaml @@ -285,6 +285,10 @@ + +