Files
LlamaCasty/ytLive.Tests/TopBarSlotTests.cs
T
gramps 69f08a478e feat(topbar): three fixed slots — every state changes inside its own slot
Creator correction (2026-11-13): "OpenCode literally inserted Live and Private as two extra flat siblings
inside the outer pill bar, shoving Record to the right and making it look like five ungrouped toolbar
items". Correct — completion states were being added to the BAR instead of to a SLOT.

Now the bar is exactly three slots, and the bar's shape never changes:

  [ Build Scenes ]   [ YouTube ]   [ Record ]

  YouTube:  ▶ YouTube -> [Live | Private | ✕] -> [● Start Live | ✕] (amber: next click goes on air)
            -> [■ Stop Live]
  Record:   ◉ Record  -> [● Start Recording | ✕] -> ● REC hh:mm:ss [■ Stop]
  Build:    enabled only while BOTH action slots are Idle; otherwise disabled at 40% with the tooltip
            "Scene editing is locked while streaming or recording"

State lives in YouTubeSlotState / RecordSlotState, with one RaiseSlotStates() announcing every flag so no
caller can forget one. Esc and the ✕ cancel the slot you are in and nothing else.

This retires the BarWorld model from earlier today, along with TopBarActivityTests (superseded by
TopBarSlotTests, which pins all three flows, the lock, and cancel-to-Idle).

679 pass, 0 failed (the host-hang fallback in f4caea0 counted the per-test lines).
Scope justification: TopBarActivityTests.cs is deleted as part of this unit — it tested the model being
replaced; TopBarSlotTests is its successor.
2026-11-13 12:20:11 -08:00

69 lines
2.5 KiB
C#

using System;
using System.IO;
using Xunit;
using ytLive.ViewModels;
namespace ytLive.Tests;
/// <summary>
/// The bar is three FIXED SLOTS (creator, 2026-11-13). Each slot owns its own flow and mutates only its
/// own interior, so neighbouring buttons never move; and while either action slot is past Idle, Build
/// Scenes is locked.
/// </summary>
[Collection("MainViewModelLayoutPath")]
public class TopBarSlotTests
{
[Fact]
public void Each_slot_runs_its_own_flow_in_place_and_build_locks_while_they_do()
{
var db = Path.Combine(Path.GetTempPath(), $"llamacasty-slots-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = db;
try
{
var vm = new MainViewModel();
// All three idle: YouTube and Record are single buttons, Build is live.
Assert.True(vm.IsYouTubeIdle);
Assert.True(vm.IsRecordIdle);
Assert.True(vm.IsBuildScenesEnabled);
Assert.Contains("Edit layers", vm.BuildScenesTooltip);
// YouTube: idle -> choose privacy -> armed -> (start) streaming.
vm.OpenYouTubeCommand.Execute(null);
Assert.True(vm.IsYouTubeChoosingPrivacy);
Assert.False(vm.IsBuildScenesEnabled);
Assert.Contains("locked", vm.BuildScenesTooltip);
vm.ChoosePrivateCommand.Execute(null);
Assert.True(vm.IsYouTubeArmed);
Assert.Equal("Start Private", vm.YouTubeArmLabel);
vm.ChooseLiveCommand.Execute(null); // switching choice while armed is allowed
Assert.Equal("Start Live", vm.YouTubeArmLabel);
// Cancel returns that slot to Idle — and Build unlocks because both slots are idle again.
vm.CancelYouTubeCommand.Execute(null);
Assert.True(vm.IsYouTubeIdle);
Assert.True(vm.IsBuildScenesEnabled);
// Record: idle -> armed -> (start) recording, with the clock carrying REC.
vm.OpenRecordCommand.Execute(null);
Assert.True(vm.IsRecordArmed);
Assert.False(vm.IsBuildScenesEnabled);
vm.StartRecordingCommand.Execute(null);
Assert.True(vm.IsRecordRecording);
Assert.StartsWith("REC: ", vm.RecordElapsedLabel);
vm.StopRecordingCommand.Execute(null);
Assert.True(vm.IsRecordIdle);
Assert.True(vm.IsBuildScenesEnabled);
}
finally
{
MainViewModel.LayoutPathOverride = null;
try { File.Delete(db); } catch (IOException) { }
}
}
}