Skip to content

fix: Exclude test for rising animation state count during runtime builds #2241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ private void Awake()
m_NetworkAnimator = GetComponent<NetworkAnimator>();
}

// Since the com.unity.netcode.components does not allow test project to access its internals
// during runtime, this is only used when running test runner from within the editor
#if UNITY_EDITOR
internal int GetAnimatorStateCount()
{
return m_NetworkAnimator.GetAnimationMessage().AnimationStates.Count;
}
#endif

public override void OnNetworkSpawn()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,13 @@ public IEnumerator TriggerUpdateTests([Values] OwnerShipMode ownerShipMode, [Val
AssertOnTimeout($"Timed out waiting for the client-side instance of {GetNetworkAnimatorName(authoritativeMode)} to be spawned!");
var animatorTestHelper = ownerShipMode == OwnerShipMode.ClientOwner ? AnimatorTestHelper.ClientSideInstances[m_ClientNetworkManagers[0].LocalClientId] : AnimatorTestHelper.ServerSideInstance;
var layerCount = animatorTestHelper.GetAnimator().layerCount;
var animationStateCount = animatorTestHelper.GetAnimatorStateCount();

// Since the com.unity.netcode.components does not allow test project to access its internals
// during runtime, this is only used when running test runner from within the editor
#if UNITY_EDITOR
var animationStateCount = animatorTestHelper.GetAnimatorStateCount();
Assert.True(layerCount == animationStateCount, $"AnimationState count {animationStateCount} does not equal the layer count {layerCount}!");
#endif
if (authoritativeMode == AuthoritativeMode.ServerAuth)
{
animatorTestHelper = AnimatorTestHelper.ServerSideInstance;
Expand Down Expand Up @@ -304,7 +308,9 @@ public IEnumerator TriggerUpdateTests([Values] OwnerShipMode ownerShipMode, [Val
// Verify we only entered each state once
yield return WaitForConditionOrTimeOut(() => CheckStateEnterCount.AllStatesEnteredMatch(clientIdList));
AssertOnTimeout($"Timed out waiting for all states entered to match!");

// Since the com.unity.netcode.components does not allow test project to access its internals
// during runtime, this is only used when running test runner from within the editor
#if UNITY_EDITOR
// Now, update some states for several seconds to assure the AnimationState count does not grow
var waitForSeconds = new WaitForSeconds(0.25f);
bool rotateToggle = true;
Expand All @@ -317,7 +323,7 @@ public IEnumerator TriggerUpdateTests([Values] OwnerShipMode ownerShipMode, [Val
yield return waitForSeconds;
rotateToggle = !rotateToggle;
}

#endif
AnimatorTestHelper.IsTriggerTest = false;
VerboseDebug($" ------------------ Trigger Test [{TriggerTest.Iteration}][{ownerShipMode}] Stopping ------------------ ");
}
Expand Down