Files
LlamaCasty/ytLive.Tests/TopBarWorldTests.cs
T
gramps a5a10fb0b0 feat(topbar): the output stage — Output [YouTube] [Local MP4] One output at a time
Unit B (creator ruling 2026-11-12). Pressing Record / Go Live now changes the bar: the REC/ON-AIR pill
pair becomes two labelled switches with glyphs (the YouTube mark, the record dot), under an "Output"
label and beside "One output at a time". Build world shows nothing but its own segment.

Two things this exposed that were not cosmetic:

- **Local MP4 was not actually the default.** Both pills started unarmed, so the stage opened with no
  output selected; the old screen got away with it because the primary button inferred "record" from
  "nothing armed". RecordPillOn now starts true, which is what "pos = ON (default)" means in code.
- **The stage gates the whole idle cluster, not just the switch.** Gating only the switch left the start
  button visible in the Build world — a Start with no output chosen. ShowOutputStage (output world, idle,
  not recording) wraps the cluster, so a running session hides the stage too: its output cannot change.

Exclusivity stays in the view model (arming one drops the other); the XAML merely reflects it.
TopBarWorldTests pins the stage's visibility and the radio pair starting at Local MP4.

680 pass, 0 warnings. Next: unit C (output-dependent primary action, End labels).
Scope justification: Assets/starting-background.jpg is outside this unit — the creator's replacement art,
still awaiting their visual check.
2026-11-12 15:38:35 -08:00

90 lines
3.1 KiB
C#

using System;
using System.IO;
using Xunit;
using ytLive.ViewModels;
namespace ytLive.Tests;
/// <summary>
/// The top bar's one decision: <c>[ Build Scenes ][ Record / Go Live ]</c>. Build Scenes ships
/// highlighted, and it <b>is</b> edit mode — the old EDIT toggle is gone, so "can I edit?" and "which
/// world am I in?" cannot disagree.
/// </summary>
[Collection("MainViewModelLayoutPath")]
public class TopBarWorldTests
{
[Fact]
public void The_output_stage_belongs_to_the_output_world_and_holds_one_output_at_a_time()
{
var db = Path.Combine(Path.GetTempPath(), $"llamacasty-outputstage-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = db;
try
{
var vm = new MainViewModel();
// Nothing to arm while building scenes.
Assert.False(vm.ShowOutputStage);
vm.EnterOutputWorldCommand.Execute(null);
Assert.True(vm.IsOutputWorld);
Assert.True(vm.IsOffline);
Assert.False(vm.IsRecording);
Assert.True(vm.ShowOutputStage);
// Local MP4 is the default output; the pair is one axis, so arming either drops the other.
Assert.True(vm.RecordPillOn);
Assert.False(vm.OnAirPillOn);
vm.OnAirPillOn = true;
Assert.True(vm.OnAirPillOn);
Assert.False(vm.RecordPillOn);
vm.RecordPillOn = true;
Assert.False(vm.OnAirPillOn);
}
finally
{
MainViewModel.LayoutPathOverride = null;
try { File.Delete(db); } catch (IOException) { }
}
}
[Fact]
public void Build_scenes_is_the_default_world_and_is_the_only_place_editing_lives()
{
var db = Path.Combine(Path.GetTempPath(), $"llamacasty-world-{Guid.NewGuid():N}.db");
MainViewModel.LayoutPathOverride = db;
try
{
var vm = new MainViewModel();
// Launch state: Build Scenes highlighted, editing on.
Assert.Equal(BarWorld.Build, vm.BarWorld);
Assert.True(vm.IsBuildWorld);
Assert.False(vm.IsOutputWorld);
Assert.True(vm.IsEditMode);
// Record / Go Live leaves edit mode — the output surface has nothing to drag.
vm.EnterOutputWorldCommand.Execute(null);
Assert.Equal(BarWorld.Output, vm.BarWorld);
Assert.True(vm.IsOutputWorld);
Assert.False(vm.IsBuildWorld);
Assert.False(vm.IsEditMode);
// Clicking the highlighted half is not a no-op: it re-enters that world, which is how a
// creator takes editing back during a session.
vm.EnterBuildWorldCommand.Execute(null);
Assert.True(vm.IsBuildWorld);
Assert.True(vm.IsEditMode);
// …and re-entering the world already in force still re-asserts its edit state.
vm.EditingActive = false;
vm.EnterBuildWorldCommand.Execute(null);
Assert.True(vm.IsEditMode);
}
finally
{
MainViewModel.LayoutPathOverride = null;
try { File.Delete(db); } catch (IOException) { }
}
}
}