Skip to content

Commit 55a0e87

Browse files
test
Updating NetworkTransformGeneral to test all interpolator types and adding a means to getting verbose debug logs,
1 parent 2d53a3a commit 55a0e87

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public enum SceneManagementState
3838
}
3939

4040
private StringBuilder m_InternalErrorLog = new StringBuilder();
41+
protected StringBuilder m_VerboseDebugLog = new StringBuilder();
4142

4243
/// <summary>
4344
/// Registered list of all NetworkObjects spawned.
@@ -257,6 +258,7 @@ protected void VerboseDebug(string msg)
257258
{
258259
if (m_EnableVerboseDebug)
259260
{
261+
m_VerboseDebugLog.AppendLine(msg);
260262
Debug.Log(msg);
261263
}
262264
}
@@ -345,6 +347,7 @@ protected virtual void OnInlineSetup()
345347
[UnitySetUp]
346348
public IEnumerator SetUp()
347349
{
350+
m_VerboseDebugLog.Clear();
348351
VerboseDebug($"Entering {nameof(SetUp)}");
349352
NetcodeLogAssert = new NetcodeLogAssert();
350353
if (m_EnableTimeTravel)

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformGeneral.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace Unity.Netcode.RuntimeTests
88
[TestFixture(HostOrServer.Host, Authority.ServerAuthority, NetworkTransform.InterpolationTypes.Lerp)]
99
[TestFixture(HostOrServer.Host, Authority.OwnerAuthority, NetworkTransform.InterpolationTypes.SmoothDampening)]
1010
[TestFixture(HostOrServer.Host, Authority.ServerAuthority, NetworkTransform.InterpolationTypes.SmoothDampening)]
11+
[TestFixture(HostOrServer.Host, Authority.OwnerAuthority, NetworkTransform.InterpolationTypes.LerpExtrapolateBlend)]
12+
[TestFixture(HostOrServer.Host, Authority.ServerAuthority, NetworkTransform.InterpolationTypes.LerpExtrapolateBlend)]
1113
internal class NetworkTransformGeneral : NetworkTransformBase
1214
{
1315
public NetworkTransformGeneral(HostOrServer testWithHost, Authority authority, NetworkTransform.InterpolationTypes interpolationType) :
@@ -298,20 +300,20 @@ public void NonAuthorityOwnerSettingStateTest([Values] Interpolation interpolati
298300
var newScale = new Vector3(2.0f, 2.0f, 2.0f);
299301
m_NonAuthoritativeTransform.SetState(newPosition, null, null, interpolate);
300302
success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionsMatchesValue(newPosition), 800);
301-
Assert.True(success, $"Timed out waiting for non-authoritative position state request to be applied!");
303+
Assert.True(success, $"Timed out waiting for non-authoritative position state request to be applied!\n {m_VerboseDebugLog}");
302304
Assert.True(Approximately(newPosition, m_AuthoritativeTransform.transform.position), "Authoritative position does not match!");
303305
Assert.True(Approximately(newPosition, m_NonAuthoritativeTransform.transform.position), "Non-Authoritative position does not match!");
304306
m_NonAuthoritativeTransform.SetState(null, newRotation, null, interpolate);
305307
success = WaitForConditionOrTimeOutWithTimeTravel(() => RotationMatchesValue(newRotation.eulerAngles), 800);
306-
Assert.True(success, $"Timed out waiting for non-authoritative rotation state request to be applied!");
307-
Assert.True(Approximately(newRotation.eulerAngles, m_AuthoritativeTransform.transform.rotation.eulerAngles), "Authoritative rotation does not match!");
308-
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), "Non-Authoritative rotation does not match!");
308+
Assert.True(success, $"Timed out waiting for non-authoritative rotation state request to be applied!\n {m_VerboseDebugLog}");
309+
Assert.True(Approximately(newRotation.eulerAngles, m_AuthoritativeTransform.transform.rotation.eulerAngles), $"Authoritative rotation does not match!\n {m_VerboseDebugLog}");
310+
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), $"Non-Authoritative rotation does not match!\n {m_VerboseDebugLog}");
309311

