Reported 2026-11-05: those two tabs stayed open when clicking elsewhere, unlike Stream Settings, YPP and TEST. All five drawers share one host (TextPullOutHost), but the window's click-outside guard only listed the other three, so the gear and socials panels had no way to dismiss except their own tab. The guard now closes them too, and a test pins both directions: an outside click retracts the drawer, and a click inside it does not.
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Microsoft.Data.Sqlite;
|
|
using Xunit;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// 2026-11-05 report: "the gear-icon tab and the socials tab do not retract when I click off the div,
|
|
/// like the other tabs." Both drawers live in the same host as Stream Settings / YPP / TEST, but the
|
|
/// window's click-outside guard only knew about the other three.
|
|
/// </summary>
|
|
[Collection("RealApp")]
|
|
public sealed class DrawerOutsideClickTests
|
|
{
|
|
private readonly RealAppHost _app;
|
|
|
|
public DrawerOutsideClickTests(RealAppHost app) => _app = app;
|
|
|
|
[Fact]
|
|
public void ClickingOutside_RetractsTheSettingsAndSocialsDrawers()
|
|
{
|
|
_app.Run(() =>
|
|
{
|
|
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-drawers-{Guid.NewGuid():N}.db");
|
|
MainViewModel.LayoutPathOverride = tempDb;
|
|
var window = new MainWindow();
|
|
var vm = (MainViewModel)window.DataContext;
|
|
try
|
|
{
|
|
window.Show();
|
|
window.UpdateLayout();
|
|
|
|
// Open the gear drawer, then click somewhere that is not the drawer host.
|
|
vm.ToggleSettingsDrawer();
|
|
Assert.True(vm.SettingsDrawerOpen);
|
|
|
|
RaiseOutsideClick(window);
|
|
Assert.False(vm.SettingsDrawerOpen);
|
|
|
|
// …and clicking INSIDE the drawer must not close it, or the panel would be unusable.
|
|
vm.ToggleSettingsDrawer();
|
|
Assert.True(vm.SettingsDrawerOpen);
|
|
var pane = (System.Windows.Controls.UserControl)window.FindName("PreviewPane")!;
|
|
var host = (FrameworkElement)pane.FindName("TextPullOutHost")!;
|
|
RaiseClickOn(host);
|
|
Assert.True(vm.SettingsDrawerOpen);
|
|
}
|
|
finally
|
|
{
|
|
window.Close();
|
|
MainViewModel.LayoutPathOverride = null;
|
|
SqliteConnection.ClearAllPools();
|
|
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
|
}
|
|
});
|
|
}
|
|
|
|
/// <summary>A left-button-down that originates on the window itself — outside the preview, the left
|
|
/// panel and the drawer host, which is exactly the case the guard handles.</summary>
|
|
private static void RaiseOutsideClick(Window window) => RaiseClickOn(window);
|
|
|
|
private static void RaiseClickOn(UIElement target)
|
|
{
|
|
var args = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left)
|
|
{
|
|
RoutedEvent = UIElement.PreviewMouseLeftButtonDownEvent,
|
|
Source = target,
|
|
};
|
|
target.RaiseEvent(args);
|
|
}
|
|
}
|