TASK 51 slice 5: webcam Background section in the Layers properties — Remove/Blur PillToggles (radio-exclusive) + Strength slider; strength changes never blank the webcam (new variant inherits the same-effect frame + bitmap). TASK 51 built (Unit: bg-effects UI)
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Xunit;
|
||||
using ytLive.Models;
|
||||
|
||||
namespace ytLive.Tests;
|
||||
|
||||
/// <summary>TASK 51 slice 5 — the creator's UI spec (2026-10-09): Remove and Blur are two pill
|
||||
/// switches in the webcam's Layers properties that act as radio buttons (one on turns the other
|
||||
/// off; both off = no effect), plus a strength slider.</summary>
|
||||
public class WebcamBackgroundPillTests
|
||||
{
|
||||
[Fact]
|
||||
public void Remove_and_Blur_pills_are_radio_exclusive_and_wired_in_the_webcam_properties()
|
||||
{
|
||||
// Behaviour: the bools the pills bind to.
|
||||
var config = new WebcamSceneConfig();
|
||||
var raised = new System.Collections.Generic.List<string?>();
|
||||
config.PropertyChanged += (_, e) => raised.Add(e.PropertyName);
|
||||
|
||||
config.RemoveBackground = true;
|
||||
Assert.Equal(BackgroundEffect.Remove, config.BackgroundEffect);
|
||||
Assert.True(config.HasBackgroundEffect);
|
||||
|
||||
raised.Clear();
|
||||
config.BlurBackground = true; // turning Blur on turns Remove off
|
||||
Assert.Equal(BackgroundEffect.Blur, config.BackgroundEffect);
|
||||
Assert.False(config.RemoveBackground);
|
||||
Assert.Contains(nameof(WebcamSceneConfig.RemoveBackground), raised); // Remove pill un-checks
|
||||
Assert.Contains(nameof(WebcamSceneConfig.BlurBackground), raised);
|
||||
|
||||
config.RemoveBackground = false; // turning the INACTIVE pill off changes nothing
|
||||
Assert.Equal(BackgroundEffect.Blur, config.BackgroundEffect);
|
||||
|
||||
config.BlurBackground = false; // turning the active pill off = None
|
||||
Assert.Equal(BackgroundEffect.None, config.BackgroundEffect);
|
||||
Assert.False(config.HasBackgroundEffect);
|
||||
|
||||
// Wiring: the two PillToggle switches + the strength slider live in the webcam's
|
||||
// properties section of the Layers panel, bound to those properties.
|
||||
XNamespace x = "http://schemas.microsoft.com/winfx/2006/xaml";
|
||||
var doc = XDocument.Load(SourceAssert.RepoPath("Controls", "LeftPanel.xaml"));
|
||||
var webcamPanel = doc.Descendants()
|
||||
.Single(e => e.Name.LocalName == "StackPanel"
|
||||
&& ((string?)e.Attribute("Visibility") ?? "").Contains("SelectedElement.IsWebcam"));
|
||||
|
||||
XElement Named(string name) => webcamPanel.Descendants().Single(e => (string?)e.Attribute(x + "Name") == name);
|
||||
|
||||
foreach (var (pill, property) in new[] { ("RemoveBackgroundPill", "RemoveBackground"), ("BlurBackgroundPill", "BlurBackground") })
|
||||
{
|
||||
var toggle = Named(pill);
|
||||
Assert.Equal("ToggleButton", toggle.Name.LocalName);
|
||||
Assert.Contains("PillToggle", (string?)toggle.Attribute("Style"));
|
||||
Assert.Contains($"SelectedElement.{property}", (string?)toggle.Attribute("IsChecked"));
|
||||
Assert.Contains("TwoWay", (string?)toggle.Attribute("IsChecked"));
|
||||
}
|
||||
|
||||
var slider = Named("BackgroundStrengthSlider");
|
||||
Assert.Contains("SelectedElement.BackgroundStrength", (string?)slider.Attribute("Value"));
|
||||
Assert.Equal("0", (string?)slider.Attribute("Minimum"));
|
||||
Assert.Equal("1", (string?)slider.Attribute("Maximum"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user