310312
m_NonAuthoritativeTransform.SetState(null, null, newScale, interpolate);
311313
success = WaitForConditionOrTimeOutWithTimeTravel(() => ScaleMatchesValue(newScale), 800);
312-
Assert.True(success, $"Timed out waiting for non-authoritative scale state request to be applied!");
313-
Assert.True(Approximately(newScale, m_AuthoritativeTransform.transform.localScale), "Authoritative scale does not match!");
314-
Assert.True(Approximately(newScale, m_NonAuthoritativeTransform.transform.localScale), "Non-Authoritative scale does not match!");
314+
Assert.True(success, $"Timed out waiting for non-authoritative scale state request to be applied!\n {m_VerboseDebugLog}");
315+
Assert.True(Approximately(newScale, m_AuthoritativeTransform.transform.localScale), $"Authoritative scale does not match!\n {m_VerboseDebugLog}");
316+
Assert.True(Approximately(newScale, m_NonAuthoritativeTransform.transform.localScale), $"Non-Authoritative scale does not match!\n {m_VerboseDebugLog}");
315317

316318
// Test all parameters at once
317319
newPosition = new Vector3(-10f, 95f, -25f);
@@ -320,13 +322,13 @@ public void NonAuthorityOwnerSettingStateTest([Values] Interpolation interpolati
320322

321323
m_NonAuthoritativeTransform.SetState(newPosition, newRotation, newScale, interpolate);
322324
success = WaitForConditionOrTimeOutWithTimeTravel(() => PositionRotationScaleMatches(newPosition, newRotation.eulerAngles, newScale), 800);
323-
Assert.True(success, $"Timed out waiting for non-authoritative position, rotation, and scale state request to be applied!");
324-
Assert.True(Approximately(newPosition, m_AuthoritativeTransform.transform.position), "Authoritative position does not match!");
325-
Assert.True(Approximately(newPosition, m_NonAuthoritativeTransform.transform.position), "Non-Authoritative position does not match!");
326-
Assert.True(Approximately(newRotation.eulerAngles, m_AuthoritativeTransform.transform.rotation.eulerAngles), "Authoritative rotation does not match!");
327-
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), "Non-Authoritative rotation does not match!");
328-
Assert.True(Approximately(newScale, m_AuthoritativeTransform.transform.localScale), "Authoritative scale does not match!");
329-
Assert.True(Approximately(newScale, m_NonAuthoritativeTransform.transform.localScale), "Non-Authoritative scale does not match!");
325+
Assert.True(success, $"Timed out waiting for non-authoritative position, rotation, and scale state request to be applied!\n {m_VerboseDebugLog}");
326+
Assert.True(Approximately(newPosition, m_AuthoritativeTransform.transform.position), $"Authoritative position does not match!\n {m_VerboseDebugLog}");
327+
Assert.True(Approximately(newPosition, m_NonAuthoritativeTransform.transform.position), $"Non-Authoritative position does not match!\n {m_VerboseDebugLog}");
328+
Assert.True(Approximately(newRotation.eulerAngles, m_AuthoritativeTransform.transform.rotation.eulerAngles), $"Authoritative rotation does not match!\n {m_VerboseDebugLog}");
329+
Assert.True(Approximately(newRotation.eulerAngles, m_NonAuthoritativeTransform.transform.rotation.eulerAngles), $"Non-Authoritative rotation does not match!\n {m_VerboseDebugLog}");
330+
Assert.True(Approximately(newScale, m_AuthoritativeTransform.transform.localScale), $"Authoritative scale does not match!\n {m_VerboseDebugLog}");
331+
Assert.True(Approximately(newScale, m_NonAuthoritativeTransform.transform.localScale), $"Non-Authoritative scale does not match!\n {m_VerboseDebugLog}");
330332
}
331333
}
332334
}

0 commit comments

Comments
 (0)