The first commit converted the four members the issue named and left the other sites alone, reasoning that none had been observed failing. A 20-run complete-solution baseline disproved that within minutes: run 2 LiveEntityRuntimeTests.AnimationView_HotSpatialTraversal… run 14 StaticRenderProjectionJournalTests.ActiveAnimatedSynchronization… run 18 StaticRenderProjectionJournalTests.ActiveAnimatedSynchronization… run 19 CurrentRenderSceneOracleTests.SurfaceOverrideFingerprint… Both new names are the same shape as the four — one warm call, then a thousand-iteration loop inside the measured window — and neither had been recorded anywhere. "Not observed failing" only ever meant "not yet observed", and leaving known-shape sites in place would have guaranteed the acceptance gate failed. Run 19 is the sharper lesson: the issue named `SurfaceOverrideFingerprint_DictionaryHotPathAllocatesNothing`, and the first commit converted a *different* test in that same file, so the actually-named member was still on the old shape. Matching by file was not matching by test. Every strict-zero site in the assembly is now on the probe — ten tests. Two came out stricter rather than merely steadier: `StaticRenderProjectionJournalTests` was measuring a synchronise whose journal does **not** coalesce. Repeating it grew the journal by 1,000 entries per call — 192,000 by the end of a probe run — so the steady state the test claimed to measure did not exist and the single-call window had been hiding it. Its step is now the whole frame cycle, synchronise *and* drain, which puts `DrainTo` inside the measured window for the first time and asserts the journal ends empty. `RetailInboundEventDispatcherTests` asserted a hard-coded 1,001 callbacks. It now counts its own dispatches and pins the callback count against that, so the assertion still proves the fast path ran the callback every time without being coupled to a loop bound that no longer exists. Left alone deliberately: the four sites asserting a tolerance rather than zero — `CellViewDedupTests` and `PortalProjectionTests`. Their ceilings already absorb this noise and none has flaked; changing a bound in either direction is a separate decision from fixing a measurement. Worth noting that `PortalProjectionTests`' ceiling exists explicitly to tolerate "a tiered-JIT/ArrayPool bookkeeping transition ... to the first measured batch", which is exactly what the probe removes, so it could probably be tightened to zero now — recorded in the issue rather than done here. Solution build 0 warnings / 0 errors; App suite 3,941 passed / 3 skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using AcDream.App.UI;
|
|
using AcDream.App.UI.Layout;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
public sealed class UiTextLayoutCacheTests
|
|
{
|
|
[Fact]
|
|
public void Stable_content_and_layout_borrow_same_shaped_lines()
|
|
{
|
|
var text = new UiText { Width = 120f };
|
|
int shapes = 0;
|
|
var cache = new UiTextLayoutCache<string>(
|
|
text,
|
|
(target, value) =>
|
|
{
|
|
shapes++;
|
|
return IndicatorDetailText.Shape(target, value);
|
|
},
|
|
"alpha beta gamma",
|
|
StringComparer.Ordinal);
|
|
|
|
IReadOnlyList<UiText.Line> first = cache.GetLines();
|
|
IReadOnlyList<UiText.Line> second = cache.GetLines();
|
|
|
|
Assert.Same(first, second);
|
|
Assert.Equal(1, shapes);
|
|
|
|
cache.SetValue(new string("alpha beta gamma".ToCharArray()));
|
|
Assert.Same(first, cache.GetLines());
|
|
Assert.Equal(1, shapes);
|
|
}
|
|
|
|
[Fact]
|
|
public void Content_width_and_font_inputs_invalidate_shaping()
|
|
{
|
|
var text = new UiText { Width = 120f };
|
|
int shapes = 0;
|
|
var cache = new UiTextLayoutCache<string>(
|
|
text,
|
|
(target, value) =>
|
|
{
|
|
shapes++;
|
|
return IndicatorDetailText.Shape(target, value);
|
|
},
|
|
"alpha beta gamma",
|
|
StringComparer.Ordinal);
|
|
|
|
IReadOnlyList<UiText.Line> first = cache.GetLines();
|
|
cache.SetValue("delta epsilon");
|
|
IReadOnlyList<UiText.Line> changed = cache.GetLines();
|
|
text.Width = 48f;
|
|
IReadOnlyList<UiText.Line> resized = cache.GetLines();
|
|
|
|
Assert.NotSame(first, changed);
|
|
Assert.NotSame(changed, resized);
|
|
Assert.Equal(3, shapes);
|
|
}
|
|
|
|
[Fact]
|
|
public void Stable_provider_poll_allocates_no_managed_memory()
|
|
{
|
|
var text = new UiText { Width = 120f };
|
|
var cache = new UiTextLayoutCache<string>(
|
|
text,
|
|
static (target, value) => IndicatorDetailText.Shape(target, value),
|
|
"alpha beta gamma",
|
|
StringComparer.Ordinal);
|
|
Func<IReadOnlyList<UiText.Line>> provider = cache.Provider;
|
|
_ = provider();
|
|
|
|
// #250: the measured window was a 1,000-iteration loop written inline.
|
|
ZeroAllocationProbe.AssertAllocatesNothing(
|
|
"UiTextLayoutCache stable provider poll",
|
|
() => _ = provider());
|
|
}
|
|
}
|