The Blur item's Visibility is bound to CanAddBlur, which depends on the staged scene. The scene setter never raised it, so the binding evaluated once (collapsed) and stayed collapsed for the session — build 1082: the option simply wasn't there. StagedScene now notifies CanAddBlur, with a test that pins both halves: Live true, Chat false, and a notification on every staged-scene change.
52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Xunit;
|
|
using ytLive.Models;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// The (+) menu's Blur entry is Live-scene only, and it is bound — so the view model has to
|
|
/// re-notify `CanAddBlur` whenever the staged scene changes. It did not, and the option stayed
|
|
/// collapsed for the rest of the session (build 1082: "it no longer appears as an option").
|
|
/// </summary>
|
|
[Collection("MainViewModelLayoutPath")]
|
|
public class BlurMenuAvailabilityTests
|
|
{
|
|
private static MainViewModel NewVm(out string dbPath)
|
|
{
|
|
dbPath = Path.Combine(Path.GetTempPath(), $"llamacasty-blurmenu-{Guid.NewGuid():N}.db");
|
|
MainViewModel.LayoutPathOverride = dbPath;
|
|
return new MainViewModel();
|
|
}
|
|
|
|
[Fact]
|
|
public void Blur_is_offered_on_the_live_scene_only_and_the_flag_is_re_notified()
|
|
{
|
|
var vm = NewVm(out var dbPath);
|
|
try
|
|
{
|
|
var live = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Live));
|
|
var chat = vm.Scenes.First(s => SceneCatalog.Is(s.Name, SceneCatalog.Chat));
|
|
|
|
vm.StagedScene = live;
|
|
Assert.True(vm.CanAddBlur, "the Live scene must offer the blur layer");
|
|
vm.StagedScene = chat;
|
|
Assert.False(vm.CanAddBlur, "other scenes must not offer a desktop blur");
|
|
|
|
// The regression: a bound property with no notification never re-evaluates.
|
|
var notified = 0;
|
|
vm.PropertyChanged += (_, e) => { if (e.PropertyName == nameof(MainViewModel.CanAddBlur)) notified++; };
|
|
vm.StagedScene = live;
|
|
Assert.True(notified > 0, "changing the staged scene must re-notify CanAddBlur");
|
|
}
|
|
finally
|
|
{
|
|
MainViewModel.LayoutPathOverride = null;
|
|
try { File.Delete(dbPath); } catch (IOException) { }
|
|
}
|
|
}
|
|
}
|