f5a9d46881
The credit existed only as a WPF BrandFlashLayer TextBlock in the preview at 25% opacity on a 300s timer. A viewer of the stream or the recording never saw it, so "free tier shows branding" was not actually being delivered. The frame pump has carried an unused per-frame flashFrame slot for exactly this. Reverses the documented "Pre-GA posture" (ai.md Monetization), which kept the flash preview-only so test VODs stayed clean. Creator ruling 2026-09-26: the free tier has to be honest advertising, so it now reaches the broadcast. One rendered VideoFrame feeds BOTH the frame pump and the preview, so the creator's view cannot drift from what viewers get. Spec: 500ms in / 1000ms hold / 500ms out, first credit ~5s after go-live then every rand(30s)+30s, single unwrapped line at a random spot inside the frame every time, neon white core with a feathered red/blue halo. Neon recipe is derivative work, per AGENTS.md: bright core + feathered multi-radius halo with R and B split in opposite directions, from https://nudaui.dev/components/neon-glow (layered text-shadow falloff), https://help.maxon.net/rg/en-us/Content/html/Blurs-and-Glows-chromatic-glow.html ("with no displacement, the green channel is all but invisible behind your white text" once R and B are split) and the OBS obs-stroke-glow-shadow "feathered stroke with user-defined size and intensity". Neon blue is #4d8bff rather than the theme's #0f3460, which renders near-black as a halo. Also fixes a PRE-EXISTING bug found on the way: FramePump's fully-static shortcut stretched the cached bake and returned it, silently discarding every per-frame overlay - the social bar and the alert ticker were already lost there. SceneCompositor.Overlay is now internal (it copies before blitting, so the bake is never mutated) and the shortcut composites overlays first. The credit is deliberately NOT folded into SceneGraph.GetBakedBase: SceneRegion.Matches compares element ids only, so a credit in the cached bake would freeze there and never expire. Per-frame only, and Epoch is stamped every read because the 8MB master buffer is recycled - without that the paste cache would freeze a stale credit. BrandFlashEnabled is now derived !IsPremium and non-assignable, and the presenter re-checks the licence on every read, so a key entered mid-credit cuts the advertisement on the next tick instead of letting it finish. Tests: 10 new facts. 357 total, 356 pass; the one failure is the known environment-flaky RealMouseDrag layer test (needs an uncovered desktop session). Adds RealAppHost.RunAsync - a frame-pump test must await inside the collection's shared STA thread or the whole suite deadlocks silently. NOTE: scope-check.sh flags Helpers/InstanceProfile.cs, AppLog.cs, TokenStore.cs, WebView2Manager.cs and InstanceIsolationTests.cs as outside this commit. That is a false positive: it uses `git diff HEAD`, which cannot distinguish a planned second commit in the same session from an unrelated edit. Those files are the dev multi-instance unit, committed immediately after this one - as is the InstanceProfile paragraph in ai.md, which shares a file with the Monetization section corrected here.
110 lines
3.3 KiB
C#
110 lines
3.3 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Windows.Threading;
|
|
using Xunit;
|
|
|
|
namespace ytLive.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests that spin up the real WPF App need exactly one Application instance per
|
|
/// AppDomain (WPF enforces it) — so they share this serial collection and a
|
|
/// single App created on one dedicated STA thread. Marshal test bodies onto it
|
|
/// via <see cref="RealAppHost.Run"/>, never `new App()` per test.
|
|
/// </summary>
|
|
[CollectionDefinition("RealApp", DisableParallelization = true)]
|
|
public sealed class RealAppCollection : ICollectionFixture<RealAppHost>
|
|
{
|
|
}
|
|
|
|
/// <summary>Owns the one-and-only WPF App on a dedicated STA thread.</summary>
|
|
public sealed class RealAppHost : IDisposable
|
|
{
|
|
private readonly Thread _thread;
|
|
private readonly Dispatcher _dispatcher;
|
|
|
|
public RealAppHost()
|
|
{
|
|
Exception? boot = null;
|
|
Dispatcher? dispatcher = null;
|
|
_thread = new Thread(() =>
|
|
{
|
|
try
|
|
{
|
|
var app = new App();
|
|
app.InitializeComponent();
|
|
dispatcher = Dispatcher.CurrentDispatcher;
|
|
Dispatcher.Run();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
boot = ex;
|
|
}
|
|
});
|
|
_thread.SetApartmentState(ApartmentState.STA);
|
|
_thread.Start();
|
|
while (dispatcher == null && boot == null)
|
|
Thread.Sleep(5);
|
|
if (boot != null)
|
|
throw new Xunit.Sdk.XunitException("Real WPF App failed to start: " + boot);
|
|
_dispatcher = dispatcher!;
|
|
}
|
|
|
|
/// <summary>Runs <paramref name="action"/> on the App's STA thread and rethrows any failure.</summary>
|
|
public void Run(Action action)
|
|
{
|
|
Exception? failure = null;
|
|
_dispatcher.Invoke(() =>
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
failure = ex;
|
|
}
|
|
});
|
|
if (failure != null)
|
|
throw failure;
|
|
}
|
|
|
|
/// <summary>Awaits <paramref name="action"/> on the App's STA thread and rethrows
|
|
/// any failure.
|
|
/// <para>A test that drives the frame pump MUST use this and <c>await</c> — never
|
|
/// <c>Run()</c> around a blocking wait. <see cref="Run"/> occupies the one STA
|
|
/// thread this collection shares, so a blocking call inside it deadlocks the pump
|
|
/// against the dispatcher and hangs the entire run with no output: the frame pump's
|
|
/// <c>StartAsync</c> needs to keep pumping while the test waits for a frame. Awaiting
|
|
/// yields the thread instead of holding it.</para></summary>
|
|
public async Task RunAsync(Func<Task> action)
|
|
{
|
|
Exception? failure = null;
|
|
await _dispatcher.InvokeAsync(async () =>
|
|
{
|
|
try
|
|
{
|
|
await action();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
failure = ex;
|
|
}
|
|
});
|
|
if (failure != null)
|
|
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(failure).Throw();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
try
|
|
{
|
|
_dispatcher.InvokeShutdown();
|
|
}
|
|
catch
|
|
{
|
|
// The App never ran its message loop — shutdown is best-effort.
|
|
}
|
|
_thread.Join(2000);
|
|
}
|
|
}
|