11using System . Collections ;
22using System . Collections . Generic ;
3+ using System . Text . RegularExpressions ;
34using NUnit . Framework ;
45using Unity . Netcode . TestHelpers . Runtime ;
6+ using UnityEngine ;
57using UnityEngine . TestTools ;
68
79namespace 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