Skip to content

Commit cea8998

Browse files
test
Adding test to check that no warning messages are logged upon a client disconnecting itself from a session.
1 parent 63c82c0 commit cea8998

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/Connection/ClientConnectionTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System.Collections;
22
using System.Collections.Generic;
3+
using System.Text.RegularExpressions;
34
using NUnit.Framework;
45
using Unity.Netcode.TestHelpers.Runtime;
6+
using UnityEngine;
57
using UnityEngine.TestTools;
68

79
namespace Unity.Netcode.RuntimeTests
@@ -28,6 +30,12 @@ public ClientConnectionTests(SceneManagementState sceneManagementState, NetworkT
2830
m_SceneManagementEnabled = sceneManagementState == SceneManagementState.SceneManagementEnabled;
2931
}
3032

33+
protected override IEnumerator OnSetup()
34+
{
35+
m_ServerCallbackCalled.Clear();
36+
m_ClientCallbackCalled.Clear();
37+
return base.OnSetup();
38+
}
3139
protected override void OnServerAndClientsCreated()
3240
{
3341
m_ServerNetworkManager.NetworkConfig.EnableSceneManagement = m_SceneManagementEnabled;
@@ -55,6 +63,27 @@ public IEnumerator VerifyOnClientConnectedCallback()
5563
Assert.True(m_ServerCallbackCalled.Count == 1 + NumberOfClients);
5664
}
5765

66+
/// <summary>
67+
/// Validates that no warnings are logged upon a client disconnecting and the
68+
/// log level is set to developer.
69+
/// </summary>
70+
[UnityTest]
71+
public IEnumerator VerifyNoWarningOnClientDisconnect()
72+
{
73+
yield return WaitForConditionOrTimeOut(AllCallbacksCalled);
74+
AssertOnTimeout("Timed out waiting for all clients to be connected!");
75+
76+
var authority = GetAuthorityNetworkManager();
77+
var clientToDisconnect = GetNonAuthorityNetworkManager();
78+
clientToDisconnect.LogLevel = LogLevel.Developer;
79+
authority.LogLevel = LogLevel.Developer;
80+
81+
yield return StopOneClient(clientToDisconnect);
82+
83+
NetcodeLogAssert.LogWasNotReceived(LogType.Warning, new Regex(".*"));
84+
}
85+
86+
5887
private void Server_OnClientConnectedCallback(ulong clientId)
5988
{
6089
if (!m_ServerCallbackCalled.Add(clientId))

0 commit comments

Comments
 (0)