Class UnityHudHostComponentTests
PlayMode tests for the two pieces the game uses that the preview never touches: the widget-context
constructor of HudRenderResources, and UnityHudHostComponent driving a HUD
through a service locator.
Inheritance
UnityHudHostComponentTests
Assembly: Tests.dll
Syntax
public class UnityHudHostComponentTests
Constructors
UnityHudHostComponentTests()
Declaration
public UnityHudHostComponentTests()
Methods
Clear_RemovesEverythingItBuilt()
Declaration
public IEnumerator Clear_RemovesEverythingItBuilt()
Returns
Clear_ResetsHiddenElementState()
Declaration
public IEnumerator Clear_ResetsHiddenElementState()
Returns
Dispatch_HideHudElementSignal_HidesOnlyThatElement()
Declaration
public IEnumerator Dispatch_HideHudElementSignal_HidesOnlyThatElement()
Returns
Dispatch_HideHudElementSignal_WithMismatchedHudId_IsIgnored()
Declaration
public IEnumerator Dispatch_HideHudElementSignal_WithMismatchedHudId_IsIgnored()
Returns
Dispatch_HideHudElementSignal_WithNoHudShown_IsIgnored()
Declaration
public IEnumerator Dispatch_HideHudElementSignal_WithNoHudShown_IsIgnored()
Returns
Dispatch_ShowHudElementSignal_AfterHide_ReShowsOnlyThatElement()
Declaration
public IEnumerator Dispatch_ShowHudElementSignal_AfterHide_ReShowsOnlyThatElement()
Returns
HiddenElement_DoesNotLeakToADifferentHudSharingTheSameElementId()
Regression test for the cross-HUD leak the fresh review caught: hidden state used to be a flat
element-id set with no HUD component, so hiding "ammo" on one HUD silently started a DIFFERENT
HUD's own "ammo" element hidden too, the first time it was built.
Declaration
public IEnumerator HiddenElement_DoesNotLeakToADifferentHudSharingTheSameElementId()
Returns
HiddenElement_StaysHiddenAcrossHideThenShowSameHud()
Declaration
public IEnumerator HiddenElement_StaysHiddenAcrossHideThenShowSameHud()
Returns
HiddenElement_StaysHiddenAcrossSwitchingHudsAndBack()
Declaration
public IEnumerator HiddenElement_StaysHiddenAcrossSwitchingHudsAndBack()
Returns
HideHud_ThenShowAgain_RebuildsWithoutDuplicating()
Teardown goes through Object.Destroy, which in play mode is deferred to the end of the frame.
Asserting on the object graph in the same frame reads the objects as still there — a test written that
way fails against correct code, or worse, passes by comparing two equally stale counts.
Declaration
public IEnumerator HideHud_ThenShowAgain_RebuildsWithoutDuplicating()
Returns
HudRenderResources_FromANullContext_DegradesInsteadOfThrowing()
Declaration
public void HudRenderResources_FromANullContext_DegradesInsteadOfThrowing()
HudRenderResources_FromAWidgetContext_ResolvesTheThemeTextStyle()
The constructor the game uses, as opposed to the theme-only one the preview uses. Both resolve the
theme's lettering, but only this one goes through the widget context — so following the theme could
have worked in the preview and silently not in the game.
Declaration
public void HudRenderResources_FromAWidgetContext_ResolvesTheThemeTextStyle()
HudRenderResources_FromAnEmptyContext_DegradesInsteadOfThrowing()
Declaration
public void HudRenderResources_FromAnEmptyContext_DegradesInsteadOfThrowing()
RegisterHud_WithNull_DoesNotThrow()
Declaration
public void RegisterHud_WithNull_DoesNotThrow()
SetUp()
Declaration
ShowHud_AuthoredHudTakesPrecedenceOverProvider_ProviderIsNeverAsked()
Declaration
public void ShowHud_AuthoredHudTakesPrecedenceOverProvider_ProviderIsNeverAsked()
ShowHud_BuildsTheElementsAndBindsThemToLiveServices()
Declaration
public void ShowHud_BuildsTheElementsAndBindsThemToLiveServices()
ShowHud_NoProviderRegistered_DoesNotThrowAndStillWarns()
Declaration
public void ShowHud_NoProviderRegistered_DoesNotThrowAndStillWarns()
ShowHud_ProviderOnlyId_BuildsTheHud()
The regression test: with nothing scene-authored at all, a HUD known only to the provider must
still build — this is the fully no-code flow (HUD Builder → generated ShowTrigger → play) that
silently showed nothing before UnityHudHostComponent ever consulted a provider.
Declaration
public void ShowHud_ProviderOnlyId_BuildsTheHud()
ShowHud_ProviderResolvedByGuid_IsAskedOnlyOnceAcrossRepeatedShowsByGuid()
Regression test: the cached-authored lookup used to match only Id, so a HUD resolved and
shown by Guid re-queried the provider on every repeat show even though it was already cached.
Declaration
public void ShowHud_ProviderResolvedByGuid_IsAskedOnlyOnceAcrossRepeatedShowsByGuid()
ShowHud_ProviderResolvedId_IsAskedOnlyOnceAcrossRepeatedShows()
Declaration
public void ShowHud_ProviderResolvedId_IsAskedOnlyOnceAcrossRepeatedShows()
ShowHud_TwoDifferentUnresolvableIds_WarnsTwice()
Declaration
public void ShowHud_TwoDifferentUnresolvableIds_WarnsTwice()
ShowHud_UnresolvableId_WarnsExactlyOnceAcrossRepeatedCalls()
Declaration
public void ShowHud_UnresolvableId_WarnsExactlyOnceAcrossRepeatedCalls()
ShowHud_WithAnUnknownId_DoesNotThrow()
Declaration
public void ShowHud_WithAnUnknownId_DoesNotThrow()
ShowHud_WithNoLocatorAtAll_DoesNotThrow()
Declaration
public void ShowHud_WithNoLocatorAtAll_DoesNotThrow()
TearDown()
Declaration
ValueTrigger_OneWatchedElement_FansOutToMultipleOwners()
Declaration
public IEnumerator ValueTrigger_OneWatchedElement_FansOutToMultipleOwners()
Returns
ValueTrigger_RebuildingTheHud_DoesNotLeakOldSubscriptionsOrDoubleFire()
Regression guard for a rebuild leaking stale watcher registrations: if TearDownElements ever
stopped clearing _animationValueWatchers, a second build would ADD a second (owner, entry)
pair for the new "healthFlash" view on top of the first (torn-down) one, and a single Points change
would fire twice instead of once.
Declaration
public IEnumerator ValueTrigger_RebuildingTheHud_DoesNotLeakOldSubscriptionsOrDoubleFire()
Returns
ValueTrigger_WatchingAnotherElement_FiresOnThatElementsChange_NotItsOwn()
Declaration
public IEnumerator ValueTrigger_WatchingAnotherElement_FiresOnThatElementsChange_NotItsOwn()
Returns
ValueTrigger_WithUnresolvableWatchedId_BuildsWithoutThrowing()
Declaration
public void ValueTrigger_WithUnresolvableWatchedId_BuildsWithoutThrowing()
ValueTrigger_WithUnresolvableWatchedId_WarnsOnlyOnceAcrossRebuilds()
Declaration
public void ValueTrigger_WithUnresolvableWatchedId_WarnsOnlyOnceAcrossRebuilds()