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.
114 lines
4.6 KiB
C#
114 lines
4.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Data.Sqlite;
|
|
using Xunit;
|
|
using ytLive.Models;
|
|
using ytLive.Services;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// Top bar redesign — the bar is ONE surface rendered by the FIRST decision
|
|
/// (Record or Stream). Each world is the whole bar: Test is a child of Stream,
|
|
/// but the account zone (Sign In / avatar) is WORLD-INDEPENDENT (creator
|
|
/// 2026-09-23) so the right column never pops in and out and the bar height
|
|
/// stays pinned. The switch is a two-position gate, so "going back" is one tap
|
|
/// on the other segment. While running, the switch retires and a single reality
|
|
/// line (dot + word + elapsed) + End replace it.
|
|
/// </summary>
|
|
[Collection("RealApp")]
|
|
public sealed class TopBarModeTests
|
|
{
|
|
private readonly RealAppHost _app;
|
|
|
|
public TopBarModeTests(RealAppHost app) => _app = app;
|
|
|
|
[Fact]
|
|
public void TopBar_Renders_Only_The_Armed_World()
|
|
{
|
|
_app.Run(Run);
|
|
}
|
|
|
|
private void Run()
|
|
{
|
|
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-topbar-{Guid.NewGuid():N}.db");
|
|
MainViewModel.LayoutPathOverride = tempDb;
|
|
try
|
|
{
|
|
using (var schema = new LayoutStore(tempDb)) { }
|
|
SqliteConnection.ClearAllPools();
|
|
|
|
var vm = new MainViewModel();
|
|
|
|
// The dev machine may hold a real saved OAuth session (loads synchronously
|
|
// during the ctor), so the sign-in state is forced deterministically.
|
|
vm.IsConnected = false;
|
|
vm.EditingActive = false; // EDIT off selects Go Live instead of Test Stream.
|
|
|
|
// Default (nothing armed) = the Record world: Go says "Start Recording",
|
|
// no Test — but the account zone is app-level and stays (signed out →
|
|
// Sign In visible even here; no avatar).
|
|
Assert.True(vm.ShowIdleWorld);
|
|
Assert.True(vm.ShowRecordAction);
|
|
Assert.False(vm.ShowStreamActions);
|
|
Assert.True(vm.ShowSignInButton);
|
|
Assert.False(vm.ShowAvatarButton);
|
|
Assert.False(vm.ShowTestButton);
|
|
Assert.Equal("Start Recording", vm.PrimaryStartButtonLabel);
|
|
|
|
// Arming ON-AIR switches the whole bar to the Stream world.
|
|
vm.OnAirPillOn = true;
|
|
Assert.False(vm.ShowRecordAction);
|
|
Assert.True(vm.ShowStreamActions);
|
|
|
|
// Signed out: the account zone shows Sign In; no avatar; Test is gated
|
|
// behind the sign-in (Test rides on Stream AND a connected account).
|
|
Assert.True(vm.ShowSignInButton);
|
|
Assert.False(vm.ShowAvatarButton);
|
|
Assert.False(vm.ShowTestButton);
|
|
Assert.Equal("Go Live", vm.PrimaryStartButtonLabel);
|
|
|
|
// Connected: avatar + Test join the Stream world; Sign In retires.
|
|
vm.IsConnected = true;
|
|
Assert.False(vm.ShowSignInButton);
|
|
Assert.True(vm.ShowAvatarButton);
|
|
Assert.True(vm.ShowTestButton);
|
|
|
|
// Going back is one tap: flipping REC returns the bar to the Record world —
|
|
// the avatar STAYS (world-independent account zone), only Test retires.
|
|
vm.RecordPillOn = true;
|
|
Assert.False(vm.ShowStreamActions);
|
|
Assert.True(vm.ShowRecordAction);
|
|
Assert.True(vm.ShowAvatarButton);
|
|
Assert.False(vm.ShowTestButton);
|
|
Assert.Equal("Start Recording", vm.PrimaryStartButtonLabel);
|
|
|
|
// A local recording lives in the Record activity (2026-11-13): the bar keeps its three
|
|
// buttons and the Record one carries REC + the clock + Stop, so the separate reality line
|
|
// stays away — it would be a second set of the same facts.
|
|
vm.OpenRecordCommand.Execute(null);
|
|
vm.StartRecordingCommand.Execute(null);
|
|
Assert.True(vm.IsRecordRecording);
|
|
Assert.False(vm.RunningVisible);
|
|
Assert.StartsWith("REC: ", vm.RecordElapsedLabel);
|
|
vm.StopRecordingCommand.Execute(null);
|
|
|
|
// A live stream is the YouTube slot's flow; the reality line pins the mode.
|
|
vm.StreamStatus = StreamStatus.Streaming;
|
|
Assert.True(vm.RunningVisible);
|
|
Assert.Equal("LIVE", vm.RunningText);
|
|
Assert.Equal("#ff5451", vm.RunningDotBrush);
|
|
vm.IsTestStream = true;
|
|
Assert.Equal("TEST", vm.RunningText);
|
|
Assert.Equal("#9c6f1c", vm.RunningDotBrush);
|
|
}
|
|
finally
|
|
{
|
|
MainViewModel.LayoutPathOverride = null;
|
|
SqliteConnection.ClearAllPools();
|
|
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
|
}
|
|
}
|
|
}
|