Skip to content

Commit 9e9691c

Browse files
test: testproject hybrid integration tests - 1st pass (#4175)
* test: opt testproject integration tests into hybrid prefab mode Opts in RpcTestsAutomated, RpcUserSerializableTypesTest, DontDestroyOnLoadTests, SenderIdTests, NetworkObjectSpawning, RpcObserverTests and NetworkObjectDestroyWithSceneTests. Hybrid cases that hit a known limitation are skipped: a client shutting down disposes every world in the process (SenderIdTests, RpcObserverTests), in-scene placed NetworkObjects are not supported (NetworkObjectSpawning.SpawnOnSynchronizedNotification), and InstantiateAndSpawn does not select the NetworkManager's world before instantiating a hybrid prefab (NetworkObjectSpawning.InstantiateAndSpawn). Removes the unified fixtures from PrefabExtendedTests, NetworkBehaviourSessionSynchronized, RespawnInSceneObjectsAfterShutdown, SceneObjectsNotDestroyedOnShutdownTest and ServerDisconnectsClientTest, which depend on in-scene placed NetworkObjects or on one peer shutting down while the others keep running. * test: remove the NetworkObjectSpawning hybrid fixture Its only hybrid case left running, CannotSpawnBeforeApproved, spawns nothing outside distributed authority, so it passed without exercising hybrid spawning. The other two tests depend on in-scene placed NetworkObjects and on InstantiateAndSpawn, which does not yet select the NetworkManager's world for hybrid prefabs.
1 parent 38a4a92 commit 9e9691c

12 files changed

Lines changed: 56 additions & 19 deletions

‎testproject/Assets/Tests/Runtime/DontDestroyOnLoadTests.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public class DontDestroyOnLoadTests : NetcodeIntegrationTest
2222

2323
public DontDestroyOnLoadTests(HostOrServer hostOrServer) : base(hostOrServer) { }
2424

25+
#if UNIFIED_NETCODE
26+
protected override bool UseUnifiedTests()
27+
{
28+
return true;
29+
}
30+
#endif
31+
2532
protected override void OnServerAndClientsCreated()
2633
{
2734
m_DontDestroyOnLoadObject = CreateNetworkObjectPrefab("DDOLObject");

‎testproject/Assets/Tests/Runtime/NetworkBehaviourSessionSynchronized.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ namespace TestProject.RuntimeTests
99
{
1010
[TestFixture(HostOrServer.Host)]
1111
[TestFixture(HostOrServer.DAHost)]
12-
#if UNIFIED_NETCODE
13-
[TestFixture(HostOrServer.UnifiedHost)]
14-
#endif
1512
public class NetworkBehaviourSessionSynchronized : NetcodeIntegrationTest
1613
{
1714
private const string k_SceneToLoad = "SessionSynchronize";

‎testproject/Assets/Tests/Runtime/NetworkObjectDestroyWithSceneTests.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ internal class NetworkObjectDestroyWithSceneTests : NetcodeIntegrationTest
2929

3030
public NetworkObjectDestroyWithSceneTests(HostOrServer hostOrServer) : base(hostOrServer) { }
3131

32+
#if UNIFIED_NETCODE
33+
protected override bool UseUnifiedTests()
34+
{
35+
return true;
36+
}
37+
#endif
38+
3239
protected override void OnServerAndClientsCreated()
3340
{
3441
m_TestPrefab = CreateNetworkObjectPrefab("TestObject").GetComponent<NetworkObject>();

‎testproject/Assets/Tests/Runtime/NetworkObjectSpawning.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
namespace TestProject.RuntimeTests
1111
{
1212
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.Host)]
13-
#if UNIFIED_NETCODE
14-
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.UnifiedHost)]
15-
#endif
1613
[TestFixture(NetworkTopologyTypes.DistributedAuthority, HostOrServer.DAHost)]
1714
internal class NetworkObjectSpawning : NetcodeIntegrationTest
1815
{

‎testproject/Assets/Tests/Runtime/PrefabExtendedTests.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ namespace TestProject.RuntimeTests
1414
// DAMODE-TODO: When scene management is working in distributed authority mode we need to update this test
1515
[TestFixture(SceneManagementTypes.SceneManagementEnabled, HostOrServer.Host)]
1616
[TestFixture(SceneManagementTypes.SceneManagementDisabled, HostOrServer.Host)]
17-
#if UNIFIED_NETCODE
18-
[TestFixture(SceneManagementTypes.SceneManagementEnabled, HostOrServer.UnifiedHost)]
19-
[TestFixture(SceneManagementTypes.SceneManagementDisabled, HostOrServer.UnifiedHost)]
20-
#endif
2117
public class PrefabExtendedTests : NetcodeIntegrationTest
2218
{
2319
private const string k_PrefabTestScene = "PrefabTestScene";

‎testproject/Assets/Tests/Runtime/RespawnInSceneObjectsAfterShutdown.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ namespace TestProject.RuntimeTests
1010
{
1111
[TestFixture(NetworkTopologyTypes.DistributedAuthority, HostOrServer.DAHost)]
1212
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.Host)]
13-
#if UNIFIED_NETCODE
14-
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.UnifiedHost)]
15-
#endif
1613
public class RespawnInSceneObjectsAfterShutdown : NetcodeIntegrationTest
1714
{
1815
public const string SceneToLoad = "InSceneNetworkObject";

‎testproject/Assets/Tests/Runtime/RpcObserverTests.cs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ protected override bool UseCMBService()
4242

4343
public RpcObserverTests(HostOrServer hostOrServer) : base(hostOrServer) { }
4444

45+
#if UNIFIED_NETCODE
46+
protected override bool UseUnifiedTests()
47+
{
48+
return true;
49+
}
50+
#endif
51+
4552
protected override void OnServerAndClientsCreated()
4653
{
4754
m_TestPrefab = CreateNetworkObjectPrefab($"{nameof(RpcObserverObject)}");
@@ -106,6 +113,14 @@ public IEnumerator ClientRpcObserverTest()
106113
m_ServerRpcObserverObject.ObserverMessageClientRpc(clientRpcParams);
107114
yield return s_DefaultWaitForTick;
108115

116+
#if UNIFIED_NETCODE
117+
// Disconnecting a client disposes every world in the process when hybrid prefabs are registered.
118+
if (m_AllPrefabsAsHybrid)
119+
{
120+
m_ServerNetworkManager.LogLevel = LogLevel.Normal;
121+
yield break;
122+
}
123+
#endif
109124
// Validate we can still just send to the host-client when no clients are connected
110125
if (m_UseHost)
111126
{

‎testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public RpcTestsAutomated(HostOrServer hostOrServer) : base(hostOrServer)
3131

3232
}
3333

34+
#if UNIFIED_NETCODE
35+
protected override bool UseUnifiedTests()
36+
{
37+
return true;
38+
}
39+
#endif
40+
3441
protected override NetworkManagerInstatiationMode OnSetIntegrationTestMode()
3542
{
3643
return NetworkManagerInstatiationMode.DoNotCreate;

‎testproject/Assets/Tests/Runtime/RpcUserSerializableTypesTest.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ protected override bool UseCMBService()
9393

9494
public RpcUserSerializableTypesTest(NetworkTopologyTypes networkTopologyType, HostOrServer hostOrServer) : base(networkTopologyType, hostOrServer) { }
9595

96+
#if UNIFIED_NETCODE
97+
protected override bool UseUnifiedTests()
98+
{
99+
return true;
100+
}
101+
#endif
102+
96103
protected override NetworkManagerInstatiationMode OnSetIntegrationTestMode()
97104
{
98105
return NetworkManagerInstatiationMode.DoNotCreate;

‎testproject/Assets/Tests/Runtime/SceneObjectsNotDestroyedOnShutdownTest.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ namespace TestProject.RuntimeTests
1111
{
1212
[TestFixture(NetworkTopologyTypes.DistributedAuthority, HostOrServer.DAHost)]
1313
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.Host)]
14-
#if UNIFIED_NETCODE
15-
[TestFixture(NetworkTopologyTypes.ClientServer, HostOrServer.UnifiedHost)]
16-
#endif
1714
public class SceneObjectsNotDestroyedOnShutdownTest : NetcodeIntegrationTest
1815
{
1916
protected override int NumberOfClients => 0;

0 commit comments

Comments
 (0)