// 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; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Headless; using Avalonia.Input; using Avalonia.Headless.NUnit; using Avalonia.Threading; using Avalonia.VisualTree; using AwesomeAssertions; using Dock.Avalonia.Controls; using ICSharpCode.ILSpy; using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.TextView; using ICSharpCode.ILSpy.ViewModels; using ICSharpCode.ILSpy.Views; using NUnit.Framework; namespace ICSharpCode.ILSpy.Tests.Docking; /// /// The document tab strip toggles between a single scrolling row and multiple wrapped rows, driven by /// the persisted setting and the mouse wheel. The /// overflow dropdown that lists open documents shows only in single-line mode. /// [TestFixture] public class DocumentTabStripModeTests { static SessionSettings Settings => AppComposition.Current.GetExport().SessionSettings; static async Task<(MainWindow window, DocumentTabStrip strip)> BootWithTabsAsync(bool multiLine) { var (window, vm) = await TestHarness.BootAsync(1); Settings.MultiLineDocumentTabs = multiLine; for (int i = 0; i < 30; i++) vm.DockWorkspace.OpenNewTab(new DecompilerTabPageModel { Title = $"Tab {i:00}" }); await Pump(window); var strip = window.GetVisualDescendants().OfType().First(); return (window, strip); } static async Task Pump(MainWindow window) { for (int i = 0; i < 12; i++) { Dispatcher.UIThread.RunJobs(); window.UpdateLayout(); await Task.Delay(20); } } static Button? Dropdown(DocumentTabStrip strip) => strip.GetVisualDescendants().OfType