diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs index 563c43b166..8bf2663d66 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs @@ -12,6 +12,8 @@ internal class BuildTests { public const string DefaultBuildScenePath = "Tests/Editor/Build/BuildTestScene.unity"; + // Increased the Build test timeout from 3 to 10 minutes. + [Timeout(900000)] [Test] public void BasicBuildTest() { diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs index a29361e195..29a6efe7b2 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs @@ -63,6 +63,25 @@ protected override void OnCreatePlayerPrefab() base.OnCreatePlayerPrefab(); } + /// + /// Bypassing this on v1.x as the deferred show message could be processed on the next + /// frame from when the client registers having connected. + /// + protected override bool ShouldWaitForNewClientToConnect(NetworkManager networkManager) + { + return false; + } + + /// + /// Validate that the player object is spawned on the client side. + /// + /// + private bool ClientSpawnedPlayer() + { + var playerObject = m_ClientNetworkManagers[0].LocalClient.PlayerObject; + return playerObject != null && playerObject.IsSpawned && playerObject.IsOwner; + } + /// /// Tests the scenario where under a client-server network topology if a player prefab /// is spawned by the server with no observers but the player prefab itself has server @@ -81,7 +100,17 @@ public IEnumerator NetworkShowOnSpawnTest([Values] PlayerSpawnStages spawnStage) yield return CreateAndStartNewClient(); - yield return new WaitForSeconds(0.25f); + // Wait for the new client to connect + yield return WaitForClientsConnectedOrTimeOut(); + AssertOnTimeout($"Timed out waiting for client to connect!"); + OnNewClientStartedAndConnected(m_ClientNetworkManagers[0]); + + // Wait for the new client to have spawned the player + yield return WaitForConditionOrTimeOut(ClientSpawnedPlayer); + AssertOnTimeout($"Timed out waiting for client to spawn its player object!"); + + // Provide some time to assure there are no additional attempts to spawn the same instance + yield return new WaitForSeconds(0.5f); NetcodeLogAssert.LogWasNotReceived(LogType.Warning, new Regex("but it is already in the spawned list!")); var client = GetNonAuthorityNetworkManager(); diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs index 9984ccb8a2..d064d7b3b2 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs @@ -270,7 +270,8 @@ public override void OnUpdate() // Add it to the table of state updates var stateEntry = new StateEntry() { - TimeAdded = Time.realtimeSinceStartup, + // Use the server time to get the valid "relative" time since the session started. + TimeAdded = NetworkManager.ServerTime.TimeAsFloat, State = m_PosInterpolator.InterpolateState, };